Class: Vanagon::Project

Inherits:
Object
  • Object
show all
Includes:
Utilities
Defined in:
lib/vanagon/project.rb,
lib/vanagon/project/dsl.rb

Defined Under Namespace

Classes: DSL

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Utilities

#erb_file, #erb_string, #ex, #find_program_on_path, #get_md5sum, #get_sum, #http_request, #local_command, #remote_ssh_command, #retry_with_timeout, #rsync_from, #rsync_to, #ssh_command

Constructor Details

#initialize(name, platform) ⇒ Vanagon::Project

Project constructor. Takes just the name. Also sets the @name and @platform, and initializes @components, @directories and @settings.

Parameters:



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/vanagon/project.rb', line 119

def initialize(name, platform) # rubocop:disable Metrics/AbcSize
  @name = name
  @components = []
  @requires = []
  @directories = []
  @settings = {}
  # Environments are like Hashes but with specific constraints
  # around their keys and values.
  @environment = Vanagon::Environment.new
  @platform = platform
  @release = "1"
  @replaces = []
  @provides = []
  @conflicts = []
  @package_overrides = []
  @source_artifacts = false
  @compiled_archive = false
  @generate_packages = true
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args) ⇒ Object

Magic getter to retrieve settings in the project



140
141
142
143
144
145
# File 'lib/vanagon/project.rb', line 140

def method_missing(method_name, *args)
  if @settings.key?(method_name)
    return @settings[method_name]
  end
  super
end

Instance Attribute Details

#bill_of_materialsObject

Stores the location for the bill-of-materials (a receipt of all files written during) project package assembly



66
67
68
# File 'lib/vanagon/project.rb', line 66

def bill_of_materials
  @bill_of_materials
end

#cleanupObject

Stores whether or not a project should cleanup as it builds because the target builder is space-constrained



56
57
58
# File 'lib/vanagon/project.rb', line 56

def cleanup
  @cleanup
end

#compiled_archiveObject

Should we include platform-specific archives as final outputs probably gzipped tarball for *nix, and probably 7z for win



88
89
90
# File 'lib/vanagon/project.rb', line 88

def compiled_archive
  @compiled_archive
end

#componentsObject

Returns the value of attribute components.



21
22
23
# File 'lib/vanagon/project.rb', line 21

def components
  @components
end

#configdirObject

Returns the value of attribute configdir.



31
32
33
# File 'lib/vanagon/project.rb', line 31

def configdir
  @configdir
end

#conflictsObject

Returns the value of attribute conflicts.



22
23
24
# File 'lib/vanagon/project.rb', line 22

def conflicts
  @conflicts
end

#descriptionObject

Returns the value of attribute description.



20
21
22
# File 'lib/vanagon/project.rb', line 20

def description
  @description
end

#directoriesObject

Store any target directories that should be packed up into the resultant artifact produced by a given Vanagon project.



37
38
39
# File 'lib/vanagon/project.rb', line 37

def directories
  @directories
end

#environmentObject

The overall Environment that a given Vanagon project should pass to each platform



74
75
76
# File 'lib/vanagon/project.rb', line 74

def environment
  @environment
end

#generate_packagesObject

Should we generate platform-specific packages (rpm, deb, dmg, msi, etc)



91
92
93
# File 'lib/vanagon/project.rb', line 91

def generate_packages
  @generate_packages
end

#homepageObject

Returns the value of attribute homepage.



18
19
20
# File 'lib/vanagon/project.rb', line 18

def homepage
  @homepage
end

#identifierObject

This is macOS specific, and defines the Identifier that macOS should use when it builds a .pkg



52
53
54
# File 'lib/vanagon/project.rb', line 52

def identifier
  @identifier
end

#licenseObject

Returns the value of attribute license.



17
18
19
# File 'lib/vanagon/project.rb', line 17

def license
  @license
end

#nameObject

Numerous attributes related to the artifact that a given Vanagon project will produce



14
15
16
# File 'lib/vanagon/project.rb', line 14

def name
  @name
end

#noarchObject

Mark a project as being architecture independent



48
49
50
# File 'lib/vanagon/project.rb', line 48

def noarch
  @noarch
end

#package_overridesObject

Extra vars to be set in the spec file or debian rules. Good for setting extra %define or %global things for RPM, or env variables needed in the debian rules file No extra munging will be performed, so these should be set as you want them to appear in your spec/rules files!



81
82
83
# File 'lib/vanagon/project.rb', line 81

def package_overrides
  @package_overrides
end

#platformObject

Platform’s abstraction is kind of backwards – we should refactor how this works, and make it possible for Vanagon to default to all defined platforms if nothing is specified.



30
31
32
# File 'lib/vanagon/project.rb', line 30

def platform
  @platform
end

#providesObject

Returns the value of attribute provides.



25
26
27
# File 'lib/vanagon/project.rb', line 25

def provides
  @provides
end

#releaseObject

Returns the value of attribute release.



16
17
18
# File 'lib/vanagon/project.rb', line 16

def release
  @release
end

#replacesObject

Returns the value of attribute replaces.



24
25
26
# File 'lib/vanagon/project.rb', line 24

def replaces
  @replaces
end

#repoObject

This is entirely too Puppet centric, and should be refactored out !depreciate !refactor



45
46
47
# File 'lib/vanagon/project.rb', line 45

def repo
  @repo
end

#requiresObject

Returns the value of attribute requires.



23
24
25
# File 'lib/vanagon/project.rb', line 23

def requires
  @requires
end

#retry_countObject

Returns the value of attribute retry_count.



32
33
34
# File 'lib/vanagon/project.rb', line 32

def retry_count
  @retry_count
end

#settingsObject

Stores individual settings related to a given Vanagon project, not necessarily the artifact that the project produces



70
71
72
# File 'lib/vanagon/project.rb', line 70

def settings
  @settings
end

#source_artifactsObject

Should we include source packages?



84
85
86
# File 'lib/vanagon/project.rb', line 84

def source_artifacts
  @source_artifacts
end

#timeoutObject

Returns the value of attribute timeout.



33
34
35
# File 'lib/vanagon/project.rb', line 33

def timeout
  @timeout
end

#userObject

This will define any new users that a project should create



40
41
42
# File 'lib/vanagon/project.rb', line 40

def user
  @user
end

#vendorObject

Returns the value of attribute vendor.



19
20
21
# File 'lib/vanagon/project.rb', line 19

def vendor
  @vendor
end

#versionObject

Returns the value of attribute version.



15
16
17
# File 'lib/vanagon/project.rb', line 15

def version
  @version
end

#version_fileObject

Stores whether or not Vanagon should write the project’s version out into a file inside the package – do we really need this? !depreciate !refactor



62
63
64
# File 'lib/vanagon/project.rb', line 62

def version_file
  @version_file
end

Class Method Details

.load_project(name, configdir, platform, include_components = []) ⇒ Vanagon::Project

Loads a given project from the configdir

Parameters:

  • name (String)

    the name of the project

  • configdir (String)

    the path to the project config file

  • platform (Vanagon::Platform)

    platform to build against

  • include_components (List) (defaults to: [])

    optional list restricting the loaded components

Returns:

Raises:

  • if the instance_eval on Project fails, the exception is reraised



101
102
103
104
105
106
107
108
109
110
111
# File 'lib/vanagon/project.rb', line 101

def self.load_project(name, configdir, platform, include_components = [])
  projfile = File.join(configdir, "#{name}.rb")
  dsl = Vanagon::Project::DSL.new(name, platform, include_components)
  dsl.instance_eval(File.read(projfile), projfile, 1)
  dsl._project
rescue StandardError => e
  warn "Error loading project '#{name}' using '#{projfile}':"
  warn e
  warn e.backtrace.join("\n")
  raise e
end

Instance Method Details

#build_manifest_json(pretty = false) ⇒ Hash

Generate a hash which contains relevant information regarding components of a package, what vanagon built the package, time of build, as well as version of the thing we were building.

Returns:

  • (Hash)

    of information which is useful to know about how a package was built and what went into the package.



615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
# File 'lib/vanagon/project.rb', line 615

def build_manifest_json(pretty = false)
  manifest = {
    "packaging_type" => {
      "vanagon" => VANAGON_VERSION,
    },
    "version" => version,
    "components" => generate_dependencies_info,
    "build_time" => BUILD_TIME,
  }
  if pretty
    JSON.pretty_generate(manifest)
  else
    manifest
  end
end

#check_pkg_state_string(pkg_state) ⇒ Object

Checks that the string pkg_state is valid (install OR upgrade). Return vanagon error if invalid

Parameters:

  • pkg_state (String)

    package state input



313
314
315
316
317
# File 'lib/vanagon/project.rb', line 313

def check_pkg_state_string(pkg_state)
  unless ["install", "upgrade"].include? pkg_state
    raise Vanagon::Error, "#{pkg_state} should be a string containing one of 'install' or 'upgrade'"
  end
end

#dirnamesArray

This originally lived in the Makefile.erb template, but it’s pretty domain-inspecific and we should try to minimize assignment inside an ERB template

Returns:

  • (Array)

    all of the paths produced by #get_directories



491
492
493
# File 'lib/vanagon/project.rb', line 491

def dirnames
  get_directories.map(&:path)
end

#fetch_sources(workdir, retry_count = 1, timeout = 7200) ⇒ Object

Collects all sources and patches into the provided workdir

Parameters:

  • workdir (String)

    directory to stage sources into

  • retry_count (Integer) (defaults to: 1)

    number of times to retry each fetch

  • timeout (Integer) (defaults to: 7200)

    How long to wait (in seconds) for each fetch before aborting



168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/vanagon/project.rb', line 168

def fetch_sources(workdir, retry_count = 1, timeout = 7200)
  @components.each do |component|
    Vanagon::Utilities.retry_with_timeout(retry_count, timeout) do
      component.get_source(workdir)
    end
    # Fetch secondary sources
    Vanagon::Utilities.retry_with_timeout(retry_count, timeout) do
      component.get_sources(workdir)
    end
    Vanagon::Utilities.retry_with_timeout(retry_count, timeout) do
      component.get_patches(workdir)
    end
  end
end

#filter_component(name) ⇒ Array

Returns a filtered out set of components only including those components necessary to build a specific component. This is a recursive function that will call itself until it gets to a component with no build requirements

Parameters:

  • name (String)

    name of component to add. must be present in configdir/components and named $name.rb currently

Returns:

  • (Array)

    array of Vanagon::Component including only those required to build “name”, or [] if there are none



200
201
202
203
204
205
206
207
208
209
210
211
212
213
# File 'lib/vanagon/project.rb', line 200

def filter_component(name)
  filtered_component = get_component(name)
  return [] if filtered_component.nil?
  included_components = [filtered_component]

  unless filtered_component.build_requires.empty?
    filtered_component.build_requires.each do |build_requirement|
      unless get_component(build_requirement).nil?
        included_components += filter_component(build_requirement)
      end
    end
  end
  included_components.uniq
end

#generate_bill_of_materialsArray

Generate a bill-of-materials: a listing of the components and their versions in the current project

Returns:

  • (Array)

    a listing of component names and versions



529
530
531
# File 'lib/vanagon/project.rb', line 529

def generate_bill_of_materials
  components.map { |comp| "#{comp.name} #{comp.version}" }.sort
end

#generate_dependencies_infoHash

Generate a json hash which lists all of the dependant components of the project.

Returns:

  • (Hash)

    where the top level keys are components and their values are hashes with additional information on the component.



603
604
605
606
607
# File 'lib/vanagon/project.rb', line 603

def generate_dependencies_info
  components.each_with_object({}) do |component, hsh|
    hsh.merge!(component.get_dependency_hash)
  end
end

#generate_packageString, Array

Ascertain how to build a package for the current platform

Returns:

  • (String, Array)

    commands to build a package for the current project as defined by the platform



579
580
581
582
583
584
585
586
587
588
# File 'lib/vanagon/project.rb', line 579

def generate_package
  cmds = []
  if generate_packages
    cmds << @platform.generate_package(self)
  end
  if compiled_archive
    cmds << @platform.generate_compiled_archive(self)
  end
  cmds.flatten
end

#generate_packaging_artifacts(workdir) ⇒ Object

Generate any required files to build a package for this project on the current platform into the provided workdir

Parameters:

  • workdir (String)

    workdir to put the packaging files into



594
595
596
# File 'lib/vanagon/project.rb', line 594

def generate_packaging_artifacts(workdir)
  @platform.generate_packaging_artifacts(workdir, @name, binding, self)
end

#get_activate_triggersArray

Collects activate triggers for the project and its components

Returns:

  • (Array)

    of activate triggers



398
399
400
# File 'lib/vanagon/project.rb', line 398

def get_activate_triggers()
  components.flat_map(&:activate_triggers).compact.map(&:activate_name)
end

#get_all_trigger_pkgsArray

Grabs all pkgs that have trigger scripts for ‘install’ and ‘upgrade’

Returns:

  • (Array)

    a list of all the pkgs that have trigger scripts



371
372
373
374
375
376
# File 'lib/vanagon/project.rb', line 371

def get_all_trigger_pkgs()
  install_triggers = get_trigger_scripts("install")
  upgrade_triggers = get_trigger_scripts("upgrade")
  packages = (install_triggers.keys + upgrade_triggers.keys).uniq
  return packages
end

#get_component(name) ⇒ Vanagon::Component

Gets the component with component.name = “name” from the list of project.components

Parameters:

Returns:



220
221
222
223
224
# File 'lib/vanagon/project.rb', line 220

def get_component(name)
  comps = @components.select { |comp| comp.name.to_s == name.to_s }
  raise "ERROR: two or more components with the same name: #{comps.first.name}" if comps.size > 1
  comps.first
end

#get_configfilesArray

Collects any configfiles supplied by components

Returns:

  • (Array)

    array of configfiles installed by components of the project



453
454
455
# File 'lib/vanagon/project.rb', line 453

def get_configfiles
  components.flat_map(&:configfiles).uniq
end

#get_conflictsObject

Collects all of the conflicts for the project and its components



257
258
259
260
261
262
263
264
265
266
267
# File 'lib/vanagon/project.rb', line 257

def get_conflicts
  conflicts = components.flat_map(&:conflicts) + @conflicts
  # Mash the whole thing down into a flat Array
  conflicts.flatten!
  conflicts.each do |conflict|
    # TODO: Make this a more reasonable default before 1.0.0
    # but in the interim, maintain the current behavior
    conflict.version = @platform.version_munger(conflict.version, default: '<') if conflict.version
  end
  conflicts.uniq
end

#get_directoriesArray

Collects any directories declared by the project and components

Returns:

  • (Array)

    the directories in the project and components



464
465
466
467
468
469
# File 'lib/vanagon/project.rb', line 464

def get_directories
  dirs = []
  dirs.push @directories
  dirs.push components.flat_map(&:directories)
  dirs.flatten.uniq
end

#get_filesArray

Collects any additional files supplied by components

Returns:

  • (Array)

    array of files installed by components of the project



186
187
188
189
190
191
# File 'lib/vanagon/project.rb', line 186

def get_files
  files = []
  files.push @version_file if @version_file
  files.push components.flat_map(&:files)
  files.flatten.uniq
end

#get_install_trigger_scripts(pkg) ⇒ Object

Grabs the install trigger scripts for the specified pkg

Parameters:

  • pkg (String)

    the pkg we watch for being installed



355
356
357
358
# File 'lib/vanagon/project.rb', line 355

def get_install_trigger_scripts(pkg)
  scripts = get_trigger_scripts("install")
  return scripts[pkg].join("\n")
end

#get_interest_triggers(pkg_state) ⇒ Array

Collects the interest triggers for the project and its scripts for the

specified packaging state

Parameters:

  • pkg_state (String)

    the package state we want to run the given scripts for. Can be one of ‘install’ or ‘upgrade’

Returns:

  • (Array)

    of OpenStructs of all interest triggers for the pkg_state Use array of openstructs because we need both interest_name and the scripts



385
386
387
388
389
390
391
392
393
# File 'lib/vanagon/project.rb', line 385

def get_interest_triggers(pkg_state)
  interest_triggers = []
  check_pkg_state_string(pkg_state)
  interests = components.flat_map(&:interest_triggers).compact.select { |s| s.pkg_state.include? pkg_state }
  interests.each do |interest|
    interest_triggers.push(interest)
  end
  interest_triggers.flatten.compact
end

#get_postinstall_actions(pkg_state) ⇒ String

Collects the postinstall packaging actions for the project and it’s components

for the specified packaging state

Parameters:

  • pkg_state (String)

    the package state we want to run the given scripts for. Can be one of ‘install’ or ‘upgrade’

Returns:

  • (String)

    string of Bourne shell compatible scriptlets to execute during the postinstall phase of packaging during the state of the system defined by pkg_state (either install or upgrade)



409
410
411
412
413
414
415
416
# File 'lib/vanagon/project.rb', line 409

def get_postinstall_actions(pkg_state)
  scripts = components.flat_map(&:postinstall_actions).compact.select { |s| s.pkg_state.include? pkg_state }.map(&:scripts)
  if scripts.empty?
    return ': no postinstall scripts provided'
  else
    return scripts.join("\n")
  end
end

#get_postremove_actions(pkg_state) ⇒ String

Collects the postremove packaging actions for the project and it’s components for the specified packaging state

Parameters:

  • pkg_state (String)

    the package state we want to run the given scripts for. Can be one or more of ‘removal’ or ‘upgrade’

Returns:

  • (String)

    string of Bourne shell compatible scriptlets to execute during the postremove phase of packaging during the state of the system defined by pkg_state (either removal or upgrade)



441
442
443
444
445
446
447
448
# File 'lib/vanagon/project.rb', line 441

def get_postremove_actions(pkg_state)
  scripts = components.flat_map(&:postremove_actions).compact.select { |s| s.pkg_state.include? pkg_state }.map(&:scripts)
  if scripts.empty?
    return ': no postremove scripts provided'
  else
    return scripts.join("\n")
  end
end

#get_preinstall_actions(pkg_state) ⇒ String

Collects the preinstall packaging actions for the project and its components

for the specified packaging state

Parameters:

  • pkg_state (String)

    the package state we want to run the given scripts for. Can be one of ‘install’ or ‘upgrade’

Returns:

  • (String)

    string of Bourne shell compatible scriptlets to execute during the preinstall phase of packaging during the state of the system defined by pkg_state (either install or upgrade)



326
327
328
329
330
331
332
333
334
# File 'lib/vanagon/project.rb', line 326

def get_preinstall_actions(pkg_state)
  check_pkg_state_string(pkg_state)
  scripts = components.flat_map(&:preinstall_actions).compact.select { |s| s.pkg_state.include? pkg_state }.map(&:scripts)
  if scripts.empty?
    return ': no preinstall scripts provided'
  else
    return scripts.join("\n")
  end
end

#get_preremove_actions(pkg_state) ⇒ String

Collects the preremove packaging actions for the project and it’s components for the specified packaging state

Parameters:

  • pkg_state (String)

    the package state we want to run the given scripts for. Can be one or more of ‘removal’ or ‘upgrade’

Returns:

  • (String)

    string of Bourne shell compatible scriptlets to execute during the preremove phase of packaging during the state of the system defined by pkg_state (either removal or upgrade)



425
426
427
428
429
430
431
432
# File 'lib/vanagon/project.rb', line 425

def get_preremove_actions(pkg_state)
  scripts = components.flat_map(&:preremove_actions).compact.select { |s| s.pkg_state.include? pkg_state }.map(&:scripts)
  if scripts.empty?
    return ': no preremove scripts provided'
  else
    return scripts.join("\n")
  end
end

#get_providesArray

Collects all of the provides for the project and its components

Returns:

  • (Array)

    array of package level provides for the project



292
293
294
295
296
297
298
299
300
301
302
303
# File 'lib/vanagon/project.rb', line 292

def get_provides
  provides = []
  provides.push @provides.flatten
  provides.push components.flat_map(&:provides)
  provides.flatten!
  provides.each do |provide|
    # TODO: Make this a more reasonable default before 1.0.0
    # but in the interim, maintain the current behavior
    provide.version = @platform.version_munger(provide.version, default: '>=') if provide.version
  end
  provides.uniq
end

#get_replacesArray

Collects all of the replacements for the project and its components

Returns:

  • (Array)

    array of package level replacements for the project



239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/vanagon/project.rb', line 239

def get_replaces
  replaces = []
  replaces.push @replaces.flatten
  replaces.push components.flat_map(&:replaces)
  replaces.flatten!
  replaces.each do |replace|
    # TODO: Make this a more reasonable default before 1.0.0
    # but in the interim, maintain the current behavior
    replace.version = @platform.version_munger(replace.version, default: '<') if replace.version
  end
  replaces.uniq
end

#get_requiresArray

Collects all of the requires for both the project and its components

Returns:

  • (Array)

    array of runtime requirements for the project



229
230
231
232
233
234
# File 'lib/vanagon/project.rb', line 229

def get_requires
  req = []
  req << components.flat_map(&:requires)
  req << @requires
  req.flatten.uniq
end

#get_root_directoriesArray

Gets the highest level directories declared by the project

Returns:

  • (Array)

    the highest level directories that have been declared by the project



474
475
476
477
478
479
480
481
482
483
484
485
# File 'lib/vanagon/project.rb', line 474

def get_root_directories # rubocop:disable Metrics/AbcSize
  dirs = get_directories.map { |dir| dir.path.split('/') }
  dirs.sort! { |dir1, dir2| dir1.length <=> dir2.length }
  ret_dirs = []

  dirs.each do |dir|
    unless ret_dirs.include?(dir.first(dir.length - 1).join('/'))
      ret_dirs << dir.join('/')
    end
  end
  ret_dirs
end

#get_service(name) ⇒ @component.service obj

Grabs a specific service based on which name is passed in note that if the name is wrong or there was no will return nil

Parameters:

  • name (string)

    of service to grab

Returns:

  • (@component.service obj)

    specific service



280
281
282
283
284
285
286
287
# File 'lib/vanagon/project.rb', line 280

def get_service(name)
  components.each do |component|
    if component.name == name
      return component.service
    end
  end
  return nil
end

#get_servicesArray

Get any services registered by components in the project

Returns:

  • (Array)

    the services provided by components in the project



498
499
500
# File 'lib/vanagon/project.rb', line 498

def get_services
  components.flat_map(&:service).compact
end

#get_tarball_filesArray

Generate a list of all files and directories to be included in a tarball for the project

Returns:

  • (Array)

    all the files and directories that should be included in the tarball



514
515
516
517
518
519
520
521
522
523
# File 'lib/vanagon/project.rb', line 514

def get_tarball_files
  files = ['file-list', 'bill-of-materials']
  files.push get_files.map(&:path)
  files.push get_configfiles.map(&:path)
  if @platform.is_windows?
    files.flatten.map { |f| "$(shell cygpath --mixed --long-name '#{f}')" }
  else
    files.flatten
  end
end

#get_trigger_scripts(pkg_state) ⇒ Hash

Collects the install trigger scripts for the project for the specified packing state

Parameters:

  • pkg_state (String)

    the package state we want to run the given scripts for. Can be one of the ‘install’ or ‘upgrade’

Returns:

  • (Hash)

    of scriptlets to execute during the pkg_state (install or upgrade) there can be more than one script for each package (key)



342
343
344
345
346
347
348
349
350
# File 'lib/vanagon/project.rb', line 342

def get_trigger_scripts(pkg_state)
  triggers = Hash.new { |hsh, key| hsh[key] = [] }
  check_pkg_state_string(pkg_state)
  pkgs = components.flat_map(&:install_triggers).compact.select { |s| s.pkg_state.include? pkg_state }
  pkgs.each do |package|
    triggers[package.pkg].push package.scripts
  end
  triggers
end

#get_upgrade_trigger_scripts(pkg) ⇒ Object

Grabs the upgrade trigger scripts for the specified pkg

Parameters:

  • pkg (String)

    the pkg we watch for being upgraded



363
364
365
366
# File 'lib/vanagon/project.rb', line 363

def get_upgrade_trigger_scripts(pkg)
  scripts = get_trigger_scripts("upgrade")
  return scripts[pkg].join("\n")
end

#has_configfiles?Boolean

Returns:

  • (Boolean)


457
458
459
# File 'lib/vanagon/project.rb', line 457

def has_configfiles?
  !get_configfiles.empty?
end

#has_conflicts?Boolean

Returns:

  • (Boolean)


269
270
271
# File 'lib/vanagon/project.rb', line 269

def has_conflicts?
  !get_conflicts.empty?
end

#has_provides?Boolean

Returns:

  • (Boolean)


305
306
307
# File 'lib/vanagon/project.rb', line 305

def has_provides?
  !get_provides.empty?
end

#has_replaces?Boolean

Returns:

  • (Boolean)


252
253
254
# File 'lib/vanagon/project.rb', line 252

def has_replaces?
  !get_replaces.empty?
end

#has_services?True, False

Simple utility for determining if the components in the project declare any services

Returns:

  • (True, False)

    Whether or not there are services declared for this project or not



506
507
508
# File 'lib/vanagon/project.rb', line 506

def has_services?
  !get_services.empty?
end

#list_component_dependencies(component) ⇒ Array

Return a list of the build_dependencies that are satisfied by an internal component

Parameters:

  • component (Vanagon::Component)

    component to check for already satisfied build dependencies

Returns:

  • (Array)

    a list of the build dependencies for the given component that are satisfied by other components in the project



565
566
567
# File 'lib/vanagon/project.rb', line 565

def list_component_dependencies(component)
  component.build_requires.select { |dep| components.map(&:name).include?(dep) }
end

#load_upstream_settings(upstream_project_name, upstream_git_url, upstream_git_branch) ⇒ Object

Load the settings hash from an upstream vanagon project. This will clone a git repo at a specified branch and load the specified vanagon project (with no components). The settings hash of the upstream project will be merged with the existing settings hash, overriding any duplicates at the time of calling with the value from upstream. To override settings from upstream, you need to set the ‘proj.setting` after `proj.inherit_settings`.

As the settings are not lazy-loaded, if you need to override a setting from upstream that is used in later settings, you’ll need to override all of the settings based on the one you’re overriding.

Parameters:

  • upstream_project_name (String)

    The name of the vanagon project to load

  • upstream_git_url (URI)

    The URL to clone this vanagon project from

  • upstream_git_branch (String)

    The branch of the vanagon project to clone from



657
658
659
660
661
662
663
664
665
666
667
668
# File 'lib/vanagon/project.rb', line 657

def load_upstream_settings(upstream_project_name, upstream_git_url, upstream_git_branch)
  Dir.mktmpdir do |working_directory|
    upstream_source = Vanagon::Component::Source::Git.new(upstream_git_url, workdir: working_directory, ref: upstream_git_branch)
    upstream_source.fetch
    # We don't want to load any of the upstream components, so we're going to
    # pass an array with an empty string as the component list for load_project
    no_components = ['']
    upstream_project = Vanagon::Project.load_project(upstream_project_name, File.join(working_directory, upstream_source.dirname, "configs", "projects"), platform, no_components)
    @settings.merge!(upstream_project.settings)
    upstream_project.cleanup
  end
end

#make_bill_of_materials(workdir) ⇒ String

Generates a bill-of-materials and writes the contents to the workdir for use in building the project

Parameters:

  • workdir (String)

    full path to the workdir to send the bill-of-materials

Returns:

  • (String)

    full path to the generated bill-of-materials



557
558
559
# File 'lib/vanagon/project.rb', line 557

def make_bill_of_materials(workdir)
  File.open(File.join(workdir, 'bill-of-materials'), 'w') { |f| f.puts(generate_bill_of_materials.join("\n")) }
end

#make_makefile(workdir) ⇒ String

Evaluates the makefile template and writes the contents to the workdir for use in building the project

Parameters:

  • workdir (String)

    full path to the workdir to send the evaluated template

Returns:

  • (String)

    full path to the generated Makefile



548
549
550
# File 'lib/vanagon/project.rb', line 548

def make_makefile(workdir)
  erb_file(File.join(VANAGON_ROOT, "resources/Makefile.erb"), File.join(workdir, "Makefile"))
end

#merged_environmentEnvironment

Merge the platform’s Environment into the project’s Environment and return the result. This will produce the top-level Environment in the Makefile, that all components (and their Make targets) will inherit from.

Returns:

  • (Environment)

    a new Environment, constructed from merging @platform’s Environment with the project’s environment.



158
159
160
# File 'lib/vanagon/project.rb', line 158

def merged_environment
  environment.merge(@platform.environment)
end

#pack_tarball_commandString

Method to generate the command to create a tarball of the project

Returns:

  • (String)

    cross platform command to generate a tarball of the project



536
537
538
539
540
541
# File 'lib/vanagon/project.rb', line 536

def pack_tarball_command
  tar_root = "#{@name}-#{@version}"
  ["mkdir -p '#{tar_root}'",
   %('#{@platform.tar}' -cf - -T "#{get_tarball_files.join('" "')}" | ( cd '#{tar_root}/'; '#{@platform.tar}' xfp -)),
   %('#{@platform.tar}' -cf - #{tar_root}/ | gzip -9c > #{tar_root}.tar.gz)].join("\n\t")
end

#package_nameString

Get the package name for the project on the current platform

Returns:

  • (String)

    package name for the current project as defined by the platform



572
573
574
# File 'lib/vanagon/project.rb', line 572

def package_name
  @platform.package_name(self)
end

#respond_to_missing?(method_name, include_private = false) ⇒ Boolean

Returns:

  • (Boolean)


147
148
149
# File 'lib/vanagon/project.rb', line 147

def respond_to_missing?(method_name, include_private = false)
  @settings.key?(method_name) || super
end

#save_manifest_jsonHash

Writes a json file at ‘ext/build_metadata.json` containing information about what went into a built artifact

Returns:

  • (Hash)

    of build information



635
636
637
638
639
640
# File 'lib/vanagon/project.rb', line 635

def save_manifest_json
  manifest = build_manifest_json(true)
  File.open(File.join('ext', 'build_metadata.json'), 'w') do |f|
    f.write(manifest)
  end
end