conjur-debify 3.0.3.pre.1965 → 3.0.3.pre.1971

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: bb57973a44bd19cc50287b17d5827be06557beb8aa62f45c439899e7eec4b45f
4
- data.tar.gz: 6abe99e1aa7819e6bb6b106bb8e587a41b20b7a226e2b15ea61e15ff938e3c28
3
+ metadata.gz: dbb48a20c69ae4de07aa6be5a0812fc434862d0a6b892ac9e14307a699d4eca4
4
+ data.tar.gz: e49635adbf456eee2eac799f8eea2be543c27b52bcec615de92e755c47cca5e1
5
5
  SHA512:
6
- metadata.gz: e2cd3cfa37fd275b6997006de154d7b7da962d75781263b04bd0f8fd8253fae89aee5e74392ba1c4b4609b47e405b116177517e90e38c696865748b97764281d
7
- data.tar.gz: bb62f3194644f9b8dcf9446fede0ce73d36ae89106d78bdb785ac334af57cc0ebabb3f98ccd6ba8554b4f231af3be269aeb70df7288f4ccb643c3e0ceaec0ab5
6
+ metadata.gz: 51126d13fd0a308ad4d3b753cd9edbdc425069ae20a3a583d4db1d2b5e5b4dd2ed99adf1e5235235eff5c03c6fd2a9c4a2daff3e0a26b33665648da0ac9e3c3f
7
+ data.tar.gz: 4d78bc9be16f8b8b4f3e7d70b51fea06beef7611de142f2bba84d912f72237a872b730de52049a1c16695c7d88f533cae81d9b5e0bfcb5f3fcebbf45abdd063a
data/CHANGELOG.md CHANGED
@@ -1,4 +1,6 @@
1
1
  ## [3.0.3]
2
+ ### Added
3
+ - Allow user to specify architecture of packages (arm64 or amd64)
2
4
 
3
5
  ## [3.0.2]
4
6
  ### Changed
data/README.md CHANGED
@@ -110,9 +110,10 @@ DESCRIPTION
110
110
  The distrib folder in the project source tree is intended to create scripts for package pre-install, post-install etc. The distrib folder is not
111
111
  included in the deb package, so its contents should be copied to the file system or packaged using fpm arguments.
112
112
 
113
- All arguments to this command which follow the double-dash are propagated to the fpm command.
113
+ All arguments to this command which follow the double-dash are propagated to the fpm command.
114
114
 
115
115
  COMMAND OPTIONS
116
+ -a, --architecture=arg - Set the architecture of the package; can be set to arm64 or amd64 (default: amd64)
116
117
  --additional-files=arg - Specify files to add to the FPM image that are not included from the git repo (default: none)
117
118
  -d, --dir=arg - Set the current working directory (default: none)
118
119
  --dockerfile=arg - Specify a custom Dockerfile.fpm (default: none)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 3.0.3-1965
1
+ 3.0.3-1971
@@ -4,20 +4,41 @@ Feature: Packaging
4
4
  Background:
5
5
  # We use version 0.0.1-suffix to verify that RPM converts dashes to underscores
6
6
  # in the version as we expect
7
- Given I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1-suffix example -- --post-install /distrib/postinstall.sh`
8
- And I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example --output rpm -v 0.0.1-suffix example -- --post-install /distrib/postinstall.sh`
9
7
 
10
- Scenario: 'example' project can be packaged successfully
8
+
9
+ Scenario: 'example' project can be packaged successfully for amd64
10
+ Given I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1-suffix --architecture=amd64 example -- --post-install /distrib/postinstall.sh`
11
+ And I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example --output rpm -v 0.0.1-suffix --architecture=amd64 example -- --post-install /distrib/postinstall.sh`
11
12
  Then the stdout should contain "conjur-example_0.0.1-suffix_amd64.deb"
12
13
  And the stdout should contain "conjur-example-dev_0.0.1-suffix_amd64.deb"
13
14
  And the stdout should contain "conjur-example-0.0.1_suffix-1.x86_64.rpm"
14
15
  And the stdout should contain "conjur-example-dev-0.0.1_suffix-1.x86_64.rpm"
15
16
 
16
- Scenario: 'clean' command will delete non-Git-managed files
17
+ Scenario: 'clean' command will delete non-Git-managed files for amd64
18
+ Given I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1-suffix --architecture=amd64 example -- --post-install /distrib/postinstall.sh`
19
+ And I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example --output rpm -v 0.0.1-suffix --architecture=amd64 example -- --post-install /distrib/postinstall.sh`
17
20
  When I successfully run `env DEBUG=true GLI_DEBUG=true debify clean -d ../../example --force`
18
21
  And I successfully run `find ../../example`
19
22
  Then the stdout from "find ../../example" should not contain "conjur-example_0.0.1-suffix_amd64.deb"
20
23
  And the stdout from "find ../../example" should not contain "conjur-example-0.0.1_suffix-1.x86_64.rpm"
21
24
 
25
+ Scenario: 'example' project can be packaged successfully for arm64
26
+ Given I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1-suffix --architecture=aarch64 example -- --post-install /distrib/postinstall.sh`
27
+ And I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example --output rpm -v 0.0.1-suffix --architecture=aarch64 example -- --post-install /distrib/postinstall.sh`
28
+ Then the stdout should contain "conjur-example_0.0.1-suffix_arm64.deb"
29
+ And the stdout should contain "conjur-example-dev_0.0.1-suffix_arm64.deb"
30
+ And the stdout should contain "conjur-example-0.0.1_suffix-1.aarch64.rpm"
31
+ And the stdout should contain "conjur-example-dev-0.0.1_suffix-1.aarch64.rpm"
32
+
33
+ Scenario: 'clean' command will delete non-Git-managed files for arm64
34
+ Given I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1-suffix --architecture=aarch64 example -- --post-install /distrib/postinstall.sh`
35
+ And I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example --output rpm -v 0.0.1-suffix --architecture=aarch64 example -- --post-install /distrib/postinstall.sh`
36
+ When I successfully run `env DEBUG=true GLI_DEBUG=true debify clean -d ../../example --force`
37
+ And I successfully run `find ../../example`
38
+ Then the stdout from "find ../../example" should not contain "conjur-example_0.0.1-suffix_arm64.deb"
39
+ And the stdout from "find ../../example" should not contain "conjur-example-0.0.1_suffix-1.aarch64.rpm"
40
+
22
41
  Scenario: 'example' project can be published
42
+ Given I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1-suffix example -- --post-install /distrib/postinstall.sh`
43
+ And I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example --output rpm -v 0.0.1-suffix example -- --post-install /distrib/postinstall.sh`
23
44
  When I successfully run `env DEBUG=true GLI_DEBUG=true debify publish -v 0.0.1-suffix -d ../../example 5.0 example`
data/lib/conjur/debify.rb CHANGED
@@ -14,6 +14,8 @@ require 'active_support/core_ext'
14
14
  include GLI::App
15
15
 
16
16
  DEFAULT_FILE_TYPE = "deb"
17
+ ARM64_ARCHITECTURE_NAME = "aarch64"
18
+ AMD64_ARCHITECTURE_NAME = "amd64"
17
19
 
18
20
  config_file '.debifyrc'
19
21
 
@@ -31,24 +33,24 @@ Docker.options[:read_timeout] = 300
31
33
  module DebugMixin
32
34
  DEBUG = ENV['DEBUG'].nil? ? true : ENV['DEBUG'].downcase == 'true'
33
35
 
34
- def debug *a
36
+ def debug(* a)
35
37
  DebugMixin.debug *a
36
38
  end
37
39
 
38
- def self.debug *a
40
+ def self.debug(* a)
39
41
  $stderr.puts *a if DEBUG
40
42
  end
41
43
 
42
- def debug_write *a
44
+ def debug_write(* a)
43
45
  DebugMixin.debug_write *a
44
46
  end
45
47
 
46
- def self.debug_write *a
48
+ def self.debug_write(* a)
47
49
  $stderr.write *a if DEBUG
48
50
  end
49
51
 
50
52
  # you can give this to various docker methods to print output if debug is on
51
- def self.docker_debug *a
53
+ def self.docker_debug(* a)
52
54
  if a.length == 2 && a[0].is_a?(Symbol)
53
55
  debug a.last
54
56
  else
@@ -91,7 +93,7 @@ def detect_version
91
93
  end
92
94
 
93
95
  def git_files
94
- files = (`git ls-files -z`.split("\x0") + ['Gemfile.lock', 'VERSION']).uniq
96
+ files = (`git ls-files -z`.split("\x0") + %w['Gemfile.lock', 'VERSION']).uniq
95
97
  # Since submodule directories are listed, but are not files, we remove them.
96
98
  # Currently, `conjur-project-config` is the only submodule in Conjur, and it
97
99
  # can safely be removed because it's a developer-only tool. If we add another
@@ -141,7 +143,7 @@ command "clean" do |c|
141
143
  c.desc "Force file deletion even if if this doesn't look like a Jenkins environment"
142
144
  c.switch [:force]
143
145
 
144
- c.action do |global_options, cmd_options, args|
146
+ c.action do |_, cmd_options, _|
145
147
  def looks_like_jenkins?
146
148
  require 'etc'
147
149
  Etc.getlogin == 'jenkins' && ENV['BUILD_NUMBER']
@@ -149,12 +151,12 @@ command "clean" do |c|
149
151
 
150
152
  require 'set'
151
153
  perform_deletion = cmd_options[:force] || looks_like_jenkins?
152
- if !perform_deletion
154
+ unless perform_deletion
153
155
  $stderr.puts "No --force, and this doesn't look like Jenkins. I won't actually delete anything"
154
156
  end
155
- @ignore_list = Array(cmd_options[:ignore]) + ['.', '..', '.git']
157
+ @ignore_list = Array(cmd_options[:ignore]) + %w['.', '..', '.git']
156
158
 
157
- def ignore_file? f
159
+ def ignore_file?(f)
158
160
  @ignore_list.find { |ignore| f.index(ignore) == 0 }
159
161
  end
160
162
 
@@ -190,7 +192,7 @@ command "clean" do |c|
190
192
  file = "/src/#{file}"
191
193
  cmd = ["rm", "-f", file]
192
194
 
193
- stdout, stderr, status = container.exec cmd, &DebugMixin::DOCKER
195
+ _, _, status = container.exec cmd, &DebugMixin::DOCKER
194
196
  $stderr.puts "Failed to delete #{file}" unless status == 0
195
197
  end
196
198
  ensure
@@ -262,8 +264,12 @@ command "package" do |c|
262
264
  c.default_value "latest"
263
265
  c.flag [:t, :'image-tag']
264
266
 
265
- c.action do |global_options, cmd_options, args|
266
- raise "project-name is required" unless project_name = args.shift
267
+ c.desc "Set the architecture of the package; can be set to arm64 or amd64"
268
+ c.default_value AMD64_ARCHITECTURE_NAME
269
+ c.flag [:a, :architecture]
270
+
271
+ c.action do |_, cmd_options, args|
272
+ raise "project-name is required" unless (project_name = args.shift)
267
273
 
268
274
  fpm_args = []
269
275
  if (delimeter = args.shift) == '--'
@@ -333,36 +339,33 @@ command "package" do |c|
333
339
  file_type = cmd_options[:output] || DEFAULT_FILE_TYPE
334
340
  container_cmd_options << "--file-type=#{file_type}"
335
341
 
342
+ # Set the architecture of the package
343
+ architecture = cmd_options[:architecture] || AMD64_ARCHITECTURE_NAME
344
+ if architecture != AMD64_ARCHITECTURE_NAME && architecture != ARM64_ARCHITECTURE_NAME
345
+ raise "Unsupported architecture type: #{architecture}, choose one of the following: #{AMD64_ARCHITECTURE_NAME}, #{ARM64_ARCHITECTURE_NAME}"
346
+ end
347
+ container_cmd_options << "--architecture=#{architecture}"
348
+
336
349
  options = {
337
350
  'Cmd' => container_cmd_options + fpm_args,
338
351
  'Image' => image.id
339
352
  }
340
353
  options['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
341
354
 
355
+ file_path, dev_file_path = determine_file_path(file_type, architecture, project_name, version)
356
+
342
357
  container = Docker::Container.create options
343
358
  begin
344
359
  DebugMixin.debug_write "Packaging #{project_name} in container #{container.id}\n"
345
- container.tap(&:start!).streaming_logs(follow: true, stdout: true, stderr: true) { |stream, chunk| $stderr.puts "#{chunk}" }
360
+ container.tap(&:start!).streaming_logs(follow: true, stdout: true, stderr: true) { |_, chunk| $stderr.puts "#{chunk}" }
346
361
  status = container.wait
347
362
  raise "Failed to package #{project_name}" unless status['StatusCode'] == 0
348
363
 
349
- if file_type == "deb"
350
- # Copy deb packages
351
- copy_packages_from_container(
352
- container,
353
- "conjur-#{project_name}_#{version}_amd64.deb",
354
- "conjur-#{project_name}-dev_#{version}_amd64.deb"
355
- )
356
- elsif file_type == "rpm"
357
- # Copy rpm packages
358
- # The rpm builder replaces dashes with underscores in the version
359
- rpm_version = version.tr('-', '_')
360
- copy_packages_from_container(
361
- container,
362
- "conjur-#{project_name}-#{rpm_version}-1.x86_64.rpm",
363
- "conjur-#{project_name}-dev-#{rpm_version}-1.x86_64.rpm"
364
- )
365
- end
364
+ copy_packages_from_container(
365
+ container,
366
+ file_path,
367
+ dev_file_path
368
+ )
366
369
  ensure
367
370
  container.delete(force: true)
368
371
  end
@@ -370,13 +373,40 @@ command "package" do |c|
370
373
  end
371
374
  end
372
375
 
373
- def container_command container, *args
374
- stdout, stderr, exitcode = container.exec args, &DebugMixin::DOCKER
376
+ def determine_file_path(file_type, architecture, project_name, version)
377
+ if file_type == "deb"
378
+ if architecture == ARM64_ARCHITECTURE_NAME
379
+ architecture = "arm64"
380
+ end
381
+
382
+ file_path = "conjur-#{project_name}_#{version}_#{architecture}.#{file_type}"
383
+ dev_file_path = "conjur-#{project_name}-dev_#{version}_#{architecture}.#{file_type}"
384
+
385
+ elsif file_type == "rpm"
386
+ if architecture == AMD64_ARCHITECTURE_NAME
387
+ architecture = "x86_64"
388
+ end
389
+
390
+ # The rpm builder replaces dashes with underscores in the version
391
+ version = version.tr('-', '_')
392
+
393
+ file_path = "conjur-#{project_name}-#{version}-1.#{architecture}.#{file_type}"
394
+ dev_file_path = "conjur-#{project_name}-dev-#{version}-1.#{architecture}.#{file_type}"
395
+
396
+ else
397
+ raise "Unrecognized file type: #{file_type}, must be one of the following: deb, rpm"
398
+ end
399
+
400
+ [file_path, dev_file_path]
401
+ end
402
+
403
+ def container_command(container, *args)
404
+ stdout, _, exitcode = container.exec args, &DebugMixin::DOCKER
375
405
  exit_now! "Command failed : #{args.join(' ')}", exitcode unless exitcode == 0
376
406
  stdout
377
407
  end
378
408
 
379
- def wait_for_conjur appliance_image, container
409
+ def wait_for_conjur(container)
380
410
  container_command container, '/opt/conjur/evoke/bin/wait_for_conjur'
381
411
  rescue
382
412
  $stderr.puts container.logs(stdout: true, stderr: true)
@@ -480,8 +510,8 @@ command "test" do |c|
480
510
  network_options(c)
481
511
 
482
512
  c.action do |global_options, cmd_options, args|
483
- raise "project-name is required" unless project_name = args.shift
484
- raise "test-script is required" unless test_script = args.shift
513
+ raise "project-name is required" unless (project_name = args.shift)
514
+ raise "test-script is required" unless (test_script = args.shift)
485
515
  raise "Received extra command-line arguments" if args.shift
486
516
 
487
517
  dir = cmd_options[:dir] || '.'
@@ -553,7 +583,7 @@ RUN touch /etc/service/conjur/down
553
583
  options = {
554
584
  'Image' => appliance_image.id,
555
585
  'name' => project_name,
556
- 'Env' => [
586
+ 'Env' => %w[
557
587
  "CONJUR_AUTHN_LOGIN=admin",
558
588
  "CONJUR_ENV=appliance",
559
589
  "CONJUR_AUTHN_API_KEY=SEcret12!!!!",
@@ -590,9 +620,9 @@ RUN touch /etc/service/conjur/down
590
620
 
591
621
  # Wait for pg/main so that migrations can run
592
622
  30.times do
593
- stdout, stderr, exitcode = container.exec %w(sv status pg/main), &DebugMixin::DOCKER
623
+ stdout, _, exitcode = container.exec %w(sv status pg/main), &DebugMixin::DOCKER
594
624
  status = stdout.join
595
- break if exitcode == 0 && status =~ /^run\:/
625
+ break if exitcode == 0 && status =~ /^run/
596
626
  sleep 1
597
627
  end
598
628
 
@@ -607,7 +637,7 @@ RUN touch /etc/service/conjur/down
607
637
 
608
638
  container_command container, "rm", "/etc/service/conjur/down"
609
639
  container_command container, "sv", "start", "conjur"
610
- wait_for_conjur appliance_image, container
640
+ wait_for_conjur container
611
641
 
612
642
  system "./#{test_script} #{container.id}"
613
643
  exit_now! "#{test_script} failed with exit code #{$?.exitstatus}", $?.exitstatus unless $?.exitstatus == 0
@@ -703,7 +733,7 @@ command "sandbox" do |c|
703
733
  'name' => "#{project_name}-sandbox",
704
734
  'Image' => appliance_image.id,
705
735
  'WorkingDir' => "/src/#{project_name}",
706
- 'Env' => [
736
+ 'Env' => %w[
707
737
  "CONJUR_AUTHN_LOGIN=admin",
708
738
  "CONJUR_ENV=appliance",
709
739
  "CONJUR_AUTHN_API_KEY=SEcret12!!!!",
@@ -746,7 +776,7 @@ command "sandbox" do |c|
746
776
  $stdout.puts container.id
747
777
  container.start!
748
778
 
749
- wait_for_conjur appliance_image, container
779
+ wait_for_conjur container
750
780
 
751
781
  if cmd_options[:'dev-install']
752
782
  container_command(container, "/opt/conjur/evoke/bin/dev-install", project_name)
@@ -798,10 +828,10 @@ command "publish" do |c|
798
828
  c.default_value "redhat-private"
799
829
  c.flag ['rpm-repo']
800
830
 
801
- c.action do |global_options, cmd_options, args|
831
+ c.action do |_, cmd_options, args|
802
832
  require 'conjur/debify/action/publish'
803
- raise "distribution is required" unless distribution = args.shift
804
- raise "project-name is required" unless project_name = args.shift
833
+ raise "distribution is required" unless (distribution = args.shift)
834
+ raise "project-name is required" unless (project_name = args.shift)
805
835
  raise "Received extra command-line arguments" if args.shift
806
836
 
807
837
  Conjur::Debify::Action::Publish.new(distribution, project_name, cmd_options).run
@@ -812,7 +842,7 @@ desc "Auto-detect and print the repository version"
812
842
  command "detect-version" do |c|
813
843
  c.desc "Set the current working directory"
814
844
  c.flag [:d, :dir]
815
- c.action do |global_options, cmd_options, args|
845
+ c.action do |_, cmd_options, args|
816
846
  raise "Received extra command-line arguments" if args.shift
817
847
 
818
848
  dir = cmd_options[:dir] || '.'
@@ -830,7 +860,7 @@ desc 'Show the given configuration'
830
860
  arg_name 'configuration'
831
861
  command 'config' do |c|
832
862
  c.action do |_, _, args|
833
- raise 'no configuration provided' unless config = args.shift
863
+ raise 'no configuration provided' unless (config = args.shift)
834
864
  raise "Received extra command-line arguments" if args.shift
835
865
 
836
866
  File.open(File.join('distrib', config)).each do |line|
@@ -838,25 +868,3 @@ command 'config' do |c|
838
868
  end
839
869
  end
840
870
  end
841
-
842
-
843
- pre do |global, command, options, args|
844
- # Pre logic here
845
- # Return true to proceed; false to abort and not call the
846
- # chosen command
847
- # Use skips_pre before a command to skip this block
848
- # on that command only
849
- true
850
- end
851
-
852
- post do |global, command, options, args|
853
- # Post logic here
854
- # Use skips_post before a command to skip this
855
- # block on that command only
856
- end
857
-
858
- on_error do |exception|
859
- # Error logic here
860
- # return false to skip default error handling
861
- true
862
- end
@@ -22,6 +22,10 @@ for i in "$@"; do
22
22
  file_type="${i#*=}"
23
23
  shift
24
24
  ;;
25
+ --architecture=*)
26
+ architecture="${i#*=}"
27
+ shift
28
+ ;;
25
29
  esac
26
30
  done
27
31
 
@@ -30,9 +34,15 @@ if [ -z "$file_type" ]; then
30
34
  file_type=deb
31
35
  fi
32
36
 
37
+ if [ -z "$architecture" ]; then
38
+ echo "No architecture given. Using amd64"
39
+ file_type=amd64
40
+ fi
41
+
33
42
  echo Project Name is $project_name
34
43
  echo Version is $version
35
44
  echo file_type is $file_type
45
+ echo architecture is $architecture
36
46
  echo params at the end are $@
37
47
 
38
48
  # Build dev package first
@@ -56,6 +66,7 @@ else
56
66
  fpm \
57
67
  -s dir \
58
68
  -t $file_type \
69
+ -a $architecture \
59
70
  -n conjur-$project_name-dev \
60
71
  -v $version \
61
72
  -C . \
@@ -91,6 +102,7 @@ echo "Building conjur-$project_name $file_type package"
91
102
  fpm \
92
103
  -s dir \
93
104
  -t $file_type \
105
+ -a $architecture \
94
106
  -n conjur-$project_name \
95
107
  -v $version \
96
108
  -C . \
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: conjur-debify
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.3.pre.1965
4
+ version: 3.0.3.pre.1971
5
5
  platform: ruby
6
6
  authors:
7
7
  - CyberArk Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-10-27 00:00:00.000000000 Z
11
+ date: 2023-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli