]> review.fuel-infra Code Review - puppet-modules/puppetlabs-apt.git/commitdiff
backports: Add support back for backports.
authorDaniele Sluijters <daenney@users.noreply.github.com>
Tue, 7 Apr 2015 11:51:10 +0000 (13:51 +0200)
committerMorgan Haskel <morgan@puppetlabs.com>
Thu, 9 Apr 2015 22:44:20 +0000 (15:44 -0700)
This is currently lacking tests.

manifests/backports.pp [new file with mode: 0644]
manifests/params.pp

diff --git a/manifests/backports.pp b/manifests/backports.pp
new file mode 100644 (file)
index 0000000..3cac0b5
--- /dev/null
@@ -0,0 +1,59 @@
+class apt::backports (
+  $location = undef,
+  $release  = undef,
+  $repos    = undef,
+  $key      = undef,
+  $pin      = 200,
+){
+  if $location {
+    validate_string($location)
+    $_location = $location
+  }
+  if $release {
+    validate_string($release)
+    $_release = $release
+  }
+  if $repos {
+    validate_string($repos)
+    $_repos = $repos
+  }
+  if $key {
+    unless is_hash($key) {
+      validate_string($key)
+    }
+    $_key = $key
+  }
+  unless is_hash($pin) {
+    unless (is_numeric($pin) or is_string($pin)) {
+      fail('pin must be either a string, number or hash')
+    }
+  }
+
+  if ($::apt::xfacts['lsbdistid'] == 'debian' or $::apt::xfacts['lsbdistid'] == 'ubuntu') {
+    unless $location {
+      $_location = $::apt::backports['location']
+    }
+    unless $release {
+      $_release = "${::apt::xfacts['lsbdistcodename']}-backports"
+    }
+    unless $repos {
+      $_repos = $::apt::backports['repos']
+    }
+    unless $key {
+      $_key =  $::apt::backports['key']
+    }
+  } else {
+    unless $location and $release and $repos and $key {
+      fail('If not on Debian or Ubuntu, you must explicitly pass location, release, repos, and key')
+    }
+  }
+
+  apt::source { 'backports':
+    location => $_location,
+    release  => $_release,
+    repos    => $_repos,
+    key      => $_key,
+    pin      => $pin,
+  }
+
+}
index 57cee5007d65ee75a21f06c4a6afa4ec315db807..6f7e5f9dc04dbc7d83f2a539ee9ffc7a428b92f7 100644 (file)
@@ -119,7 +119,27 @@ class apt::params {
     }
   }
   case $distid {
+    'debian': {
+      case $distcodename {
+        'squeeze': {
+          $backports = {'location' => 'http://backports.debian.org/debian-backports',
+                        'key'       => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD6246925553',
+                        'repos'     => 'main contrib non-free',
+          }
+        }
+        default: {
+          $backports = {'location' => 'http://ftp.debian.org/debian/',
+                        'key'       => 'A1BD8E9D78F7FE5C3E65D8AF8B48AD624692555',
+                        'repos'     => 'main contrib non-free',
+          }
+        }
+      }
+    }
     'ubuntu': {
+      $backports = {'location' => 'http://archive.ubuntu.com/ubuntu',
+                    'key'       => '630239CC130E1A7FD81A27B140976EAF437D05B5',
+                    'repos'     => 'main universe multiverse restricted',
+      }
       case $distcodename {
         'lucid': {
           $ppa_options        = undef