2 # pin a release in apt, useful for unstable repositories
14 $release_version = '', # v=
16 $originator = '', # o=
19 if $order and !is_integer($order) {
20 fail('Only integers are allowed in the apt::pin order param')
24 $_explanation = $explanation
26 if defined('$caller_module_name') { # strict vars check
27 $_explanation = "${caller_module_name}: ${name}"
29 $_explanation = ": ${name}"
33 $pin_release_array = [
40 $pin_release = join($pin_release_array, '')
42 # Read the manpage 'apt_preferences(5)', especially the chapter
43 # 'The Effect of APT Preferences' to understand the following logic
44 # and the difference between specific and general form
45 if is_array($packages) {
46 $packages_string = join($packages, ' ')
48 $packages_string = $packages
51 if $packages_string != '*' { # specific form
52 if ( $pin_release != '' and ( $origin != '' or $version != '' )) or
53 ( $version != '' and ( $pin_release != '' or $origin != '' )) {
54 fail('parameters release, origin, and version are mutually exclusive')
56 } else { # general form
58 fail('parameter version cannot be used in general form')
60 if ( $pin_release != '' and $origin != '' ) {
61 fail('parameters release and origin are mutually exclusive')
65 # According to man 5 apt_preferences:
66 # The files have either no or "pref" as filename extension
67 # and only contain alphanumeric, hyphen (-), underscore (_) and period
68 # (.) characters. Otherwise APT will print a notice that it has ignored a
69 # file, unless that file matches a pattern in the
70 # Dir::Ignore-Files-Silently configuration list - in which case it will
71 # be silently ignored.
72 $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG')
74 apt::setting { "pref-${file_name}":
77 content => template('apt/_header.erb', 'apt/pin.pref.erb'),
78 notify_update => false,