Class: Omnibus::Packager::Makeself

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

Constant Summary collapse

SCRIPT_MAP =
{
  # 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, #staging_dir

Methods included from Util

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

Methods included from Templating

included, #render_template

Methods included from NullArgumentable

included, #null?

Methods included from Logging

included

Methods included from Digestable

#digest, #digest_directory

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.


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

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

  Dir.chdir(staging_dir) do
    shellout! "\#{makeself} \\\\\n--header \"\#{makeself_header}\" \\\\\n--gzip \\\\\n\"\#{staging_dir}\" \\\\\n\"\#{package_name}\" \\\\\n\"\#{project.description}\" \\\\\n\"./makeselfinst\"\n".gsub(/^ {10}/, '')
  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!


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!


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.


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

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
87
# 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.


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

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