Class: FPM::Package::APK

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

Overview

Support for Alpine packages (.apk files)

This class supports both input and output of packages.

Constant Summary collapse

TAR_CHUNK_SIZE =
512
TAR_TYPEFLAG_OFFSET =
156
TAR_NAME_OFFSET_START =
0
TAR_NAME_OFFSET_END =
99
TAR_LENGTH_OFFSET_START =
124
TAR_LENGTH_OFFSET_END =
135
TAR_CHECKSUM_OFFSET_START =
148
TAR_CHECKSUM_OFFSET_END =
155
TAR_MAGIC_START =
257
TAR_MAGIC_END =
264
TAR_UID_START =
108
TAR_UID_END =
115
TAR_GID_START =
116
TAR_GID_END =
123
TAR_UNAME_START =
265
TAR_UNAME_END =
296
TAR_GNAME_START =
297
TAR_GNAME_END =
328
TAR_MAJOR_START =
329
TAR_MAJOR_END =
336
TAR_MINOR_START =
337
TAR_MINOR_END =
344

Instance Attribute Summary

Attributes inherited from FPM::Package

#attributes, #attrs, #category, #config_files, #conflicts, #dependencies, #description, #directories, #epoch, #iteration, #license, #maintainer, #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, #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

#architectureObject



68
69
70
71
72
73
74
75
# File 'lib/fpm/package/apk.rb', line 68

def architecture

  # "native" in apk should be "noarch"
  if @architecture.nil? or @architecture == "native"
    @architecture = "noarch"
  end
  return @architecture
end

#input(input_path) ⇒ Object



77
78
79
# File 'lib/fpm/package/apk.rb', line 77

def input(input_path)
  logger.error("apk extraction is not yet implemented")
end

#nameObject

Get the name of this package. See also FPM::Package#name

This accessor actually modifies the name if it has some invalid or unwise characters.



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fpm/package/apk.rb', line 45

def name
  if @name =~ /[A-Z]/
    logger.warn("apk packages should not have uppercase characters in their names")
    @name = @name.downcase
  end

  if @name.include?("_")
    logger.warn("apk packages should not include underscores")
    @name = @name.gsub(/[_]/, "-")
  end

  if @name.include?(" ")
    logger.warn("apk packages should not contain spaces")
    @name = @name.gsub(/[ ]/, "-")
  end

  return @name
end

#output(output_path) ⇒ Object



81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# File 'lib/fpm/package/apk.rb', line 81

def output(output_path)

  output_check(output_path)

  control_path = build_path("control")
  controltar_path = build_path("control.tar")
  datatar_path = build_path("data.tar")

  FileUtils.mkdir(control_path)

  # data tar.
  tar_path(staging_path(""), datatar_path)

  # control tar.
  begin
    write_pkginfo(control_path)
    write_control_scripts(control_path)
    tar_path(control_path, controltar_path)
  ensure
    FileUtils.rm_r(control_path)
  end

  # concatenate the two into a real apk.
  begin

    # cut end-of-tar record from control tar
    cut_tar_record(controltar_path)

    # calculate/rewrite sha1 hashes for data tar
    hash_datatar(datatar_path)

    # concatenate the two into the final apk
    concat_zip_tars(controltar_path, datatar_path, output_path)
  end

  logger.warn("apk output does not currently sign packages.")
  logger.warn("It's recommended that your package be installed with '--allow-untrusted'")
end

#prefixObject



64
65
66
# File 'lib/fpm/package/apk.rb', line 64

def prefix
  return (attributes[:prefix] or "/")
end

#to_s(format = nil) ⇒ Object



504
505
506
507
# File 'lib/fpm/package/apk.rb', line 504

def to_s(format=nil)
  return super("NAME_FULLVERSION_ARCH.TYPE") if format.nil?
  return super(format)
end