def run
if File.exist?(@module_name) || File.symlink?(@module_name) then
if force? then
FileUtils.rm_rf @module_name rescue nil
else
check_clobber!
FileUtils.rm_rf @module_name rescue nil
end
end
build_dir = Puppet::Module::Tool::Cache.base_path + "tmp-unpacker-#{Digest::SHA1.hexdigest(@filename.basename.to_s)}"
build_dir.mkpath
begin
FileUtils.cp @filename, build_dir
Dir.chdir(build_dir) do
unless system "tar xzf #{@filename.basename}"
abort "Could not extract contents of module archive."
end
end
extracted = build_dir.children.detect { |c| c.directory? }
FileUtils.cp_r extracted, @module_name
tag_revision
ensure
build_dir.rmtree
end
say "Installed #{@release_name.inspect} into directory: #{@module_name}"
end