vanagon 0.18.1 → 0.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +2 -2
  3. data/bin/build +3 -1
  4. data/bin/build_host_info +3 -1
  5. data/bin/build_requirements +3 -1
  6. data/bin/inspect +3 -1
  7. data/bin/render +3 -1
  8. data/bin/repo +3 -1
  9. data/bin/ship +3 -1
  10. data/bin/sign +3 -1
  11. data/lib/vanagon/cli.rb +4 -2
  12. data/lib/vanagon/cli/build.rb +2 -1
  13. data/lib/vanagon/cli/build_host_info.rb +3 -2
  14. data/lib/vanagon/cli/build_requirements.rb +4 -4
  15. data/lib/vanagon/cli/completion.rb +4 -3
  16. data/lib/vanagon/cli/inspect.rb +3 -2
  17. data/lib/vanagon/cli/list.rb +16 -6
  18. data/lib/vanagon/cli/render.rb +2 -1
  19. data/lib/vanagon/cli/ship.rb +4 -19
  20. data/lib/vanagon/cli/sign.rb +3 -2
  21. data/lib/vanagon/component.rb +13 -10
  22. data/lib/vanagon/component/dsl.rb +27 -20
  23. data/lib/vanagon/component/source.rb +2 -1
  24. data/lib/vanagon/component/source/git.rb +35 -10
  25. data/lib/vanagon/component/source/http.rb +3 -2
  26. data/lib/vanagon/component/source/local.rb +2 -1
  27. data/lib/vanagon/component/source/rewrite.rb +3 -2
  28. data/lib/vanagon/driver.rb +20 -23
  29. data/lib/vanagon/engine/always_be_scheduling.rb +12 -11
  30. data/lib/vanagon/engine/docker.rb +2 -1
  31. data/lib/vanagon/engine/ec2.rb +5 -4
  32. data/lib/vanagon/engine/hardware.rb +4 -3
  33. data/lib/vanagon/engine/pooler.rb +6 -5
  34. data/lib/vanagon/environment.rb +3 -2
  35. data/lib/vanagon/logger.rb +31 -0
  36. data/lib/vanagon/platform.rb +38 -5
  37. data/lib/vanagon/platform/defaults/debian-10-amd64.rb +11 -0
  38. data/lib/vanagon/platform/defaults/debian-8-amd64.rb +12 -0
  39. data/lib/vanagon/platform/defaults/debian-8-i386.rb +12 -0
  40. data/lib/vanagon/platform/defaults/debian-9-amd64.rb +12 -0
  41. data/lib/vanagon/platform/defaults/debian-9-i386.rb +12 -0
  42. data/lib/vanagon/platform/defaults/el-6-i386.rb +11 -0
  43. data/lib/vanagon/platform/defaults/el-6-x86_64.rb +11 -0
  44. data/lib/vanagon/platform/defaults/el-7-aarch64.rb +13 -0
  45. data/lib/vanagon/platform/defaults/el-7-x86_64.rb +11 -0
  46. data/lib/vanagon/platform/defaults/el-8-aarch64.rb +10 -0
  47. data/lib/vanagon/platform/defaults/el-8-x86_64.rb +10 -0
  48. data/lib/vanagon/platform/defaults/fedora-30-x86_64.rb +11 -0
  49. data/lib/vanagon/platform/defaults/fedora-31-x86_64.rb +11 -0
  50. data/lib/vanagon/platform/defaults/fedora-32-x86_64.rb +11 -0
  51. data/lib/vanagon/platform/defaults/osx-10.14-x86_64.rb +22 -0
  52. data/lib/vanagon/platform/defaults/osx-10.15-x86_64.rb +21 -0
  53. data/lib/vanagon/platform/defaults/redhatfips-7-x86_64.rb +11 -0
  54. data/lib/vanagon/platform/defaults/sles-12-x86_64.rb +11 -0
  55. data/lib/vanagon/platform/defaults/sles-15-x86_64.rb +10 -0
  56. data/lib/vanagon/platform/defaults/solaris-11-i386.rb +9 -0
  57. data/lib/vanagon/platform/defaults/solaris-11-sparc.rb +10 -0
  58. data/lib/vanagon/platform/defaults/ubuntu-16.04-amd64.rb +12 -0
  59. data/lib/vanagon/platform/defaults/ubuntu-16.04-i386.rb +12 -0
  60. data/lib/vanagon/platform/defaults/ubuntu-18.04-amd64.rb +12 -0
  61. data/lib/vanagon/platform/defaults/ubuntu-20.04-aarch64.rb +11 -0
  62. data/lib/vanagon/platform/defaults/ubuntu-20.04-amd64.rb +11 -0
  63. data/lib/vanagon/platform/dsl.rb +30 -6
  64. data/lib/vanagon/platform/windows.rb +3 -1
  65. data/lib/vanagon/project.rb +25 -15
  66. data/lib/vanagon/project/dsl.rb +6 -5
  67. data/lib/vanagon/utilities.rb +5 -4
  68. data/resources/deb/control.erb +1 -1
  69. data/resources/deb/postinst.erb +24 -13
  70. data/resources/deb/postrm.erb +9 -6
  71. data/resources/deb/prerm.erb +18 -8
  72. data/resources/osx/postinstall.erb +6 -2
  73. data/resources/rpm/project.spec.erb +12 -12
  74. data/resources/solaris/10/depend.erb +2 -2
  75. data/resources/solaris/10/postinstall.erb +11 -3
  76. data/resources/solaris/11/p5m.erb +2 -2
  77. data/spec/lib/vanagon/cli_spec.rb +57 -9
  78. data/spec/lib/vanagon/component/dsl_spec.rb +54 -10
  79. data/spec/lib/vanagon/component/source/git_spec.rb +4 -4
  80. data/spec/lib/vanagon/component_spec.rb +15 -2
  81. data/spec/lib/vanagon/engine/always_be_scheduling_spec.rb +4 -4
  82. data/spec/lib/vanagon/platform_spec.rb +80 -0
  83. data/spec/lib/vanagon/utilities_spec.rb +4 -1
  84. metadata +58 -31
@@ -0,0 +1,22 @@
1
+ platform "osx-10.14-x86_64" do |plat|
2
+ plat.servicetype "launchd"
3
+ plat.servicedir "/Library/LaunchDaemons"
4
+ plat.codename "mojave"
5
+
6
+ plat.provision_with "export HOMEBREW_NO_EMOJI=true"
7
+ plat.provision_with "export HOMEBREW_VERBOSE=true"
8
+ plat.provision_with "sudo dscl . -create /Users/test"
9
+ plat.provision_with "sudo dscl . -create /Users/test UserShell /bin/bash"
10
+ plat.provision_with "sudo dscl . -create /Users/test UniqueID 1001"
11
+ plat.provision_with "sudo dscl . -create /Users/test PrimaryGroupID 1000"
12
+ plat.provision_with "sudo dscl . -create /Users/test NFSHomeDirectory /Users/test"
13
+ plat.provision_with "sudo dscl . -passwd /Users/test password"
14
+ plat.provision_with "sudo dscl . -merge /Groups/admin GroupMembership test"
15
+ plat.provision_with "echo 'test ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/username"
16
+ plat.provision_with "mkdir -p /etc/homebrew"
17
+ plat.provision_with "cd /etc/homebrew"
18
+ plat.provision_with %Q(su test -c 'echo | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
19
+ plat.provision_with "sudo chown -R test:admin /Users/test/"
20
+ plat.vmpooler_template "osx-1014-x86_64"
21
+ plat.output_dir File.join("apple", "10.14", "puppet6", "x86_64")
22
+ end
@@ -0,0 +1,21 @@
1
+ platform "osx-10.15-x86_64" do |plat|
2
+ plat.servicetype "launchd"
3
+ plat.servicedir "/Library/LaunchDaemons"
4
+ plat.codename "catalina"
5
+
6
+ plat.provision_with "export HOMEBREW_NO_EMOJI=true"
7
+ plat.provision_with "export HOMEBREW_VERBOSE=true"
8
+ plat.provision_with "sudo dscl . -create /Users/test"
9
+ plat.provision_with "sudo dscl . -create /Users/test UserShell /bin/bash"
10
+ plat.provision_with "sudo dscl . -create /Users/test UniqueID 1001"
11
+ plat.provision_with "sudo dscl . -create /Users/test PrimaryGroupID 1000"
12
+ plat.provision_with "sudo dscl . -create /Users/test NFSHomeDirectory /Users/test"
13
+ plat.provision_with "sudo dscl . -passwd /Users/test password"
14
+ plat.provision_with "sudo dscl . -merge /Groups/admin GroupMembership test"
15
+ plat.provision_with "echo 'test ALL=(ALL:ALL) NOPASSWD: ALL' > /etc/sudoers.d/username"
16
+ plat.provision_with "mkdir -p /etc/homebrew"
17
+ plat.provision_with "cd /etc/homebrew"
18
+ plat.provision_with %Q(su test -c 'echo | /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"')
19
+ plat.provision_with "sudo chown -R test:admin /Users/test/"
20
+ plat.vmpooler_template "osx-1015-x86_64"
21
+ end
@@ -0,0 +1,11 @@
1
+ platform "redhatfips-7-x86_64" do |plat|
2
+ plat.servicedir "/usr/lib/systemd/system"
3
+ plat.defaultdir "/etc/sysconfig"
4
+ plat.servicetype "systemd"
5
+
6
+ plat.add_build_repository "http://pl-build-tools.delivery.puppetlabs.net/yum/pl-build-tools-release-el-7.noarch.rpm"
7
+ packages = %w(autoconf automake createrepo rsync gcc make rpmdevtools rpm-libs yum-utils rpm-sign)
8
+ plat.provision_with "yum install --assumeyes #{packages.join(' ')}"
9
+ plat.install_build_dependencies_with "yum install --assumeyes"
10
+ plat.vmpooler_template "redhat-fips-7-x86_64"
11
+ end
@@ -0,0 +1,11 @@
1
+ platform "sles-12-x86_64" do |plat|
2
+ plat.servicedir "/usr/lib/systemd/system"
3
+ plat.defaultdir "/etc/sysconfig"
4
+ plat.servicetype "systemd"
5
+
6
+ plat.add_build_repository "http://pl-build-tools.delivery.puppetlabs.net/yum/pl-build-tools-release-#{plat.get_os_name}-#{plat.get_os_version}.noarch.rpm"
7
+ packages = %w(aaa_base autoconf automake rsync gcc make rpm-build)
8
+ plat.provision_with "zypper -n --no-gpg-checks install -y #{packages.join(' ')}"
9
+ plat.install_build_dependencies_with "zypper -n --no-gpg-checks install -y"
10
+ plat.vmpooler_template "sles-12-x86_64"
11
+ end
@@ -0,0 +1,10 @@
1
+ platform "sles-15-x86_64" do |plat|
2
+ plat.servicedir "/usr/lib/systemd/system"
3
+ plat.defaultdir "/etc/sysconfig"
4
+ plat.servicetype "systemd"
5
+
6
+ packages = %w(aaa_base autoconf automake rsync gcc gcc-c++ make rpm-build gettext-tools cmake)
7
+ plat.provision_with "zypper -n --no-gpg-checks install -y #{packages.join(' ')}"
8
+ plat.install_build_dependencies_with "zypper -n --no-gpg-checks install -y"
9
+ plat.vmpooler_template "sles-15-x86_64"
10
+ end
@@ -0,0 +1,9 @@
1
+ platform "solaris-11-i386" do |plat|
2
+ plat.servicedir "/lib/svc/manifest"
3
+ plat.defaultdir "/lib/svc/method"
4
+ plat.servicetype "smf"
5
+
6
+ plat.vmpooler_template "solaris-11-x86_64"
7
+ plat.add_build_repository "http://solaris-11-reposync.delivery.puppetlabs.net:81", "puppetlabs.com"
8
+ plat.install_build_dependencies_with "pkg install ", " || [[ $? -eq 4 ]]"
9
+ end
@@ -0,0 +1,10 @@
1
+ platform "solaris-11-sparc" do |plat|
2
+ plat.servicedir "/lib/svc/manifest"
3
+ plat.defaultdir "/lib/svc/method"
4
+ plat.servicetype "smf"
5
+
6
+ plat.cross_compiled true
7
+ plat.vmpooler_template "solaris-11-x86_64"
8
+ plat.add_build_repository "http://solaris-11-reposync.delivery.puppetlabs.net:81", "puppetlabs.com"
9
+ plat.install_build_dependencies_with "pkg install ", " || [[ $? -eq 4 ]]"
10
+ end
@@ -0,0 +1,12 @@
1
+ platform "ubuntu-16.04-amd64" do |plat|
2
+ plat.servicedir "/lib/systemd/system"
3
+ plat.defaultdir "/etc/default"
4
+ plat.servicetype "systemd"
5
+ plat.codename "xenial"
6
+
7
+ plat.add_build_repository "http://pl-build-tools.delivery.puppetlabs.net/debian/pl-build-tools-release-#{plat.get_codename}.deb"
8
+ packages = %w(build-essential devscripts make quilt pkg-config debhelper rsync fakeroot)
9
+ plat.provision_with "export DEBIAN_FRONTEND=noninteractive; apt-get update -qq; apt-get install -qy --no-install-recommends #{packages.join(' ')}"
10
+ plat.install_build_dependencies_with "DEBIAN_FRONTEND=noninteractive; apt-get install -qy --no-install-recommends "
11
+ plat.vmpooler_template "ubuntu-1604-x86_64"
12
+ end
@@ -0,0 +1,12 @@
1
+ platform "ubuntu-16.04-i386" do |plat|
2
+ plat.servicedir "/lib/systemd/system"
3
+ plat.defaultdir "/etc/default"
4
+ plat.servicetype "systemd"
5
+ plat.codename "xenial"
6
+
7
+ plat.add_build_repository "http://pl-build-tools.delivery.puppetlabs.net/debian/pl-build-tools-release-#{plat.get_codename}.deb"
8
+ packages = %w(build-essential devscripts make quilt pkg-config debhelper rsync fakeroot)
9
+ plat.provision_with "export DEBIAN_FRONTEND=noninteractive; apt-get update -qq; apt-get install -qy --no-install-recommends #{packages.join(' ')}"
10
+ plat.install_build_dependencies_with "DEBIAN_FRONTEND=noninteractive; apt-get install -qy --no-install-recommends "
11
+ plat.vmpooler_template "ubuntu-1604-i386"
12
+ end
@@ -0,0 +1,12 @@
1
+ platform "ubuntu-18.04-amd64" do |plat|
2
+ plat.servicedir "/lib/systemd/system"
3
+ plat.defaultdir "/etc/default"
4
+ plat.servicetype "systemd"
5
+ plat.codename "bionic"
6
+
7
+ plat.add_build_repository "http://pl-build-tools.delivery.puppetlabs.net/debian/pl-build-tools-release-#{plat.get_codename}.deb"
8
+ packages = %w(build-essential devscripts make quilt pkg-config debhelper rsync fakeroot)
9
+ plat.provision_with "export DEBIAN_FRONTEND=noninteractive; apt-get update -qq; apt-get install -qy --no-install-recommends #{packages.join(' ')}"
10
+ plat.install_build_dependencies_with "export DEBIAN_FRONTEND=noninteractive; apt-get install -qy --no-install-recommends "
11
+ plat.vmpooler_template "ubuntu-1804-x86_64"
12
+ end
@@ -0,0 +1,11 @@
1
+ platform "ubuntu-20.04-aarch64" do |plat|
2
+ plat.servicedir "/lib/systemd/system"
3
+ plat.defaultdir "/etc/default"
4
+ plat.servicetype "systemd"
5
+ plat.codename "focal"
6
+
7
+ packages = %w(build-essential devscripts make quilt pkg-config debhelper rsync fakeroot cmake)
8
+ plat.provision_with "export DEBIAN_FRONTEND=noninteractive; apt-get update -qq; apt-get install -qy --no-install-recommends #{packages.join(' ')}"
9
+ plat.install_build_dependencies_with "DEBIAN_FRONTEND=noninteractive; apt-get install -qy --no-install-recommends "
10
+ plat.vmpooler_template "ubuntu-2004-arm64"
11
+ end
@@ -0,0 +1,11 @@
1
+ platform "ubuntu-20.04-amd64" do |plat|
2
+ plat.servicedir "/lib/systemd/system"
3
+ plat.defaultdir "/etc/default"
4
+ plat.servicetype "systemd"
5
+ plat.codename "focal"
6
+
7
+ packages = %w(build-essential devscripts make quilt pkg-config debhelper rsync fakeroot cmake)
8
+ plat.provision_with "export DEBIAN_FRONTEND=noninteractive; apt-get update -qq; apt-get install -qy --no-install-recommends #{packages.join(' ')}"
9
+ plat.install_build_dependencies_with "DEBIAN_FRONTEND=noninteractive; apt-get install -qy --no-install-recommends "
10
+ plat.vmpooler_template "ubuntu-2004-x86_64"
11
+ end
@@ -8,7 +8,9 @@ require 'vanagon/platform/osx'
8
8
  require 'vanagon/platform/solaris_10'
9
9
  require 'vanagon/platform/solaris_11'
10
10
  require 'vanagon/platform/windows'
11
+ require 'vanagon/logger'
11
12
  require 'securerandom'
13
+ require 'ostruct'
12
14
  require 'uri'
13
15
 
14
16
  class Vanagon
@@ -83,6 +85,13 @@ class Vanagon
83
85
  method_name.to_s.start_with?('get_') || super
84
86
  end
85
87
 
88
+ def inherit_from_default(name = @name)
89
+ default_file = File.join(__dir__, 'defaults', "#{name}.rb")
90
+ default_object = Vanagon::Platform::DSL.new(name)
91
+
92
+ @platform = default_object.instance_eval(File.read(default_file), default_file, 1)
93
+ end
94
+
86
95
  # Adds an arbitrary environment variable to a Platform, which will be
87
96
  # merged with any environment variables defined by the Project into the
88
97
  # rendered Makefile
@@ -218,6 +227,11 @@ class Vanagon
218
227
  # @param dir [String] Directory where service files live on the platform
219
228
  def servicedir(dir)
220
229
  @platform.servicedir = dir
230
+
231
+ # Add to the servicetypes array if we haven't already
232
+ if @platform.servicetype && @platform.servicedir && @platform.servicetypes.select { |s| s.servicetype == @platform.servicetype }.empty?
233
+ @platform.servicetypes << OpenStruct.new(:servicetype => @platform.servicetype, :servicedir => @platform.servicedir)
234
+ end
221
235
  end
222
236
 
223
237
  # Set the directory where default or sysconfig files live for the platform
@@ -230,8 +244,18 @@ class Vanagon
230
244
  # Set the servicetype for the platform so that services can be installed correctly.
231
245
  #
232
246
  # @param type [String] service type for the platform ('sysv' for example)
233
- def servicetype(type)
234
- @platform.servicetype = type
247
+ # @param servicedir [String] service dir for this platform and service type ('/etc/init.d' for example). Optional.
248
+ def servicetype(type, servicedir: nil) # rubocop:disable Metrics/AbcSize
249
+ if servicedir
250
+ @platform.servicetypes << OpenStruct.new(:servicetype => type, :servicedir => servicedir)
251
+ else
252
+ @platform.servicetype = type
253
+ end
254
+
255
+ # Add to the servicetypes array if we haven't already
256
+ if @platform.servicetype && @platform.servicedir && @platform.servicetypes.select { |s| s.servicetype == @platform.servicetype }.empty?
257
+ @platform.servicetypes << OpenStruct.new(:servicetype => @platform.servicetype, :servicedir => @platform.servicedir)
258
+ end
235
259
  end
236
260
 
237
261
  # Set the list of possible host to perform a build on (when not using
@@ -259,7 +283,7 @@ class Vanagon
259
283
  # @param name [String] name that the pooler uses for this platform
260
284
  # @deprecated Please use vmpooler_template instead, this will be removed in a future vanagon release.
261
285
  def vcloud_name(cloud_name)
262
- warn "vcloud_name is a deprecated platform DSL method, and will be removed in a future vanagon release. Please use vmpooler_template instead."
286
+ VanagonLogger.info "vcloud_name is a deprecated platform DSL method, and will be removed in a future vanagon release. Please use vmpooler_template instead."
263
287
  self.vmpooler_template(cloud_name)
264
288
  end
265
289
 
@@ -394,7 +418,7 @@ class Vanagon
394
418
  # @param gpg_key [String] optional gpg key to be fetched via curl and installed
395
419
  # @deprecated Please use the add_build_repository DSL method instead. apt_repo will be removed in a future vanagon release.
396
420
  def apt_repo(definition, gpg_key = nil)
397
- warn "Please use the add_build_repository DSL method instead. apt_repo will be removed in a future vanagon release."
421
+ VanagonLogger.info "Please use the add_build_repository DSL method instead. apt_repo will be removed in a future vanagon release."
398
422
  self.add_build_repository(definition, gpg_key)
399
423
  end
400
424
 
@@ -403,7 +427,7 @@ class Vanagon
403
427
  # @param definition [String] the repo setup URI or RPM file
404
428
  # @deprecated Please use the add_build_repository DSL method instead. yum_repo will be removed in a future vanagon release.
405
429
  def yum_repo(definition)
406
- warn "Please use the add_build_repository DSL method instead. yum_repo will be removed in a future vanagon release."
430
+ VanagonLogger.info "Please use the add_build_repository DSL method instead. yum_repo will be removed in a future vanagon release."
407
431
  self.add_build_repository(definition)
408
432
  end
409
433
 
@@ -412,7 +436,7 @@ class Vanagon
412
436
  # @param definition [String] the repo setup URI or RPM file
413
437
  # @deprecated Please use the add_build_repository DSL method instead. zypper_repo will be removed in a future vanagon release.
414
438
  def zypper_repo(definition)
415
- warn "Please use the add_build_repository DSL method instead. zypper_repo will be removed in a future vanagon release."
439
+ VanagonLogger.info "Please use the add_build_repository DSL method instead. zypper_repo will be removed in a future vanagon release."
416
440
  self.add_build_repository(definition)
417
441
  end
418
442
 
@@ -1,3 +1,5 @@
1
+ require 'vanagon/logger'
2
+
1
3
  class Vanagon
2
4
  class Platform
3
5
  class Windows < Vanagon::Platform
@@ -231,7 +233,7 @@ class Vanagon
231
233
  ]
232
234
  end
233
235
  rescue RuntimeError
234
- warn "Unable to connect to #{project.signing_username}@#{project.signing_hostname}, skipping signing extra files: #{project.extra_files_to_sign.join(',')}"
236
+ VanagonLogger.error "Unable to connect to #{project.signing_username}@#{project.signing_hostname}, skipping signing extra files: #{project.extra_files_to_sign.join(',')}"
235
237
  end
236
238
  end
237
239
  make_commands << [
@@ -1,5 +1,6 @@
1
1
  require 'vanagon/component'
2
2
  require 'vanagon/environment'
3
+ require 'vanagon/logger'
3
4
  require 'vanagon/platform'
4
5
  require 'vanagon/project/dsl'
5
6
  require 'vanagon/utilities'
@@ -130,9 +131,9 @@ class Vanagon
130
131
  dsl.instance_eval(File.read(projfile), projfile, 1)
131
132
  dsl._project
132
133
  rescue StandardError => e
133
- warn "Error loading project '#{name}' using '#{projfile}':"
134
- warn e
135
- warn e.backtrace.join("\n")
134
+ VanagonLogger.error "Error loading project '#{name}' using '#{projfile}':"
135
+ VanagonLogger.error(e)
136
+ VanagonLogger.error e.backtrace.join("\n")
136
137
  raise e
137
138
  end
138
139
 
@@ -296,10 +297,14 @@ class Vanagon
296
297
  #
297
298
  # @return [Array] array of runtime requirements for the project
298
299
  def get_requires
299
- req = []
300
- req << components.flat_map(&:requires)
301
- req << @requires
302
- req.flatten.uniq
300
+ requires = []
301
+ requires << @requires.flatten
302
+ requires << components.flat_map(&:requires)
303
+ requires.flatten!
304
+ requires.each do |requirement|
305
+ requirement.version = @platform.version_munger(requirement.version, default: '<') if requirement.version
306
+ end
307
+ requires.uniq
303
308
  end
304
309
 
305
310
  # Collects all of the replacements for the project and its components
@@ -307,8 +312,8 @@ class Vanagon
307
312
  # @return [Array] array of package level replacements for the project
308
313
  def get_replaces
309
314
  replaces = []
310
- replaces.push @replaces.flatten
311
- replaces.push components.flat_map(&:replaces)
315
+ replaces << @replaces.flatten
316
+ replaces << components.flat_map(&:replaces)
312
317
  replaces.flatten!
313
318
  replaces.each do |replace|
314
319
  # TODO: Make this a more reasonable default before 1.0.0
@@ -324,8 +329,9 @@ class Vanagon
324
329
 
325
330
  # Collects all of the conflicts for the project and its components
326
331
  def get_conflicts
327
- conflicts = components.flat_map(&:conflicts) + @conflicts
328
- # Mash the whole thing down into a flat Array
332
+ conflicts = []
333
+ conflicts << @conflicts.flatten
334
+ conflicts << components.flat_map(&:conflicts)
329
335
  conflicts.flatten!
330
336
  conflicts.each do |conflict|
331
337
  # TODO: Make this a more reasonable default before 1.0.0
@@ -345,10 +351,14 @@ class Vanagon
345
351
  # will return nil
346
352
  #
347
353
  # @param [string] name of service to grab
348
- # @return [@component.service obj] specific service
354
+ # @return [@component.service obj] specific service, or array of services
355
+ # if there's more than one
349
356
  def get_service(name)
350
357
  components.each do |component|
351
358
  if component.name == name
359
+ if component.service.size == 1
360
+ return component.service.first
361
+ end
352
362
  return component.service
353
363
  end
354
364
  end
@@ -360,8 +370,8 @@ class Vanagon
360
370
  # @return [Array] array of package level provides for the project
361
371
  def get_provides
362
372
  provides = []
363
- provides.push @provides.flatten
364
- provides.push components.flat_map(&:provides)
373
+ provides << @provides.flatten
374
+ provides << components.flat_map(&:provides)
365
375
  provides.flatten!
366
376
  provides.each do |provide|
367
377
  # TODO: Make this a more reasonable default before 1.0.0
@@ -841,7 +851,7 @@ class Vanagon
841
851
  end
842
852
 
843
853
  def load_upstream_metadata(metadata_uri)
844
- warn "Loading metadata from #{metadata_uri}"
854
+ VanagonLogger.info "Loading metadata from #{metadata_uri}"
845
855
  case metadata_uri
846
856
  when /^http/
847
857
  @upstream_metadata = JSON.parse(Net::HTTP.get(URI(metadata_uri)))
@@ -1,4 +1,5 @@
1
1
  require 'vanagon/errors'
2
+ require 'vanagon/logger'
2
3
  require 'vanagon/project'
3
4
  require 'vanagon/utilities'
4
5
  require 'vanagon/component/source'
@@ -109,8 +110,8 @@ class Vanagon
109
110
  # Sets the run time requirements for the project. Mainly for use in packaging.
110
111
  #
111
112
  # @param req [String] of requirements of the project
112
- def requires(req)
113
- @project.requires << req
113
+ def requires(requirement, version = nil)
114
+ @project.requires << OpenStruct.new(:requirement => requirement, :version => version)
114
115
  end
115
116
 
116
117
  # Indicates that this component replaces a system level package. Replaces can be collected and used by the project and package.
@@ -185,7 +186,7 @@ class Vanagon
185
186
  last_tag = repo_object.describe('HEAD', { :abbrev => 0 })
186
187
  release(repo_object.rev_list("#{last_tag}..HEAD", { :count => true }))
187
188
  rescue Git::GitExecuteError
188
- warn "Directory '#{File.expand_path('..', @configdir)}' cannot be versioned by git. Maybe it hasn't been tagged yet?"
189
+ VanagonLogger.error "Directory '#{File.expand_path('..', @configdir)}' cannot be versioned by git. Maybe it hasn't been tagged yet?"
189
190
  end
190
191
 
191
192
  # Sets the version for the project based on a git describe of the
@@ -196,7 +197,7 @@ class Vanagon
196
197
  git_version = Git.open(File.expand_path("..", @configdir)).describe('HEAD', tags: true)
197
198
  version(git_version.split('-').reject(&:empty?).join('.'))
198
199
  rescue Git::GitExecuteError
199
- warn "Directory '#{File.expand_path('..', @configdir)}' cannot be versioned by git. Maybe it hasn't been tagged yet?"
200
+ VanagonLogger.error "Directory '#{File.expand_path('..', @configdir)}' cannot be versioned by git. Maybe it hasn't been tagged yet?"
200
201
  end
201
202
 
202
203
  # Get the version string from a git branch name. This will look for a '.'
@@ -268,7 +269,7 @@ class Vanagon
268
269
  #
269
270
  # @param name [String] name of component to add. must be present in configdir/components and named $name.rb currently
270
271
  def component(name)
271
- warn "Loading #{name}" if @project.settings[:verbose]
272
+ VanagonLogger.info "Loading #{name}" if @project.settings[:verbose]
272
273
  if @include_components.empty? or @include_components.include?(name)
273
274
  component = Vanagon::Component.load_component(name, File.join(@configdir, "components"), @project.settings, @project.platform)
274
275
  @project.components << component
@@ -9,6 +9,7 @@ require 'timeout'
9
9
  # but it provides a wealth of useful constants
10
10
  require 'English'
11
11
  require 'vanagon/extensions/string'
12
+ require 'vanagon/logger'
12
13
 
13
14
  class Vanagon
14
15
  module Utilities
@@ -165,7 +166,7 @@ class Vanagon
165
166
  yield
166
167
  return true
167
168
  rescue StandardError => e
168
- warn 'An error was encountered evaluating block. Retrying..'
169
+ VanagonLogger.error 'An error was encountered evaluating block. Retrying..'
169
170
  error = e
170
171
  end
171
172
  end
@@ -238,7 +239,7 @@ class Vanagon
238
239
  # output of the command if return_command_output is true
239
240
  # @raise [RuntimeError] If there is no target given or the command fails an exception is raised
240
241
  def remote_ssh_command(target, command, port = 22, return_command_output: false)
241
- warn "Executing '#{command}' on '#{target}'"
242
+ VanagonLogger.info "Executing '#{command}' on '#{target}'"
242
243
  if return_command_output
243
244
  ret = %x(#{ssh_command(port)} -T #{target} '#{command.gsub("'", "'\\\\''")}').chomp
244
245
  if $CHILD_STATUS.success?
@@ -261,7 +262,7 @@ class Vanagon
261
262
  # @raise [RuntimeError] If the command fails an exception is raised
262
263
  def local_command(command, return_command_output: false)
263
264
  clean_environment do
264
- warn "Executing '#{command}' locally"
265
+ VanagonLogger.info "Executing '#{command}' locally"
265
266
  if return_command_output
266
267
  ret = %x(#{command}).chomp
267
268
  if $CHILD_STATUS.success?
@@ -305,7 +306,7 @@ class Vanagon
305
306
  outfile ||= File.join(Dir.mktmpdir, File.basename(erbfile).sub(File.extname(erbfile), ""))
306
307
  output = erb_string(erbfile, opts[:binding])
307
308
  File.open(outfile, 'w') { |f| f.write output }
308
- warn "Generated: #{outfile}"
309
+ VanagonLogger.info "Generated: #{outfile}"
309
310
  FileUtils.rm_rf erbfile if remove_orig
310
311
  outfile
311
312
  end