Class: Packtory::TgzPackage

Inherits:
Object
  • Object
show all
Defined in:
lib/packtory/tgz_package.rb

Constant Summary collapse

INSTALL_PREFIX =
'%s'

Class Method Summary collapse

Class Method Details

.build_package(opts = { }) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/packtory/tgz_package.rb', line 8

def self.build_package(opts = { })
  packager = Packer.new({ :binstub => { } }.merge(opts))
  fpm_exec = FpmExec.new(packager, INSTALL_PREFIX)

  sfiles_map = packager.prepare_files(INSTALL_PREFIX)
  package_filename = '%s_%s_%s.tar.gz' % [ packager.package_name, packager.version, packager.architecture ]
  pkg_file_path = fpm_exec.build(sfiles_map, package_filename, type: :tgz)

  if File.exist?(pkg_file_path)
    Bundler.ui.info 'Created package: %s (%s bytes)' % [ pkg_file_path, File.size(pkg_file_path) ]
    Bundler.ui.info 'SHA256 checksum: %s' % Digest::SHA256.file(pkg_file_path).hexdigest
  else
    Bundler.ui.error '[ERROR] Package not found: %s' % [ pkg_file_path ]
  end

  [ packager, pkg_file_path ]
end