- $path = $order ? {
- '' => "${preferences_d}/${name}.pref",
- default => "${preferences_d}/${order}-${name}.pref",
- }
- file { "${name}.pref":
- ensure => $ensure,
- path => $path,
- owner => root,
- group => root,
- mode => '0644',
- content => template('apt/pin.pref.erb'),
+ # According to man 5 apt_preferences:
+ # The files have either no or "pref" as filename extension
+ # and only contain alphanumeric, hyphen (-), underscore (_) and period
+ # (.) characters. Otherwise APT will print a notice that it has ignored a
+ # file, unless that file matches a pattern in the
+ # Dir::Ignore-Files-Silently configuration list - in which case it will
+ # be silently ignored.
+ $file_name = regsubst($title, '[^0-9a-z\-_\.]', '_', 'IG')
+
+ $headertmp = epp('apt/_header.epp')
+
+ $pinpreftmp = epp('apt/pin.pref.epp', {
+ 'name' => $name,
+ 'pin_release' => $pin_release,
+ 'release' => $release,
+ 'codename' => $codename,
+ 'release_version' => $release_version,
+ 'component' => $component,
+ 'originator' => $originator,
+ 'label' => $label,
+ 'version' => $version,
+ 'origin' => $origin,
+ 'explanation' => $_explanation,
+ 'packages_string' => $packages_string,
+ 'priority' => $priority,
+ })
+
+ apt::setting { "pref-${file_name}":
+ ensure => $ensure,
+ priority => $order,
+ content => "${headertmp}${pinpreftmp}",
+ notify_update => false,