lib/omnibus/packagers/bff.rb
def write_gen_template
      # Get a list of all files
      files = FileSyncer.glob("#{staging_dir}/**/*").reject do |path|
        # remove any files with spaces or braces.
        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 paths have colons or commas, rename them and add them to a post-install,
        # post-sysck renaming script ('config') which is created if needed
        if path =~ /:|,/
          alt = path.gsub(/(:|,)/, "__")
          log.debug(log_key) { "Renaming #{path} to #{alt}" }

          File.rename(path, alt) if File.exist?(path)

          # Create a config script if needed based on resources/bff/config.erb
          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(/^#{staging_dir}/, "")
      end

      # Create a map of scripts that exist to inject into the template
      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,
        }
      )

      # Print the full contents of the rendered template file for mkinstallp's use
      log.debug(log_key) { "Rendered Template:\n" + File.read(File.join(staging_dir, "gen.template")) }
    end
def write_gen_template
      # Get a list of all files
      files = FileSyncer.glob("#{staging_dir}/**/*").reject do |path|
        # remove any files with spaces or braces.
        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 paths have colons or commas, rename them and add them to a post-install,
        # post-sysck renaming script ('config') which is created if needed
        if path =~ /:|,/
          alt = path.gsub(/(:|,)/, "__")
          log.debug(log_key) { "Renaming #{path} to #{alt}" }

          File.rename(path, alt) if File.exist?(path)

          # Create a config script if needed based on resources/bff/config.erb
          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(/^#{staging_dir}/, "")
      end

      # Create a map of scripts that exist to inject into the template
      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,
        }
      )

      # Print the full contents of the rendered template file for mkinstallp's use
      log.debug(log_key) { "Rendered Template:\n" + File.read(File.join(staging_dir, "gen.template")) }
    end
Create the gen template for +mkinstallp+.

 @return [void]

 Some details on the various lifecycle scripts:

 The order of the installp scripts is:
 - install
   - pre-install
   - post-install
   - config
 - upgrade
   - pre-remove (of previous version)
   - pre-install (previous version of software not present anymore)
   - post-install
   - config
 - remove
   - unconfig
   - unpre-install

 To run the new version of scc, the post-install will do.
 To run the previous version with an upgrade, use the pre-remove script.
 To run a source install of scc upon installation of installp package, use the pre-install.
 Upon upgrade, both the pre-remove and the pre-install scripts will run.
 As scc has been removed between the runs of these scripts, it will only run once during upgrade.

 Keywords for scripts:

   Pre-installation Script: /path/script
   Unpre-installation Script: /path/script
   Post-installation Script: /path/script
   Pre_rm Script: /path/script
   Configuration Script: /path/script
   Unconfiguration Script: /path/script