Add functionality to support apt pinning to more than just the release.
authorZach Leslie <zach@puppetlabs.com>
Mon, 21 May 2012 21:19:18 +0000 (14:19 -0700)
committerZach Leslie <zach@puppetlabs.com>
Mon, 21 May 2012 21:19:18 +0000 (14:19 -0700)
Write the pin preference filename as ${name} rather than ${release}, so
that we can pin more than one thing.

Change apt::source so that when pin is set, that it pins to the origin
rather than the release.

manifests/pin.pp
manifests/source.pp

index 29fddfb85ae4656369c023b1e2522bf909f2ff5c..2664c9ba6a40199fde9203b6d99b07a3cf1a8615 100644 (file)
@@ -5,19 +5,28 @@ define apt::pin(
   $ensure   = present,
   $packages = '*',
   $priority = 0,
   $ensure   = present,
   $packages = '*',
   $priority = 0,
-  $release  = $name
+  $release  = '',
+  $origin   = ''
 ) {
 
   include apt::params
 
   $preferences_d = $apt::params::preferences_d
 
 ) {
 
   include apt::params
 
   $preferences_d = $apt::params::preferences_d
 
+  if $release != '' {
+    $pin = "release a=${release}"
+  } elsif $origin != '' {
+    $pin = "origin \"${origin}\""
+  } else {
+    err("Apt::Pin needs either $release or $origin")
+  }
+
   file { "${name}.pref":
     ensure  => $ensure,
     path    => "${preferences_d}/${name}",
     owner   => root,
     group   => root,
     mode    => '0644',
   file { "${name}.pref":
     ensure  => $ensure,
     path    => "${preferences_d}/${name}",
     owner   => root,
     group   => root,
     mode    => '0644',
-    content => "# ${name}\nPackage: ${packages}\nPin: release a=${release}\nPin-Priority: ${priority}",
+    content => "# ${name}\nPackage: ${packages}\nPin: ${pin}\nPin-Priority: ${priority}",
   }
 }
   }
 }
index f3fc7b995aa91c3f9c881b2a53302772dc045ab0..0040c14f4e9cb853b66aadf6ab5b30a15b8d52ae 100644 (file)
@@ -35,10 +35,16 @@ define apt::source(
     notify  => Exec['apt_update'],
   }
 
     notify  => Exec['apt_update'],
   }
 
+
   if ($pin != false) and ($ensure == 'present') {
   if ($pin != false) and ($ensure == 'present') {
-    apt::pin { $release:
+    # Get the host portion out of the url so we can pin to origin
+    $url_split = split($location, '/')
+    $host      = $url_split[2]
+
+    apt::pin { $name:
       priority => $pin,
       priority => $pin,
-      before   => File["${name}.list"]
+      before   => File["${name}.list"],
+      origin   => $host,
     }
   }
 
     }
   }