]> gitweb.fluxo.info Git - puppet-apt.git/commitdiff
Allow passing arbitrary Pin value to apt::preferences_snippet.
authorintrigeri <intrigeri@boum.org>
Fri, 8 Jun 2012 16:30:23 +0000 (18:30 +0200)
committerintrigeri <intrigeri@boum.org>
Fri, 8 Jun 2012 16:30:23 +0000 (18:30 +0200)
Closes: Redmine#3467.
README
manifests/preferences_snippet.pp
templates/preferences_snippet.erb
templates/preferences_snippet_release.erb [new file with mode: 0644]

diff --git a/README b/README
index 82d216a5cff19b369816f18895b5d96c8829495a..2e9d48f5af03ce9a486b13e6f9ba5f503887e2cf 100644 (file)
--- a/README
+++ b/README
@@ -321,6 +321,12 @@ Example:
       priority => 1;
   }
 
+  apt::preferences_snippet{
+    'ttdnsd':
+      pin => 'origin deb.torproject.org',
+      priority => 999;
+  }
+
 apt::preseeded_package
 ----------------------
 
index 908ca7344dfdfa839834d9d3e217106ddee3a6be..e00c4d1e5e3a6ac91d7cd34fff0294671d1f7af1 100644 (file)
@@ -2,7 +2,8 @@ define apt::preferences_snippet(
   $package = $name,
   $ensure = 'present',
   $source = '',
-  $release,
+  $release = '',
+  $pin = '',
   $priority )
 {
 
@@ -10,6 +11,13 @@ define apt::preferences_snippet(
     fail("Trying to define a preferences_snippet with \$custom_preferences set to false.")
   }
 
+  if !$pin and !$release {
+    fail("apt::preferences_snippet requires one of the 'pin' or 'release' argument to be set")
+  }
+  if $pin and $release {
+    fail("apt::preferences_snippet requires either a 'pin' or 'release' argument, not both")
+  }
+
   include apt::preferences
 
   concat::fragment{"apt_preference_${name}":
@@ -22,8 +30,17 @@ define apt::preferences_snippet(
   # lenny, we can't generalize without going into ugly special-casing.
   case $source {
     '': {
-      Concat::Fragment["apt_preference_${name}"]{
-        content => template("apt/preferences_snippet.erb")
+      case $release {
+        '': {
+          Concat::Fragment["apt_preference_${name}"]{
+            content => template("apt/preferences_snippet.erb")
+          }
+        }
+        default: {
+          Concat::Fragment["apt_preference_${name}"]{
+            content => template("apt/preferences_snippet_release.erb")
+          }
+        }
       }
     }
     default: {
index 0c4e136ddc7c0d09d3be86f639ec612d1d205b52..fd15ce64a3af21ad66291d0208c803dfdba9cb99 100644 (file)
@@ -1,4 +1,4 @@
 Package: <%= package %>
-Pin: release a=<%= release %>
+Pin: <%= pin %>
 Pin-Priority: <%= priority %>
 
diff --git a/templates/preferences_snippet_release.erb b/templates/preferences_snippet_release.erb
new file mode 100644 (file)
index 0000000..0c4e136
--- /dev/null
@@ -0,0 +1,4 @@
+Package: <%= package %>
+Pin: release a=<%= release %>
+Pin-Priority: <%= priority %>
+