From 94484df1a8d00e0eae35cbe09c0e5d2ff4b16f49 Mon Sep 17 00:00:00 2001 From: luke Date: Mon, 9 Oct 2006 18:29:44 +0000 Subject: Applying patch from #234 from David Schmitt. This is also untested, and the patch is slightly modified. git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1754 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/provider/package/apt.rb | 15 ++++++++++++++- lib/puppet/type/package.rb | 29 +++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) (limited to 'lib/puppet') diff --git a/lib/puppet/provider/package/apt.rb b/lib/puppet/provider/package/apt.rb index 9c4478eba..5c6dc8916 100755 --- a/lib/puppet/provider/package/apt.rb +++ b/lib/puppet/provider/package/apt.rb @@ -41,6 +41,8 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg do end end + attr_accessor :keepconfig + # Install a package using 'apt-get'. This function needs to support # installing a specific version. def install @@ -59,7 +61,18 @@ Puppet::Type.type(:package).provide :apt, :parent => :dpkg do # Add the package version str += "=%s" % should end - aptcmd("-q -y install %s" % str) + + keep = "" + if defined? @keepconfig + case @keepconfig + when true + keep = "-o 'DPkg::Options::=--force-confold'" + else + keep = "-o 'DPkg::Options::=--force-confnew'" + end + end + + aptcmd("-q -y %s install %s" % [keep, str]) end # What's the latest package version available? diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 749c9e76a..47b6331ea 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -242,6 +242,35 @@ module Puppet generally be a fully qualified path." end + newparam(:configfiles) do + desc "Whether configfiles should be kept or replaced. Most packages + types do not support this parameter, but those that do will default + to keeping their configuration files." + + unless provider.respond_to?(:keepconfig=) + self.fail( + "Package provider %s does not support keeping the configuration files" % + @parent[:provider] + ) + end + + # There is only a default for those that support this parameter. + defaultto do + if provider.respond_to?(:keepconfig) + :keep + else + nil + end + end + + newvalue(:keep) do + provider.keepconfig = true + end + newvalue(:replace) do + provider.keepconfig = false + end + end + newparam(:category) do desc "A read-only parameter set by the package." end -- cgit