2 # pin a release in apt, useful for unstable repositories
6 $explanation = "${caller_module_name}: ${name}",
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')
23 $pin_release_array = [
30 $pin_release = join($pin_release_array, '')
32 # Read the manpage 'apt_preferences(5)', especially the chapter
33 # 'The Effect of APT Preferences' to understand the following logic
34 # and the difference between specific and general form
35 if is_array($packages) {
36 $packages_string = join($packages, ' ')
38 $packages_string = $packages
41 if $packages_string != '*' { # specific form
42 if ( $pin_release != '' and ( $origin != '' or $version != '' )) or
43 ( $version != '' and ( $pin_release != '' or $origin != '' )) {
44 fail('parameters release, origin, and version are mutually exclusive')
46 } else { # general form
48 fail('parameter version cannot be used in general form')
50 if ( $pin_release != '' and $origin != '' ) {
51 fail('parameters release and origin are mutually exclusive')
55 # According to man 5 apt_preferences:
56 # The files have either no or "pref" as filename extension
57 # and only contain alphanumeric, hyphen (-), underscore (_) and period
58 # (.) characters. Otherwise APT will print a notice that it has ignored a
59 # file, unless that file matches a pattern in the
60 # Dir::Ignore-Files-Silently configuration list - in which case it will
61 # be silently ignored.
62 $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG')
64 apt::setting { "pref-${file_name}":
67 content => template('apt/_header.erb', 'apt/pin.pref.erb'),