lib/omnibus/packagers/bff.rb
def create_bff_file
      # We are making the assumption that sudo exists.
      # Unforunately, the owner of the file in the staging directory is what
      # will be on the target machine, and mkinstallp can't tell you if that
      # is a bad thing (it usually is).
      # The match is so we only pick the lowest level of the project dir.
      # This implies that if we are in /tmp/staging/project/dir/things,
      # we will chown from 'project' on, rather than 'project/dir', which leaves
      # project owned by the build user (which is incorrect)
      # First - let's find out who we are.
      shellout!("sudo chown -Rh 0:0 #{File.join(staging_dir, project.install_dir.match(/^\/?(\w+)/).to_s)}")
      log.info(log_key) { "Creating .bff file" }

      # Since we want the owner to be root, we need to sudo the mkinstallp
      # command, otherwise it will not have access to the previously chowned
      # directory.
      shellout!("sudo /usr/sbin/mkinstallp -d #{staging_dir} -T #{File.join(staging_dir, 'gen.template')}")

      # Print the full contents of the inventory file generated by mkinstallp
      # from within the staging_dir's .info folder (where control files for the
      # packaging process are kept.)
      log.debug(log_key) do
        "With .inventory file of:\n" + File.read("#{File.join( staging_dir, '.info', "#{safe_base_package_name}.inventory" )}")
      end

      # Copy the resulting package up to the package_dir
      FileSyncer.glob(File.join(staging_dir, "tmp/*.bff")).each do |bff|
        copy_file(bff, File.join(Config.package_dir, create_bff_file_name))
      end

    ensure
      # chown back to original user's uid/gid so cleanup works correctly
      original_uid = shellout!("id -u").stdout.chomp
      original_gid = shellout!("id -g").stdout.chomp

      shellout!("sudo chown -Rh #{original_uid}:#{original_gid} #{staging_dir}")
    end
def create_bff_file
      # We are making the assumption that sudo exists.
      # Unforunately, the owner of the file in the staging directory is what
      # will be on the target machine, and mkinstallp can't tell you if that
      # is a bad thing (it usually is).
      # The match is so we only pick the lowest level of the project dir.
      # This implies that if we are in /tmp/staging/project/dir/things,
      # we will chown from 'project' on, rather than 'project/dir', which leaves
      # project owned by the build user (which is incorrect)
      # First - let's find out who we are.
      shellout!("sudo chown -Rh 0:0 #{File.join(staging_dir, project.install_dir.match(/^\/?(\w+)/).to_s)}")
      log.info(log_key) { "Creating .bff file" }

      # Since we want the owner to be root, we need to sudo the mkinstallp
      # command, otherwise it will not have access to the previously chowned
      # directory.
      shellout!("sudo /usr/sbin/mkinstallp -d #{staging_dir} -T #{File.join(staging_dir, 'gen.template')}")

      # Print the full contents of the inventory file generated by mkinstallp
      # from within the staging_dir's .info folder (where control files for the
      # packaging process are kept.)
      log.debug(log_key) do
        "With .inventory file of:\n" + File.read("#{File.join( staging_dir, '.info', "#{safe_base_package_name}.inventory" )}")
      end

      # Copy the resulting package up to the package_dir
      FileSyncer.glob(File.join(staging_dir, "tmp/*.bff")).each do |bff|
        copy_file(bff, File.join(Config.package_dir, create_bff_file_name))
      end

    ensure
      # chown back to original user's uid/gid so cleanup works correctly
      original_uid = shellout!("id -u").stdout.chomp
      original_gid = shellout!("id -g").stdout.chomp

      shellout!("sudo chown -Rh #{original_uid}:#{original_gid} #{staging_dir}")
    end
Create the bff file using +mkinstallp+.

 Warning: This command runs as sudo! AIX requires the use of sudo to run
 the +mkinstallp+ command.

 @return [void]