conjur-debify 1.11.5 → 1.12.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 58a50a072fd2700fa612ac0a6113f2a6227787ed67ac732767443dc26a6f9e72
4
- data.tar.gz: ba642699eb85c6506091ccdb8c82779a1f4daf9b5e00f45e071f910b889883e5
3
+ metadata.gz: 0b5fa10a6d866735c45f5edfd2a9defcc685ebe502c8950b219b6a8bc22ed232
4
+ data.tar.gz: 169e5c66e12fe3533c778255b337ad64b323f35cbc298f8e39c00e7abe765b7f
5
5
  SHA512:
6
- metadata.gz: 3674127fd6cc68ee9696f552edac2a089efe2c9ab6e1b0ac212ee78b4b282735e03ec65f15c7502592e2c31702a182756e6744c8a3bbc90a2e04b1c06ad6ffeb
7
- data.tar.gz: 31b3d6dd4a7c414ea09ea97e98ef1a56963d4724b4bd637fbd0379f7f53db0c9d0be22981a1de2de748aa8925a5b15d82b6551e4eb7b4edf6c68579c7f5b9d3b
6
+ metadata.gz: f9326cdb7fd4efafc3db3dda92e6a313cfc504dc34a24450be1076078cc8124b93c8f8ab781f59434cf625c4a37e2a1e8e6b1ead7466a7df00c2de7e3c3cca30
7
+ data.tar.gz: 8aae92edeacc8a8ffecaa7bbe4bf09cbb0a0f797b40c4cc8e52e4b9999cd7f607a58a913334e5f82cdcabfe07cc94ab2803bce65b3e99e0b84a0ed23d56824d6
data/.gitignore CHANGED
@@ -16,5 +16,6 @@ features/reports
16
16
  results.html
17
17
  mkmf.log
18
18
  *.deb
19
+ *.rpm
19
20
  *.gem
20
21
  docker-debify
@@ -1,3 +1,19 @@
1
+ ## [Unreleased]
2
+
3
+ # 1.12.0
4
+
5
+ ### Added
6
+ - Debify now packages and publishes an RPM file, alongside a debian file.
7
+ [conjurinc/debify#49](https://github.com/conjurinc/debify/pull/49)
8
+ - `debify package` now offers an `--additional-files` flag to provide a comma
9
+ separated list of files to include in the FPM build that are not provided
10
+ automatically by `git ls-files`.
11
+ [conjurinc/debify#52](https://github.com/conjurinc/debify/pull/52)
12
+
13
+ ### Fixed
14
+ - Bug causing `all` files in the git repo to be added to the debian file.
15
+ [conjurinc/debify#50](https://github.com/conjurinc/debify/pull/50)
16
+
1
17
  # 1.11.5
2
18
 
3
19
  ### Changed
@@ -66,7 +66,6 @@ pipeline {
66
66
  }
67
67
 
68
68
  stage('Publish to RubyGems') {
69
- agent { label 'releaser-v2' }
70
69
  when {
71
70
  allOf {
72
71
  branch 'master'
data/README.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Debify
2
2
 
3
+ Debify is a tool used for building and testing DAP appliance packages.
4
+ It is mainly used to package and publish debian packages that are consumed into the
5
+ appliance image in its build stage. However, it also packages and publishes an
6
+ RPM package whenever it does so for a debian.
7
+
3
8
  ## Installation
4
9
 
5
10
  There are two different ways of installing debify: as a gem, or as a Docker image.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.11.5
1
+ 1.12.0
@@ -6,8 +6,8 @@ require 'conjur/debify/version'
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = "conjur-debify"
8
8
  spec.version = Conjur::Debify::VERSION
9
- spec.authors = ["Kevin Gilpin"]
10
- spec.email = ["kgilpin@conjur.net"]
9
+ spec.authors = ["CyberArk Software, Inc."]
10
+ spec.email = ["conj_maintainers@cyberark.com"]
11
11
  spec.summary = %q{Utility commands to build and package Conjur services as Debian packages}
12
12
  spec.homepage = "https://github.com/conjurinc/debify"
13
13
  spec.license = "MIT"
@@ -2,16 +2,21 @@
2
2
  Feature: Packaging
3
3
 
4
4
  Background:
5
- Given I successfully run `env DEBUG=true GLI_DEBUG=true debify package -d ../../example -v 0.0.1 example -- --post-install /distrib/postinstall.sh`
5
+ # We use version 0.0.1-suffix to verify that RPM converts dashes to underscores
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`
6
8
 
7
9
  Scenario: 'example' project can be packaged successfully
8
- Then the stdout should contain "conjur-example_0.0.1_amd64.deb"
9
- And the stdout should contain "conjur-example-dev_0.0.1_amd64.deb"
10
+ Then the stdout should contain "conjur-example_0.0.1-suffix_amd64.deb"
11
+ And the stdout should contain "conjur-example-dev_0.0.1-suffix_amd64.deb"
12
+ And the stdout should contain "conjur-example-0.0.1_suffix-1.x86_64.rpm"
13
+ And the stdout should contain "conjur-example-dev-0.0.1_suffix-1.x86_64.rpm"
10
14
 
11
15
  Scenario: 'clean' command will delete non-Git-managed files
12
16
  When I successfully run `env DEBUG=true GLI_DEBUG=true debify clean -d ../../example --force`
13
17
  And I successfully run `find ../../example`
14
- Then the stdout from "find ../../example" should not contain "conjur-example_0.0.1_amd64.deb"
15
-
18
+ Then the stdout from "find ../../example" should not contain "conjur-example_0.0.1-suffix_amd64.deb"
19
+ And the stdout from "find ../../example" should not contain "conjur-example-0.0.1_suffix-1.x86_64.rpm"
20
+
16
21
  Scenario: 'example' project can be published
17
- When I successfully run `env DEBUG=true GLI_DEBUG=true debify publish -v 0.0.1 -d ../../example 4.9 example`
22
+ When I successfully run `env DEBUG=true GLI_DEBUG=true debify publish -v 0.0.1-suffix -d ../../example 4.9 example`
@@ -4,6 +4,7 @@ require 'fileutils'
4
4
  require 'gli'
5
5
  require 'json'
6
6
  require 'base64'
7
+ require 'tmpdir'
7
8
 
8
9
  require 'conjur/debify/utils'
9
10
 
@@ -196,6 +197,17 @@ command "clean" do |c|
196
197
  end
197
198
  end
198
199
 
200
+ def copy_packages_from_container(container, package_name, dev_package_name)
201
+ Conjur::Debify::Utils.copy_from_container container, "/src/#{package_name}"
202
+ puts "#{package_name}"
203
+ begin
204
+ Conjur::Debify::Utils.copy_from_container container, "/dev-pkg/#{dev_package_name}"
205
+ puts "#{dev_package_name}"
206
+ rescue Docker::Error::NotFoundError
207
+ warn "#{dev_package_name} not found. The package might not have any development dependencies."
208
+ end
209
+ end
210
+
199
211
  desc "Build a debian package for a project"
200
212
  long_desc <<DESC
201
213
  The package is built using fpm (https://github.com/jordansissel/fpm).
@@ -228,6 +240,9 @@ command "package" do |c|
228
240
  c.desc "Specify a custom Dockerfile.fpm"
229
241
  c.flag [ :dockerfile]
230
242
 
243
+ c.desc "Specify files to add to the FPM image that are not included from the git repo"
244
+ c.flag [ :'additional-files' ]
245
+
231
246
  c.action do |global_options,cmd_options,args|
232
247
  raise "project-name is required" unless project_name = args.shift
233
248
 
@@ -241,25 +256,41 @@ command "package" do |c|
241
256
  dir = cmd_options[:dir] || '.'
242
257
  pwd = File.dirname(__FILE__)
243
258
 
259
+ additional_files = []
260
+ if cmd_options[:'additional-files']
261
+ additional_files = cmd_options[:'additional-files'].split(',').map(&:strip)
262
+ end
263
+
244
264
  fpm_image = Docker::Image.build_from_dir File.expand_path('fpm', File.dirname(__FILE__)), tag: "debify-fpm", &DebugMixin::DOCKER
245
265
  DebugMixin.debug_write "Built base fpm image '#{fpm_image.id}'\n"
246
266
  dir = File.expand_path(dir)
267
+
247
268
  Dir.chdir dir do
248
269
  version = cmd_options[:version] || detect_version
249
- dockerfile_path = cmd_options[:dockerfile] || File.expand_path("debify/Dockerfile.fpm", pwd)
250
- dockerfile = File.read(dockerfile_path)
251
270
 
252
- output = StringIO.new
253
- Gem::Package::TarWriter.new(output) do |tar|
254
- git_files.each do |fname|
255
- stat = File.stat(fname)
256
- tar.add_file(fname, stat.mode) { |tar_file| tar_file.write(File.read(fname)) }
257
- end
258
- tar.add_file('Dockerfile', 0640) { |tar_file| tar_file.write dockerfile.gsub("@@image@@", fpm_image.id) }
271
+ # move git files and Dockerfile to temp dir to make deb from
272
+ # we do this to avoid adding "non-git" files
273
+ # that aren't mentioned in the dockerignore to the deb
274
+ temp_dir = Dir.mktmpdir
275
+ DebugMixin.debug_write "Copying git files to tmp dir '#{temp_dir}'\n"
276
+ (git_files + additional_files).each do |fname|
277
+ original_file = File.join(dir, fname)
278
+ destination_path = File.join(temp_dir, fname)
279
+ FileUtils.mkdir_p(File.dirname(destination_path))
280
+ FileUtils.cp(original_file, destination_path)
259
281
  end
260
- output.rewind
282
+
283
+ # rename specified dockerfile to 'Dockerfile' during copy, incase name is different
284
+ dockerfile_path = cmd_options[:dockerfile] || File.expand_path("debify/Dockerfile.fpm", pwd)
285
+ temp_dockerfile = File.join(temp_dir, "Dockerfile")
286
+
287
+ # change image variable in specified Dockerfile
288
+ dockerfile = File.read(dockerfile_path)
289
+ replace_image = dockerfile.gsub("@@image@@", fpm_image.id)
290
+ File.open(temp_dockerfile, "w") {|file| file.puts replace_image}
261
291
 
262
- image = Docker::Image.build_from_tar output, &DebugMixin::DOCKER
292
+ # build image from project being debified dir
293
+ image = Docker::Image.build_from_dir temp_dir, &DebugMixin::DOCKER
263
294
 
264
295
  DebugMixin.debug_write "Built fpm image '#{image.id}' for project #{project_name}\n"
265
296
 
@@ -276,16 +307,21 @@ command "package" do |c|
276
307
  status = container.wait
277
308
  raise "Failed to package #{project_name}" unless status['StatusCode'] == 0
278
309
 
279
- pkg = "conjur-#{project_name}_#{version}_amd64.deb"
280
- dev_pkg = "conjur-#{project_name}-dev_#{version}_amd64.deb"
281
- Conjur::Debify::Utils.copy_from_container container, "/src/#{pkg}"
282
- puts "#{pkg}"
283
- begin
284
- Conjur::Debify::Utils.copy_from_container container, "/dev-pkg/#{dev_pkg}"
285
- puts "#{dev_pkg}"
286
- rescue Docker::Error::NotFoundError
287
- warn "#{dev_pkg} not found. The package might not have any development dependencies."
288
- end
310
+ # Copy deb packages
311
+ copy_packages_from_container(
312
+ container,
313
+ "conjur-#{project_name}_#{version}_amd64.deb",
314
+ "conjur-#{project_name}-dev_#{version}_amd64.deb"
315
+ )
316
+
317
+ # Copy rpm packages
318
+ # The rpm builder replaces dashes with underscores in the version
319
+ rpm_version = version.tr('-', '_')
320
+ copy_packages_from_container(
321
+ container,
322
+ "conjur-#{project_name}-#{rpm_version}-1.x86_64.rpm",
323
+ "conjur-#{project_name}-dev-#{rpm_version}-1.x86_64.rpm"
324
+ )
289
325
  ensure
290
326
  container.delete(force: true)
291
327
  end
@@ -309,7 +345,7 @@ end
309
345
  def network_options(cmd)
310
346
  cmd.desc "Specify link for test container"
311
347
  cmd.flag [ :l, :link ], :multiple => true
312
-
348
+
313
349
  cmd.desc 'Attach to the specified network'
314
350
  cmd.flag [ :n, :net ]
315
351
  end
@@ -401,7 +437,7 @@ command "test" do |c|
401
437
  c.flag [ :'volumes-from' ], :multiple => true
402
438
 
403
439
  network_options(c)
404
-
440
+
405
441
  c.action do |global_options,cmd_options,args|
406
442
  raise "project-name is required" unless project_name = args.shift
407
443
  raise "test-script is required" unless test_script = args.shift
@@ -488,12 +524,12 @@ RUN touch /etc/service/conjur/down
488
524
  }
489
525
  }
490
526
  host_config = options['HostConfig']
491
-
527
+
492
528
  host_config['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
493
529
  host_config['VolumesFrom'] = cmd_options[:'volumes-from'] if cmd_options[:'volumes-from'] && !cmd_options[:'volumes-from'].empty?
494
530
 
495
531
  add_network_config(options, cmd_options)
496
-
532
+
497
533
  if global_options[:'local-bundle']
498
534
  host_config['Binds']
499
535
  .push([ vendor_dir, "/src/#{project_name}/vendor" ].join(':'))
@@ -590,7 +626,7 @@ command "sandbox" do |c|
590
626
 
591
627
  c.desc 'A command to run in the sandbox'
592
628
  c.flag [ :c, :command ]
593
-
629
+
594
630
  c.action do |global_options,cmd_options,args|
595
631
  raise "Received extra command-line arguments" if args.shift
596
632
 
@@ -647,7 +683,7 @@ command "sandbox" do |c|
647
683
 
648
684
  host_config['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
649
685
  host_config['VolumesFrom'] = cmd_options[:'volumes-from'] unless cmd_options[:'volumes-from'].empty?
650
-
686
+
651
687
  add_network_config(options, cmd_options)
652
688
 
653
689
  unless cmd_options[:port].empty?
@@ -716,6 +752,10 @@ command "publish" do |c|
716
752
  c.default_value "debian-private"
717
753
  c.flag [ :r, :repo]
718
754
 
755
+ c.desc "Artifactory RPM repo to publish package to"
756
+ c.default_value "redhat-private"
757
+ c.flag ['rpm-repo']
758
+
719
759
  c.action do |global_options,cmd_options,args|
720
760
  require 'conjur/debify/action/publish'
721
761
  raise "distribution is required" unless distribution = args.shift
@@ -25,14 +25,12 @@ module Conjur::Debify
25
25
 
26
26
  Dir.chdir dir do
27
27
  version = cmd_options[:version] || detect_version
28
- component = cmd_options[:component] || detect_component
29
- package_name = "conjur-#{project_name}_#{version}_amd64.deb"
30
28
 
31
29
  publish_image = create_image
32
30
  DebugMixin.debug_write "Built base publish image '#{publish_image.id}'\n"
33
31
 
34
32
  art_url = cmd_options[:url]
35
- art_repo = cmd_options[:repo]
33
+ deb_art_repo = cmd_options[:repo]
36
34
 
37
35
  art_user = ENV['ARTIFACTORY_USER']
38
36
  art_password = ENV['ARTIFACTORY_PASSWORD']
@@ -40,23 +38,35 @@ module Conjur::Debify
40
38
  art_user, art_password = fetch_art_creds
41
39
  end
42
40
 
43
- options = {
44
- 'Image' => publish_image.id,
45
- 'Cmd' => [
46
- "jfrog", "rt", "upload",
47
- "--url", art_url,
48
- "--user", art_user,
49
- "--password", art_password,
50
- "--deb", "#{distribution}/#{component}/amd64",
51
- package_name, "#{art_repo}/"
52
- ],
53
- 'Binds' => [
54
- [ dir, "/src" ].join(':')
55
- ]
56
- }
57
- options['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
58
-
59
- publish(options)
41
+ # Publish deb package
42
+ component = cmd_options[:component] || detect_component
43
+ deb_info = "#{distribution}/#{component}/amd64"
44
+ package_name = "conjur-#{project_name}_#{version}_amd64.deb"
45
+ publish_package(
46
+ publish_image: publish_image,
47
+ art_url: art_url,
48
+ art_user: art_user,
49
+ art_password: art_password,
50
+ art_repo: deb_art_repo,
51
+ package_name: package_name,
52
+ dir: dir,
53
+ deb_info: deb_info
54
+ )
55
+
56
+ # Publish RPM package
57
+ # The rpm builder replaces dashes with underscores in the version
58
+ rpm_version = version.tr('-', '_')
59
+ package_name = "conjur-#{project_name}-#{rpm_version}-1.x86_64.rpm"
60
+ rpm_art_repo = cmd_options['rpm-repo']
61
+ publish_package(
62
+ publish_image: publish_image,
63
+ art_url: art_url,
64
+ art_user: art_user,
65
+ art_password: art_password,
66
+ art_repo: rpm_art_repo,
67
+ package_name: package_name,
68
+ dir: dir
69
+ )
60
70
  end
61
71
  end
62
72
 
@@ -77,6 +87,39 @@ module Conjur::Debify
77
87
  [conjur.resource(username_var).value, conjur.resource(password_var).value]
78
88
  end
79
89
 
90
+ def publish_package(
91
+ publish_image:,
92
+ art_url:,
93
+ art_user:,
94
+ art_password:,
95
+ art_repo:,
96
+ package_name:,
97
+ dir:,
98
+ deb_info: nil
99
+ )
100
+
101
+ cmd_args = [
102
+ "jfrog", "rt", "upload",
103
+ "--url", art_url,
104
+ "--user", art_user,
105
+ "--password", art_password,
106
+ ]
107
+
108
+ cmd_args += ["--deb", deb_info] if deb_info
109
+ cmd_args += [package_name, "#{art_repo}/"]
110
+
111
+ options = {
112
+ 'Image' => publish_image.id,
113
+ 'Cmd' => cmd_args,
114
+ 'Binds' => [
115
+ [ dir, "/src" ].join(':')
116
+ ]
117
+ }
118
+ options['Privileged'] = true if Docker.version['Version'] >= '1.10.0'
119
+
120
+ publish(options)
121
+ end
122
+
80
123
  def publish(options)
81
124
  container = Docker::Container.create(options)
82
125
  begin
@@ -5,7 +5,8 @@ RUN apt-get update -y && \
5
5
  apt-get dist-upgrade -y && \
6
6
  apt-get install -y build-essential \
7
7
  git \
8
- libffi-dev
8
+ libffi-dev \
9
+ rpm
9
10
 
10
11
  RUN gem install --no-document bundler:1.17.3 \
11
12
  fpm
@@ -16,11 +16,7 @@ if [ -z "$version" ]; then
16
16
  exit 1
17
17
  fi
18
18
 
19
- package_name=conjur-"$project_name"_"$version"_amd64.deb
20
- dev_package_name=conjur-"$project_name"-dev_"$version"_amd64.deb
21
-
22
19
  # Build dev package first
23
- echo Building $dev_package_name
24
20
  prefix=/src/opt/conjur/project
25
21
  cp -al $prefix /dev-pkg
26
22
  cd $prefix
@@ -34,21 +30,29 @@ bundle_clean
34
30
  if [ `ls | wc -l` -eq 0 ]; then
35
31
  echo No dev dependencies, skipping dev package
36
32
  else
37
- fpm -s dir -t deb -n conjur-$project_name-dev -v $version -C . \
38
- --maintainer "Conjur Inc." \
39
- --vendor "Conjur Inc." \
33
+ for file_type in deb rpm
34
+ do
35
+ echo "Building conjur-$project_name-dev $file_type package"
36
+
37
+ fpm \
38
+ -s dir \
39
+ -t $file_type \
40
+ -n conjur-$project_name-dev \
41
+ -v $version \
42
+ -C . \
43
+ --maintainer "CyberArk Software, Inc." \
44
+ --vendor "CyberArk Software, Inc." \
40
45
  --license "Proprietary" \
41
- --url "https://www.conjur.net" \
46
+ --url "https://www.cyberark.com" \
42
47
  --deb-no-default-config-files \
43
- --deb-user conjur \
44
- --deb-group conjur \
48
+ --$file_type-user conjur \
49
+ --$file_type-group conjur \
45
50
  --depends "conjur-$project_name = $version" \
46
51
  --prefix /opt/conjur/$project_name \
47
52
  --description "Conjur $project_name service - development files"
53
+ done
48
54
  fi
49
55
 
50
- echo Building $package_name
51
-
52
56
  mv /src/opt/conjur/project /src/opt/conjur/$project_name
53
57
 
54
58
  cd /src/opt/conjur/$project_name
@@ -63,16 +67,26 @@ mkdir -p opt/conjur/etc
63
67
 
64
68
  [ -d opt/conjur/"$project_name"/distrib ] && mv opt/conjur/"$project_name"/distrib /
65
69
 
66
- fpm -s dir -t deb -n conjur-$project_name -v $version -C . \
67
- --maintainer "Conjur Inc." \
68
- --vendor "Conjur Inc." \
70
+ for file_type in deb rpm
71
+ do
72
+ echo "Building conjur-$project_name-dev $file_type package"
73
+
74
+ fpm \
75
+ -s dir \
76
+ -t $file_type \
77
+ -n conjur-$project_name \
78
+ -v $version \
79
+ -C . \
80
+ --maintainer "CyberArk Software, Inc." \
81
+ --vendor "CyberArk Software, Inc." \
69
82
  --license "Proprietary" \
70
- --url "https://www.conjur.net" \
71
- --deb-no-default-config-files \
83
+ --url "https://www.cyberark.com" \
72
84
  --config-files opt/conjur/etc \
73
- --deb-user conjur \
74
- --deb-group conjur \
85
+ --deb-no-default-config-files \
86
+ --$file_type-user conjur \
87
+ --$file_type-group conjur \
75
88
  --description "Conjur $project_name service" \
76
89
  "$@"
90
+ done
77
91
 
78
- ls -al *.deb
92
+ ls -al *.{deb,rpm}
@@ -31,8 +31,8 @@ describe Conjur::Debify::Action::Publish do
31
31
  end
32
32
 
33
33
  it 'runs' do
34
- expect(action).to receive(:publish)
35
-
34
+ expect(action).to receive(:publish).twice
35
+
36
36
  action.run
37
37
  end
38
38
 
@@ -42,8 +42,8 @@ describe Conjur::Debify::Action::Publish do
42
42
 
43
43
  it 'runs' do
44
44
  expect(action).to receive(:fetch_art_creds)
45
- expect(action).to receive(:publish)
46
-
45
+ expect(action).to receive(:publish).twice
46
+
47
47
  action.run
48
48
  end
49
49
  end
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: 1.11.5
4
+ version: 1.12.0
5
5
  platform: ruby
6
6
  authors:
7
- - Kevin Gilpin
7
+ - CyberArk Software, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-14 00:00:00.000000000 Z
11
+ date: 2020-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gli
@@ -166,7 +166,7 @@ dependencies:
166
166
  version: '1.0'
167
167
  description:
168
168
  email:
169
- - kgilpin@conjur.net
169
+ - conj_maintainers@cyberark.com
170
170
  executables:
171
171
  - debify
172
172
  extensions: []