'' => "${preferences_d}/${name}.pref",
default => "${preferences_d}/${order}-${name}.pref",
}
- file { "${name}.pref":
+
+ # 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')
+
+ file { "${file_name}.pref":
ensure => $ensure,
path => $path,
owner => root,
}
end
end
+
+ describe 'resource title with invalid chars' do
+ context 'spaces' do
+ let(:title) { 'oh my god this is not valid' }
+ it { should contain_file('oh_my_god_this_is_not_valid.pref') }
+ end
+
+ context '#$&*$' do
+ let(:title) { 'so && many $* invalid @! things' }
+ it { should contain_file('so____many____invalid____things.pref') }
+ end
+ end
end