Class: FPM::Package::Zip

Inherits:
FPM::Package show all
Defined in:
lib/fpm/package/zip.rb

Overview

Use a zip as a package.

This provides no metadata. Both input and output are supported.

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

Methods inherited from FPM::Package

apply_options, #build_path, #cleanup, #cleanup_build, #cleanup_staging, #convert, #converted_from, default_attributes, #edit_file, #files, inherited, #initialize, option, #script, #staging_path, #to_s, #type, type, types

Methods included from Util

#ar_cmd, #ar_cmd_deterministic?, #copied_entries, #copy_entry, #copy_metadata, #default_shell, #erbnew, #execmd, #expand_pessimistic_constraints, #logger, #program_exists?, #program_in_path?, #safesystem, #safesystemout, #tar_cmd, #tar_cmd_supports_sort_names_and_set_mtime?

Constructor Details

This class inherits a constructor from FPM::Package

Instance Method Details

#input(input_path) ⇒ Object

Input a zipfile.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fpm/package/zip.rb', line 13

def input(input_path)
  # use part of the filename as the package name
  self.name = File.extname(input_path)[1..-1]

  realpath = Pathname.new(input_path).realpath.to_s
  ::Dir.chdir(build_path) do
    safesystem("unzip", realpath)
  end

  # use dir to set stuff up properly, mainly so I don't have to reimplement
  # the chdir/prefix stuff special for zip.
  dir = convert(FPM::Package::Dir)
  if attributes[:chdir]
    dir.attributes[:chdir] = File.join(build_path, attributes[:chdir])
  else
    dir.attributes[:chdir] = build_path
  end

  cleanup_staging
  # Tell 'dir' to input "." and chdir/prefix will help it figure out the
  # rest.
  dir.input(".")
  @staging_path = dir.staging_path
  dir.cleanup_build
end

#output(output_path) ⇒ Object

Output a zipfile.



40
41
42
43
44
45
46
# File 'lib/fpm/package/zip.rb', line 40

def output(output_path)
  output_check(output_path)
  realpath = Pathname.new(output_path).realdirpath.to_s
  ::Dir.chdir(staging_path) do
    safesystem("zip", "-9r", realpath, ".")
  end
end