if RUBY_VERSION == '1.8.7'
# Mothers cry, puppies die and Ruby 1.8.7's open-uri needs to be
# monkeypatched to support passing in :ftp_passive_mode.
- require 'puppet_x/apt_key/patch_openuri'
+ require File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..',
+ 'puppet_x', 'apt_key', 'patch_openuri.rb'))
OpenURI::Options.merge!({:ftp_active_mode => false,})
end
commands :apt_key => 'apt-key'
def self.instances
- key_array = apt_key('list').split("\n").collect do |line|
+ if RUBY_VERSION > '1.8.7'
+ key_output = apt_key('list').encode('UTF-8', 'binary', :invalid => :replace, :undef => :replace, :replace => '')
+ else
+ key_output = apt_key('list')
+ end
+ key_array = key_output.split("\n").collect do |line|
line_hash = key_line_hash(line)
next unless line_hash
expired = false
def self.prefetch(resources)
apt_keys = instances
resources.keys.each do |name|
- if provider = apt_keys.find{ |key| key.name == name }
+ if name.length == 16
+ shortname=name[8..-1]
+ else
+ shortname=name
+ end
+ if provider = apt_keys.find{ |key| key.name == shortname }
resources[name].provider = provider
end
end