def create_bundle(fname)
bpath = File::join(session.path(:bundle), session.name)
fpath = File::join(bpath, Puppet::Module::FILES)
mpath = File::join(bpath, Puppet::Module::MANIFESTS)
after = session.path(:after)
if File::exists?(bpath)
system("rm -rf #{bpath}")
end
[bpath, mpath, fpath].each { |p| FileUtils::mkdir_p(p) }
trans = transportable
trans.each_obj do |f|
if f.type.to_sym == :file
src = f[:source]
next unless src
tgt = File::join(fpath, src[after.size..-1])
tgt_dir = File::dirname(tgt)
unless File::directory?(tgt_dir)
FileUtils::mkdir_p(tgt_dir)
end
FileUtils::cp_r(src, tgt)
f[:source] = "puppet:///#{session.name}/" + File::basename(src)
end
end
File::open(File::join(mpath, "init.pp"), "w") do |f|
f.puts(trans.to_manifest)
end
%x{tar -czf #{fname} -C #{File::join(bpath, "..")} #{File::basename(bpath)} 2>&1}
unless $? == 0
raise Error, "Failed to create #{fname}"
end
end