vanagon 0.23.0 → 0.24.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9471f41441c2a8aea399d9a08961332b68e94e9a377b783e76d09857ffcec0d7
4
- data.tar.gz: ea8ccc12852db54d70c58d17d66815fadc48604eabfdf456623357fef3c3dd21
3
+ metadata.gz: 958967d126de3ae4bf36c6e13f2aa0dcbe387e7cf52621ba5386ef87e470402d
4
+ data.tar.gz: 57b2cb0b77c9d0fd82d79a935d2c5fd8676c3e46968c036f21dc86128e97303f
5
5
  SHA512:
6
- metadata.gz: 67e94d799467fc05efb1e3815c55d71f4ffee9b91126eacae5b24793a7d6cb1478f0aae5c936a946e6d78e0896ea92f970104fbc519f0de45389f36bec228e2e
7
- data.tar.gz: 756ebf1259f45d5fd5c9a2e5050423bca7da0cf72d5ab3404551da4c9d868b2b68bfa03043ee3f6e070c1b86884076c43af3891cfa3841a5dec8b6909ee3faf5
6
+ metadata.gz: c6a328120e33ef21de286bbb5f1d086632ac855507c3c3a3913d392a7a99a04f447c90128cfeaca4f37674c8f541e5c07c326a70c5dde79a069a8a8339c052f3
7
+ data.tar.gz: 98ffb256fbd7b09fc1c7eea5157036ef666cbb80e9bc686077a2722d64b9371a516b60252a5f70f2956451e83a2f68e3538f3369115e8fdf26cbf18402fb030d
@@ -0,0 +1,89 @@
1
+ require 'docopt'
2
+ require 'json'
3
+ require 'vanagon/logger'
4
+
5
+ class Vanagon
6
+ class CLI
7
+ class Dependencies < Vanagon::CLI
8
+ DOCUMENTATION = <<~DOCOPT.freeze
9
+ Usage:
10
+ dependencies [options] <project-name> <platforms>
11
+
12
+ Options:
13
+ -h, --help Display help
14
+ -c, --configdir DIRECTORY Configuration directory [default: #{Dir.pwd}/configs]
15
+ -w, --workdir DIRECTORY Working directory on the local host
16
+ -v, --verbose Only here for backwards compatibility. Does nothing.
17
+
18
+ Project-Name:
19
+ May be a project name of a project from the configs/projects directory or 'all' to generate dependencies for all projects.
20
+ Platforms:
21
+ May be a platform name of a platform from the configs/platforms directory or 'all' to generate dependencies for all platforms.
22
+ DOCOPT
23
+
24
+ def parse(argv)
25
+ Docopt.docopt(DOCUMENTATION, { argv: argv })
26
+ rescue Docopt::Exit => e
27
+ VanagonLogger.error e.message
28
+ exit 1
29
+ end
30
+
31
+ def run(options) # rubocop:disable Metrics/AbcSize
32
+ platforms_directory = File.join(options[:configdir], 'platforms')
33
+ projects_directory = File.join(options[:configdir], 'projects')
34
+
35
+ unless Dir.exist?(projects_directory) && Dir.exist?(platforms_directory)
36
+ VanagonLogger.error "Path to #{platforms_directory} or #{projects_directory} not found."
37
+ exit 1
38
+ end
39
+
40
+ projects = [options[:project_name]]
41
+ if projects.include?('all')
42
+ projects = Dir.children(projects_directory).map do |project|
43
+ File.basename(project, File.extname(project))
44
+ end
45
+ end
46
+
47
+ platforms = options[:platforms].split(',')
48
+ if platforms.include?('all')
49
+ platforms = Dir.children(platforms_directory).map do |platform|
50
+ File.basename(platform, File.extname(platform))
51
+ end
52
+ end
53
+
54
+ failures = []
55
+
56
+ projects.each do |project|
57
+ platforms.each do |platform|
58
+ begin
59
+ artifact = Vanagon::Driver.new(platform, project, options)
60
+ artifact.dependencies
61
+ rescue RuntimeError => e
62
+ failures.push("#{project}, #{platform}: #{e}")
63
+ end
64
+ end
65
+ end
66
+
67
+ unless failures.empty?
68
+ VanagonLogger.info "Failed to generate dependencies for the following:"
69
+ failures.each do |failure|
70
+ VanagonLogger.info failure
71
+ end
72
+ end
73
+
74
+ VanagonLogger.info "Finished generating dependencies"
75
+ end
76
+
77
+ def options_translate(docopt_options)
78
+ translations = {
79
+ '--verbose' => :verbose,
80
+ '--workdir' => :workdir,
81
+ '--configdir' => :configdir,
82
+ '<project-name>' => :project_name,
83
+ '<platforms>' => :platforms
84
+ }
85
+ return docopt_options.map { |k, v| [translations[k], v] }.to_h
86
+ end
87
+ end
88
+ end
89
+ end
data/lib/vanagon/cli.rb CHANGED
@@ -14,6 +14,7 @@ require 'vanagon/cli/list'
14
14
  require 'vanagon/cli/render'
15
15
  require 'vanagon/cli/ship'
16
16
  require 'vanagon/cli/sign'
17
+ require 'vanagon/cli/dependencies'
17
18
 
18
19
  require 'vanagon/logger'
19
20
 
@@ -37,6 +38,7 @@ class Vanagon
37
38
  render create local versions of packaging artifacts for project
38
39
  sign sign a package
39
40
  ship upload a package to a distribution server
41
+ dependencies write json file to STDOUT that shows all required gems for a given project and platform
40
42
  help print this help
41
43
  DOCOPT
42
44
 
@@ -64,6 +66,8 @@ class Vanagon
64
66
  @sub_parser = Vanagon::CLI::Sign.new
65
67
  when 'ship'
66
68
  @sub_parser = Vanagon::CLI::Ship.new
69
+ when 'dependencies'
70
+ @sub_parser = Vanagon::CLI::Dependencies.new
67
71
  when 'help'
68
72
  puts DOCUMENTATION
69
73
  exit 0
@@ -13,7 +13,7 @@ class Vanagon
13
13
  class Component
14
14
  class Source
15
15
  class Git
16
- attr_accessor :url, :ref, :workdir, :clone_options
16
+ attr_accessor :url, :log_url, :ref, :workdir, :clone_options
17
17
  attr_reader :version, :default_options, :repo
18
18
 
19
19
  class << self
@@ -73,18 +73,19 @@ class Vanagon
73
73
  # @param url [String] url of git repo to use as source
74
74
  # @param ref [String] ref to checkout from git repo
75
75
  # @param workdir [String] working directory to clone into
76
- def initialize(url, workdir:, **options)
76
+ def initialize(url, workdir:, **options) # rubocop:disable Metrics/AbcSize
77
77
  opts = default_options.merge(options.reject { |k, v| v.nil? })
78
78
 
79
79
  # Ensure that #url returns a URI object
80
80
  @url = URI.parse(url.to_s)
81
+ @log_url = @url.host + @url.path unless @url.host.nil? || @url.path.nil?
81
82
  @ref = opts[:ref]
82
83
  @dirname = opts[:dirname]
83
84
  @workdir = File.realpath(workdir)
84
85
  @clone_options = opts[:clone_options] ||= {}
85
86
 
86
87
  # We can test for Repo existence without cloning
87
- raise Vanagon::InvalidRepo, "#{url} not a valid Git repo" unless valid_remote?
88
+ raise Vanagon::InvalidRepo, "url is not a valid Git repo" unless valid_remote?
88
89
  end
89
90
 
90
91
  # Fetch the source. In this case, clone the repository into the workdir
@@ -157,10 +158,10 @@ class Vanagon
157
158
  # Clone a remote repo, make noise about it, and fail entirely
158
159
  # if we're unable to retrieve the remote repo
159
160
  def clone!
160
- VanagonLogger.info "Cloning Git repo '#{url}'"
161
+ VanagonLogger.info "Cloning Git repo '#{log_url}'"
161
162
  VanagonLogger.info "Successfully cloned '#{dirname}'" if clone
162
163
  rescue ::Git::GitExecuteError
163
- raise Vanagon::InvalidRepo, "Unable to clone from '#{url}'"
164
+ raise Vanagon::InvalidRepo, "Unable to clone from '#{log_url}'"
164
165
  end
165
166
  private :clone!
166
167
 
@@ -170,7 +171,7 @@ class Vanagon
170
171
  VanagonLogger.info "Checking out '#{ref}' from Git repo '#{dirname}'"
171
172
  clone.checkout(ref)
172
173
  rescue ::Git::GitExecuteError
173
- raise Vanagon::CheckoutFailed, "unable to checkout #{ref} from '#{url}'"
174
+ raise Vanagon::CheckoutFailed, "unable to checkout #{ref} from '#{log_url}'"
174
175
  end
175
176
  private :checkout!
176
177
 
@@ -108,6 +108,9 @@ class Vanagon
108
108
  uri = URI.parse(target_url.to_s)
109
109
  target_file ||= File.basename(uri.path)
110
110
 
111
+ # Add X-RPROXY-PASS to request header if the environment variable exists
112
+ headers['X-RPROXY-PASS'] = ENV['X-RPROXY-PASS'] if ENV['X-RPROXY-PASS']
113
+
111
114
  VanagonLogger.info "Downloading file '#{target_file}' from url '#{target_url}'"
112
115
 
113
116
  Net::HTTP.start(uri.host, uri.port, use_ssl: uri.scheme == 'https') do |http|
@@ -171,7 +171,7 @@ class Vanagon
171
171
 
172
172
  def render # rubocop:disable Metrics/AbcSize
173
173
  # Simple sanity check for the project
174
- if @project.version.nil? or @project.version.empty?
174
+ if @project.version.nil? || @project.version.empty?
175
175
  raise Vanagon::Error, "Project requires a version set, all is lost."
176
176
  end
177
177
 
@@ -182,6 +182,17 @@ class Vanagon
182
182
  @project.make_makefile(workdir)
183
183
  end
184
184
 
185
+ def dependencies
186
+ # Simple sanity check for the project
187
+ if @project.version.nil? || @project.version.empty?
188
+ raise Vanagon::Error, "Project requires a version set, all is lost."
189
+ end
190
+
191
+ VanagonLogger.info "creating dependencies list"
192
+ @project.fetch_sources(workdir, retry_count, timeout)
193
+ @project.cli_manifest_json(@platform)
194
+ end
195
+
185
196
  # Initialize the logging instance
186
197
  def loginit(logfile)
187
198
  @@logger = Logger.new(logfile)
@@ -0,0 +1,10 @@
1
+ platform "el-9-aarch64" do |plat|
2
+ plat.servicedir "/usr/lib/systemd/system"
3
+ plat.defaultdir "/etc/sysconfig"
4
+ plat.servicetype "systemd"
5
+
6
+ packages = %w(autoconf automake createrepo gcc gcc-c++ rsync cmake make rpm-libs rpm-build libarchive)
7
+ plat.provision_with "dnf install -y --allowerasing #{packages.join(' ')}"
8
+ plat.install_build_dependencies_with "dnf install -y --allowerasing "
9
+ plat.vmpooler_template "redhat-9-arm64"
10
+ end
@@ -0,0 +1,10 @@
1
+ platform "el-9-x86_64" do |plat|
2
+ plat.servicedir "/usr/lib/systemd/system"
3
+ plat.defaultdir "/etc/sysconfig"
4
+ plat.servicetype "systemd"
5
+
6
+ packages = %w(gcc gcc-c++ autoconf automake createrepo rsync cmake make rpm-libs rpm-build rpm-sign libtool libarchive)
7
+ plat.provision_with "dnf install -y --allowerasing #{packages.join(' ')}"
8
+ plat.install_build_dependencies_with "dnf install -y --allowerasing "
9
+ plat.vmpooler_template "redhat-9-x86_64"
10
+ end
@@ -762,6 +762,17 @@ class Vanagon
762
762
  end
763
763
  end
764
764
 
765
+ # Writes a json file to STDOUT containing information
766
+ # about what will go into an artifact
767
+ #
768
+ # @param platform [String] platform we're writing metadata for
769
+ def cli_manifest_json(platform)
770
+ manifest = build_manifest_json
771
+ metadata = metadata_merge(manifest, @upstream_metadata)
772
+
773
+ puts JSON.pretty_generate(metadata)
774
+ end
775
+
765
776
  # Writes a yaml file at `output/<name>-<version>.<platform>.settings.yaml`
766
777
  # containing settings used to build the current project on the platform
767
778
  # provided (and a corresponding sha1sum file) if `yaml_settings` has been
@@ -81,7 +81,7 @@ Requires: <%= requires.requirement %><%= requires.version ? " #{requires.versio
81
81
  # did not specify a dependency on these.
82
82
  # In the future, we will supress pre/post scripts completely if there's nothing
83
83
  # specified by the project or the components.
84
- <%- if @platform.is_fedora? && @platform.os_version.to_i >= 29 -%>
84
+ <%- if @platform.is_fedora? || (@platform.is_el? && @platform.os_version.to_i >= 9) -%>
85
85
  Requires(pre): /usr/bin/mkdir
86
86
  Requires(pre): /usr/bin/touch
87
87
  Requires(post): /usr/bin/mkdir
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vanagon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Puppet Labs
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-24 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: docopt
@@ -118,6 +118,7 @@ files:
118
118
  - lib/vanagon/cli/build_host_info.rb
119
119
  - lib/vanagon/cli/build_requirements.rb
120
120
  - lib/vanagon/cli/completion.rb
121
+ - lib/vanagon/cli/dependencies.rb
121
122
  - lib/vanagon/cli/inspect.rb
122
123
  - lib/vanagon/cli/list.rb
123
124
  - lib/vanagon/cli/render.rb
@@ -164,11 +165,10 @@ files:
164
165
  - lib/vanagon/platform/defaults/el-7-x86_64.rb
165
166
  - lib/vanagon/platform/defaults/el-8-aarch64.rb
166
167
  - lib/vanagon/platform/defaults/el-8-x86_64.rb
167
- - lib/vanagon/platform/defaults/fedora-30-x86_64.rb
168
- - lib/vanagon/platform/defaults/fedora-31-x86_64.rb
168
+ - lib/vanagon/platform/defaults/el-9-aarch64.rb
169
+ - lib/vanagon/platform/defaults/el-9-x86_64.rb
169
170
  - lib/vanagon/platform/defaults/fedora-32-x86_64.rb
170
171
  - lib/vanagon/platform/defaults/fedora-34-x86_64.rb
171
- - lib/vanagon/platform/defaults/osx-10.14-x86_64.rb
172
172
  - lib/vanagon/platform/defaults/osx-10.15-x86_64.rb
173
173
  - lib/vanagon/platform/defaults/osx-11-x86_64.rb
174
174
  - lib/vanagon/platform/defaults/redhatfips-7-x86_64.rb
@@ -326,42 +326,42 @@ signing_key:
326
326
  specification_version: 3
327
327
  summary: All of your packages will fit into this van with this one simple trick.
328
328
  test_files:
329
- - spec/lib/vanagon/component_spec.rb
330
- - spec/lib/vanagon/utilities/shell_utilities_spec.rb
329
+ - spec/lib/vanagon/project_spec.rb
331
330
  - spec/lib/vanagon/utilities/extra_files_signer_spec.rb
331
+ - spec/lib/vanagon/utilities/shell_utilities_spec.rb
332
+ - spec/lib/vanagon/extensions/string_spec.rb
332
333
  - spec/lib/vanagon/extensions/set/json_spec.rb
333
334
  - spec/lib/vanagon/extensions/ostruct/json_spec.rb
334
- - spec/lib/vanagon/extensions/string_spec.rb
335
+ - spec/lib/vanagon/utilities_spec.rb
336
+ - spec/lib/vanagon/common/user_spec.rb
337
+ - spec/lib/vanagon/common/pathname_spec.rb
338
+ - spec/lib/vanagon/cli_spec.rb
339
+ - spec/lib/vanagon/platform/solaris_10_spec.rb
340
+ - spec/lib/vanagon/platform/solaris_11_spec.rb
341
+ - spec/lib/vanagon/platform/osx_spec.rb
342
+ - spec/lib/vanagon/platform/deb_spec.rb
343
+ - spec/lib/vanagon/platform/rpm/aix_spec.rb
344
+ - spec/lib/vanagon/platform/rpm_spec.rb
345
+ - spec/lib/vanagon/platform/windows_spec.rb
346
+ - spec/lib/vanagon/platform/dsl_spec.rb
347
+ - spec/lib/vanagon/project/dsl_spec.rb
348
+ - spec/lib/vanagon/driver_spec.rb
349
+ - spec/lib/vanagon/component_spec.rb
350
+ - spec/lib/vanagon/environment_spec.rb
351
+ - spec/lib/vanagon/platform_spec.rb
335
352
  - spec/lib/vanagon/engine/base_spec.rb
336
353
  - spec/lib/vanagon/engine/hardware_spec.rb
337
354
  - spec/lib/vanagon/engine/always_be_scheduling_spec.rb
338
- - spec/lib/vanagon/engine/ec2_spec.rb
339
- - spec/lib/vanagon/engine/pooler_spec.rb
340
355
  - spec/lib/vanagon/engine/docker_spec.rb
341
356
  - spec/lib/vanagon/engine/local_spec.rb
342
- - spec/lib/vanagon/common/user_spec.rb
343
- - spec/lib/vanagon/common/pathname_spec.rb
344
- - spec/lib/vanagon/environment_spec.rb
345
- - spec/lib/vanagon/platform_spec.rb
346
- - spec/lib/vanagon/component/rules_spec.rb
347
- - spec/lib/vanagon/component/source_spec.rb
357
+ - spec/lib/vanagon/engine/ec2_spec.rb
358
+ - spec/lib/vanagon/engine/pooler_spec.rb
348
359
  - spec/lib/vanagon/component/source/rewrite_spec.rb
349
360
  - spec/lib/vanagon/component/source/http_spec.rb
350
- - spec/lib/vanagon/component/source/git_spec.rb
351
361
  - spec/lib/vanagon/component/source/local_spec.rb
362
+ - spec/lib/vanagon/component/source/git_spec.rb
363
+ - spec/lib/vanagon/component/rules_spec.rb
364
+ - spec/lib/vanagon/component/source_spec.rb
352
365
  - spec/lib/vanagon/component/dsl_spec.rb
353
- - spec/lib/vanagon/utilities_spec.rb
354
- - spec/lib/vanagon/project/dsl_spec.rb
355
- - spec/lib/vanagon/cli_spec.rb
356
- - spec/lib/vanagon/project_spec.rb
357
- - spec/lib/vanagon/platform/rpm_spec.rb
358
- - spec/lib/vanagon/platform/windows_spec.rb
359
- - spec/lib/vanagon/platform/osx_spec.rb
360
- - spec/lib/vanagon/platform/deb_spec.rb
361
- - spec/lib/vanagon/platform/rpm/aix_spec.rb
362
- - spec/lib/vanagon/platform/dsl_spec.rb
363
- - spec/lib/vanagon/platform/solaris_11_spec.rb
364
- - spec/lib/vanagon/platform/solaris_10_spec.rb
365
- - spec/lib/vanagon/driver_spec.rb
366
- - spec/lib/makefile_spec.rb
367
366
  - spec/lib/git/rev_list_spec.rb
367
+ - spec/lib/makefile_spec.rb
@@ -1,11 +0,0 @@
1
- platform "fedora-30-x86_64" do |plat|
2
- plat.servicedir "/usr/lib/systemd/system"
3
- plat.defaultdir "/etc/sysconfig"
4
- plat.servicetype "systemd"
5
- plat.dist "fc30"
6
-
7
- packages = %w(autoconf automake createrepo rsync gcc gcc-c++ make rpmdevtools rpm-libs cmake rpm-sign yum-utils)
8
- plat.provision_with "/usr/bin/dnf install -y --best --allowerasing #{packages.join(' ')}"
9
- plat.install_build_dependencies_with "/usr/bin/dnf install -y --best --allowerasing"
10
- plat.vmpooler_template "fedora-30-x86_64"
11
- end
@@ -1,11 +0,0 @@
1
- platform "fedora-31-x86_64" do |plat|
2
- plat.servicedir "/usr/lib/systemd/system"
3
- plat.defaultdir "/etc/sysconfig"
4
- plat.servicetype "systemd"
5
- plat.dist "fc31"
6
-
7
- packages = %w(autoconf automake cmake createrepo rsync gcc gcc-c++ make rpmdevtools rpm-libs rpm-sign)
8
- plat.provision_with "/usr/bin/dnf install -y --best --allowerasing #{packages.join(' ')}"
9
- plat.install_build_dependencies_with "/usr/bin/dnf install -y --best --allowerasing"
10
- plat.vmpooler_template "fedora-31-x86_64"
11
- end
@@ -1,21 +0,0 @@
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
- end