diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-07-21 19:33:36 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2006-07-21 19:33:36 +0000 |
commit | 21ae8fbdcef5b31f4794869b075e344606446555 (patch) | |
tree | 7f6994c250b1cb6ae3006c9ce8fe2f240b4b849e /lib/puppet | |
parent | 039abd6d792dd99bf5c1ad272c4f841f80ea5642 (diff) | |
download | puppet-21ae8fbdcef5b31f4794869b075e344606446555.tar.gz puppet-21ae8fbdcef5b31f4794869b075e344606446555.tar.xz puppet-21ae8fbdcef5b31f4794869b075e344606446555.zip |
Fixing #185. Added a check for cdrom sources, and added an override parameter.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1417 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet')
-rw-r--r-- | lib/puppet/type/package.rb | 7 | ||||
-rwxr-xr-x | lib/puppet/type/package/apt.rb | 25 |
2 files changed, 32 insertions, 0 deletions
diff --git a/lib/puppet/type/package.rb b/lib/puppet/type/package.rb index 58afe2c1c..e75f6c288 100644 --- a/lib/puppet/type/package.rb +++ b/lib/puppet/type/package.rb @@ -379,6 +379,13 @@ module Puppet desc "A read-only parameter set by the package." end + newparam(:allowcdrom) do + desc "Tells apt to allow cdrom sources in the sources.list file. + Normally apt will bail if you try this." + + newvalues(:true, :false) + end + autorequire(:file) do autos = [] [:responsefile, :adminfile].each { |param| diff --git a/lib/puppet/type/package/apt.rb b/lib/puppet/type/package/apt.rb index 10a1506a2..cc1e26a06 100755 --- a/lib/puppet/type/package/apt.rb +++ b/lib/puppet/type/package/apt.rb @@ -2,15 +2,40 @@ module Puppet Puppet.type(:package).newpkgtype(:apt, :dpkg) do ENV['DEBIAN_FRONTEND'] = "noninteractive" + + # A derivative of DPKG; this is how most people actually manage # Debian boxes, and the only thing that differs is that it can # install packages from remote sites. + def checkforcdrom + unless defined? @@checkedforcdrom + if FileTest.exists? "/etc/apt/sources.list" + if File.read("/etc/apt/sources.list") =~ /^[^#]*cdrom:/ + @@checkedforcdrom = true + else + @@checkedforcdrom = false + end + else + # This is basically a pathalogical case, but we'll just + # ignore it + @@checkedforcdrom = false + end + end + + if @@checkedforcdrom and self[:allowcdrom] != :true + raise Puppet::Error, + "/etc/apt/sources.list contains a cdrom source; not installing. Use 'allowcdrom' to override this failure." + end + end + # Install a package using 'apt-get'. This function needs to support # installing a specific version. def install should = self.should(:ensure) + checkforcdrom() + str = self[:name] case should when true, false, Symbol |