02bd326994
Details: https://labs.riseup.net/code/issues/3467 https://labs.riseup.net/code/issues/3468
57 lines
1.4 KiB
Puppet
57 lines
1.4 KiB
Puppet
define apt::preferences_snippet(
|
|
$package = false,
|
|
$ensure = 'present',
|
|
$source = '',
|
|
$release = '',
|
|
$pin = '',
|
|
$priority )
|
|
{
|
|
|
|
$real_package = $package ? {
|
|
false => $name,
|
|
default => $package,
|
|
}
|
|
|
|
if $custom_preferences == false {
|
|
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}":
|
|
ensure => $ensure,
|
|
target => '/etc/apt/preferences',
|
|
}
|
|
|
|
# This should really work in the same manner as sources_list and apt_conf
|
|
# snippets, but since the preferences.d directory cannot be used in Debian
|
|
# lenny, we can't generalize without going into ugly special-casing.
|
|
case $source {
|
|
'': {
|
|
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: {
|
|
Concat::Fragment["apt_preference_${name}"]{
|
|
source => $source
|
|
}
|
|
}
|
|
}
|
|
}
|