Class: Litbuild::Package

Inherits:
Blueprint show all
Defined in:
lib/litbuild/package.rb

Constant Summary collapse

BUILD_STAGES =
%w[configure compile test install].freeze
STAGE_DIRECTIVES =
BUILD_STAGES.map { |stg| "#{stg}-commands" }.freeze
STAGE_DEFAULTS =
{ 'configure-commands' => './configure --prefix=/usr',
'compile-commands' => 'make',
'test-commands' => 'make check',
'install-commands' => 'make install' }.freeze
NONE =
'(none)'

Instance Attribute Summary

Attributes inherited from Blueprint

#active_phase, #base_grafs, #logfile_namer

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Blueprint

#[], #deduped_dependency_names, descendants, #directives, #failure_line, #file_name, #for_phase, #full_name, #header_text_with_phase, #logfile, #name, #name_with_phase, #parameter_defaults, #phase_grafs, #phases, #phases?, #prepare, #success_line, #target_name, #value

Constructor Details

#initialize(text:) ⇒ Package

Returns a new instance of Package.



19
20
21
22
23
24
25
26
27
28
# File 'lib/litbuild/package.rb', line 19

def initialize(text:)
  super
  if phases?
    phases.each do |p|
      synthesize_default_commands(@phase_directives[p], @phase_grafs[p])
    end
  else
    synthesize_default_commands(@base_directives, @base_grafs)
  end
end

Class Method Details

.directory_nameObject



15
16
17
# File 'lib/litbuild/package.rb', line 15

def self.directory_name
  'packages'
end

Instance Method Details

#accept(visitor:) ⇒ Object



30
31
32
33
# File 'lib/litbuild/package.rb', line 30

def accept(visitor:)
  super
  visitor.visit_package(package: self)
end

#build_commands(stage) ⇒ Object



65
66
67
68
69
70
# File 'lib/litbuild/package.rb', line 65

def build_commands(stage)
  commands = directives["#{stage}-commands"]
  return [] if commands == [NONE]

  commands
end

#build_dirObject



57
58
59
# File 'lib/litbuild/package.rb', line 57

def build_dir
  value('build-dir')
end

#header_textObject



76
77
78
# File 'lib/litbuild/package.rb', line 76

def header_text
  name
end

#in_treeObject



43
44
45
46
# File 'lib/litbuild/package.rb', line 43

def in_tree
  in_tree_files = self['in-tree-sources'] || []
  in_tree_files.map(&:split)
end

#in_tree_packagesObject



48
49
50
# File 'lib/litbuild/package.rb', line 48

def in_tree_packages
  in_tree.map { |name, version, _path| "#{name}-#{version}.tar" }
end

#name_and_versionObject



61
62
63
# File 'lib/litbuild/package.rb', line 61

def name_and_version
  "#{name}-#{version}"
end

#patch_filesObject



52
53
54
55
# File 'lib/litbuild/package.rb', line 52

def patch_files
  patches = self['patches'] || []
  patches.map { |basename| "#{name_and_version}-#{basename}.patch" }
end

#pkgusr_nameObject



72
73
74
# File 'lib/litbuild/package.rb', line 72

def pkgusr_name
  value('package-user')['name'].first
end

#tar_files_neededObject



39
40
41
# File 'lib/litbuild/package.rb', line 39

def tar_files_needed
  ["#{name_and_version}.tar"] + in_tree_packages
end

#url(url_type) ⇒ Object

Return the URL directive of the specified type, or ‘(unknown)` if there is none.



83
84
85
# File 'lib/litbuild/package.rb', line 83

def url(url_type)
  directives["#{url_type}-url"]&.first || '(unknown)'
end

#versionObject



35
36
37
# File 'lib/litbuild/package.rb', line 35

def version
  self['version'].first
end