aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README6
-rw-r--r--manifests/preferences_snippet.pp23
-rw-r--r--templates/preferences_snippet.erb2
-rw-r--r--templates/preferences_snippet_release.erb4
4 files changed, 31 insertions, 4 deletions
diff --git a/README b/README
index 82d216a..2e9d48f 100644
--- 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
----------------------
diff --git a/manifests/preferences_snippet.pp b/manifests/preferences_snippet.pp
index 908ca73..e00c4d1 100644
--- a/manifests/preferences_snippet.pp
+++ b/manifests/preferences_snippet.pp
@@ -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: {
diff --git a/templates/preferences_snippet.erb b/templates/preferences_snippet.erb
index 0c4e136..fd15ce6 100644
--- a/templates/preferences_snippet.erb
+++ b/templates/preferences_snippet.erb
@@ -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
index 0000000..0c4e136
--- /dev/null
+++ b/templates/preferences_snippet_release.erb
@@ -0,0 +1,4 @@
+Package: <%= package %>
+Pin: release a=<%= release %>
+Pin-Priority: <%= priority %>
+