Class: Omnibus::Packager::Makeself

Inherits:
Base
  • Object
show all
Defined in:
lib/omnibus/packagers/makeself.rb

Constant Summary collapse

SCRIPT_MAP =

Returns:

  • (Hash)
{
  # Default Omnibus naming
  postinst: "postinst",
}.freeze

Constants included from Util

Util::SHELLOUT_OPTIONS

Constants included from NullArgumentable

NullArgumentable::NULL

Instance Attribute Summary

Attributes inherited from Base

#project

Instance Method Summary collapse

Methods inherited from Base

build, #exclusions, id, #id, #initialize, #install_dir, #package_path, #resource_path, #resources_path, #run!, setup, #skip_packager, #staging_dir, #staging_dir_path

Methods included from Util

#compiler_safe_path, #copy_file, #create_directory, #create_file, #create_link, included, #path_key, #remove_directory, #remove_file, #retry_block, #shellout, #shellout!, #windows_safe_path

Methods included from Templating

included, #render_template, #render_template_content

Methods included from Sugarable

extended, included, #node

Methods included from NullArgumentable

included, #null?

Methods included from Logging

included

Methods included from Instrumentation

#measure

Methods included from Digestable

#digest, #digest_directory, included

Constructor Details

This class inherits a constructor from Omnibus::Packager::Base

Instance Method Details

#create_makeself_packagevoid

This method returns an undefined value.

Run the actual makeself command, publishing the generated package.



111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/omnibus/packagers/makeself.rb', line 111

def create_makeself_package
  log.info(log_key) { "Creating makeself package" }

  Dir.chdir(staging_dir) do
    shellout! <<-EOH.gsub(/^ {10}/, "")
      #{makeself} \\
        --header "#{makeself_header}" \\
        --gzip \\
        "#{staging_dir}" \\
        "#{package_name}" \\
        "#{project.description}" \\
        "./makeselfinst"
    EOH
  end

  FileSyncer.glob("#{staging_dir}/*.sh").each do |makeself|
    copy_file(makeself, Config.package_dir)
  end
end

#makeselfString

The path to the makeself script - the default should almost always be fine!

Returns:

  • (String)


57
58
59
# File 'lib/omnibus/packagers/makeself.rb', line 57

def makeself
  resource_path("makeself.sh")
end

#makeself_headerString

The path to the makeself-header script - the default should almost always be fine!

Returns:

  • (String)


67
68
69
# File 'lib/omnibus/packagers/makeself.rb', line 67

def makeself_header
  resource_path("makeself-header.sh")
end

#package_nameObject

See Also:



47
48
49
# File 'lib/omnibus/packagers/makeself.rb', line 47

def package_name
  "#{project.package_name}-#{project.build_version}_#{project.build_iteration}.#{safe_architecture}.sh"
end

#safe_architectureString

The architecture for this makeself package.

Returns:

  • (String)


136
137
138
# File 'lib/omnibus/packagers/makeself.rb', line 136

def safe_architecture
  Ohai["kernel"]["machine"]
end

#write_makeselfinstvoid

This method returns an undefined value.

Render a makeselfinst in the staging directory using the supplied ERB template. This file will be used to move the contents of the self- extracting archive into place following extraction.



78
79
80
81
82
83
84
85
86
# File 'lib/omnibus/packagers/makeself.rb', line 78

def write_makeselfinst
  makeselfinst_staging_path = File.join(staging_dir, "makeselfinst")
  render_template(resource_path("makeselfinst.erb"),
    destination: makeselfinst_staging_path,
    variables: {
      install_dir: project.install_dir,
    })
  FileUtils.chmod(0755, makeselfinst_staging_path)
end

#write_scriptsvoid

This method returns an undefined value.

Copy all scripts in Omnibus::Project#package_scripts_path to the staging directory.



94
95
96
97
98
99
100
101
102
103
104
# File 'lib/omnibus/packagers/makeself.rb', line 94

def write_scripts
  SCRIPT_MAP.each do |source, destination|
    source_path = File.join(project.package_scripts_path, source.to_s)

    if File.file?(source_path)
      destination_path = File.join(staging_dir, destination)
      log.debug(log_key) { "Adding script `#{source}' to `#{destination_path}'" }
      copy_file(source_path, destination_path)
    end
  end
end