Class: FPM::Package::Sh
- Inherits:
-
FPM::Package
- Object
- FPM::Package
- FPM::Package::Sh
- Defined in:
- lib/fpm/package/sh.rb
Overview
Support for self extracting sh files (.sh files)
This class only supports output of packages.
The sh package is a single sh file with a bzipped tar payload concatenated to the end. The script can unpack the tarball to install it and call optional post install scripts.
Instance Attribute Summary
Attributes inherited from FPM::Package
#architecture, #attributes, #attrs, #category, #config_files, #conflicts, #dependencies, #description, #directories, #epoch, #iteration, #license, #maintainer, #name, #provides, #replaces, #scripts, #url, #vendor, #version
Instance Method Summary collapse
- #create_scripts ⇒ Object
-
#fpm_meta_path ⇒ Object
Where we keep metadata and post install scripts and such.
- #install_script ⇒ Object
- #output(output_path) ⇒ Object
-
#payload ⇒ Object
Returns the path to the tar file containing the packed up staging directory.
Methods inherited from FPM::Package
apply_options, #build_path, #cleanup, #cleanup_build, #cleanup_staging, #convert, #converted_from, default_attributes, #edit_file, #files, inherited, #initialize, #input, option, #script, #staging_path, #to_s, #type, type, types
Methods included from Util
#copied_entries, #copy_entry, #default_shell, #expand_pessimistic_constraints, #logger, #mknod_w, #program_exists?, #program_in_path?, #safesystem, #safesystemout, #tar_cmd, #with
Constructor Details
This class inherits a constructor from FPM::Package
Instance Method Details
#create_scripts ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fpm/package/sh.rb', line 26 def create_scripts if script?(:before_install) # the scripts are kept in the payload so what would before install be if we've already # unpacked the payload? raise "sh package does not support before install scripts." end if script?(:after_install) File.write(File.join(, "after_install"), script(:after_install)) end end |
#fpm_meta_path ⇒ Object
Where we keep metadata and post install scripts and such
68 69 70 71 72 73 74 |
# File 'lib/fpm/package/sh.rb', line 68 def @fpm_meta_path ||= begin path = File.join(staging_path, ".fpm") FileUtils.mkdir_p(path) path end end |
#install_script ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/fpm/package/sh.rb', line 38 def install_script path = build_path("installer.sh") File.open(path, "w") do |file| file.write template("sh.erb").result(binding) end path end |
#output(output_path) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/fpm/package/sh.rb', line 18 def output(output_path) create_scripts # Make one file. The installscript can unpack itself. `cat #{install_script} #{payload} > #{output_path}` FileUtils.chmod("+x", output_path) end |
#payload ⇒ Object
Returns the path to the tar file containing the packed up staging directory
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/fpm/package/sh.rb', line 47 def payload payload_tar = build_path("payload.tar") logger.info("Creating payload tar ", :path => payload_tar) args = [ tar_cmd, "-C", staging_path, "-cf", payload_tar, "--owner=0", "--group=0", "--numeric-owner", "." ] unless safesystem(*args) raise "Command failed while creating payload tar: #{args}" end payload_tar end |