2013-01-02 14:12:11 +01:00
|
|
|
define apt::preferences_snippet (
|
|
|
|
$priority,
|
2012-06-18 22:57:13 +02:00
|
|
|
$package = false,
|
2010-10-17 14:13:02 +02:00
|
|
|
$ensure = 'present',
|
2010-10-25 06:14:33 +02:00
|
|
|
$source = '',
|
2012-06-08 18:30:23 +02:00
|
|
|
$release = '',
|
2013-01-02 14:12:11 +01:00
|
|
|
$pin = ''
|
|
|
|
) {
|
2010-12-07 19:18:41 +01:00
|
|
|
|
2012-06-18 22:57:13 +02:00
|
|
|
$real_package = $package ? {
|
|
|
|
false => $name,
|
|
|
|
default => $package,
|
|
|
|
}
|
|
|
|
|
2010-10-25 18:17:50 +02:00
|
|
|
if $custom_preferences == false {
|
2013-01-02 14:12:11 +01:00
|
|
|
fail('Trying to define a preferences_snippet with $custom_preferences set to false.')
|
2010-10-25 18:17:50 +02:00
|
|
|
}
|
|
|
|
|
2012-06-08 18:30:23 +02:00
|
|
|
if !$pin and !$release {
|
2013-01-02 14:12:11 +01:00
|
|
|
fail('apt::preferences_snippet requires one of the \'pin\' or \'release\' argument to be set')
|
2012-06-08 18:30:23 +02:00
|
|
|
}
|
|
|
|
if $pin and $release {
|
2013-01-02 14:12:11 +01:00
|
|
|
fail('apt::preferences_snippet requires either a \'pin\' or \'release\' argument, not both')
|
2012-06-08 18:30:23 +02:00
|
|
|
}
|
|
|
|
|
2012-09-20 09:55:58 +02:00
|
|
|
file { "/etc/apt/preferences.d/${name}":
|
2010-10-17 13:58:59 +02:00
|
|
|
ensure => $ensure,
|
2013-01-02 14:12:11 +01:00
|
|
|
owner => root, group => 0, mode => '0644';
|
2010-10-17 13:58:59 +02:00
|
|
|
}
|
2010-10-25 06:14:33 +02:00
|
|
|
|
|
|
|
# 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 {
|
2010-10-28 22:05:37 +02:00
|
|
|
'': {
|
2012-06-08 18:30:23 +02:00
|
|
|
case $release {
|
|
|
|
'': {
|
2012-09-20 09:55:58 +02:00
|
|
|
File["/etc/apt/preferences.d/${name}"]{
|
2013-01-02 14:12:11 +01:00
|
|
|
content => template('apt/preferences_snippet.erb')
|
2012-06-08 18:30:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default: {
|
2012-09-20 09:55:58 +02:00
|
|
|
File["/etc/apt/preferences.d/${name}"]{
|
2013-01-02 14:12:11 +01:00
|
|
|
content => template('apt/preferences_snippet_release.erb')
|
2012-06-08 18:30:23 +02:00
|
|
|
}
|
|
|
|
}
|
2010-10-28 22:05:37 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default: {
|
2012-09-20 09:55:58 +02:00
|
|
|
File["/etc/apt/preferences.d/${name}"]{
|
2010-10-25 06:14:33 +02:00
|
|
|
source => $source
|
|
|
|
}
|
2010-10-28 22:05:37 +02:00
|
|
|
}
|
2010-10-25 06:14:33 +02:00
|
|
|
}
|
2010-10-17 13:58:59 +02:00
|
|
|
}
|