in lib/omnibus/packagers/bff.rb [130:195]
def write_gen_template
files = FileSyncer.glob("#{staging_dir}/**/*").reject do |path|
if path =~ /[[:space:]{}]/
log.warn(log_key) { "Skipping packaging '#{path}' file due to whitespace or braces in filename" }
true
end
end
files.map! do |path|
if path =~ /:|,/
alt = path.gsub(/(:|,)/, "__")
log.debug(log_key) { "Renaming #{path} to #{alt}" }
File.rename(path, alt) if File.exist?(path)
config_script_path = File.join(scripts_staging_dir, "config")
unless File.exist? config_script_path
render_template(resource_path("config.erb"),
destination: "#{scripts_staging_dir}/config",
variables: {
name: project.name,
})
end
File.open(File.join(scripts_staging_dir, "config"), "a") do |file|
file.puts "mv '#{alt.gsub(/^#{staging_dir}/, "")}' '#{path.gsub(/^#{staging_dir}/, "")}'"
end
path = alt
end
path.gsub(/^
end
scripts = SCRIPT_MAP.inject({}) do |hash, (script, installp_key)|
staging_path = File.join(scripts_staging_dir, script.to_s)
if File.file?(staging_path)
hash[installp_key] = staging_path
log.debug(log_key) { installp_key + ":\n" + File.read(staging_path) }
end
hash
end
render_template(resource_path("gen.template.erb"),
destination: File.join(staging_dir, "gen.template"),
variables: {
name: safe_base_package_name,
install_dir: project.install_dir,
friendly_name: project.friendly_name,
version: bff_version,
description: project.description,
files: files,
scripts: scripts,
})
log.debug(log_key) { "Rendered Template:\n" + File.read(File.join(staging_dir, "gen.template")) }
end