Skip to content

Commit

Permalink
Merge pull request #52 from conjurinc/additional-files-flag
Browse files Browse the repository at this point in the history
Additional files flag
  • Loading branch information
micahlee authored Nov 17, 2020
2 parents 098d0a9 + 243967f commit 046eb12
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
## [Unreleased]

# 1.12.0

### Added
- Debify now packages and publishes an RPM file, alongside a debian file.
[conjurinc/debify#49](https://github.com/conjurinc/debify/pull/49)
- `debify package` now offers an `--additional-files` flag to provide a comma
separated list of files to include in the FPM build that are not provided
automatically by `git ls-files`.
[conjurinc/debify#52](https://github.com/conjurinc/debify/pull/52)

### Fixed
- Bug causing `all` files in the git repo to be added to the debian file.
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.5
1.12.0
11 changes: 10 additions & 1 deletion lib/conjur/debify.rb
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ def copy_packages_from_container(container, package_name, dev_package_name)
c.desc "Specify a custom Dockerfile.fpm"
c.flag [ :dockerfile]

c.desc "Specify files to add to the FPM image that are not included from the git repo"
c.flag [ :'additional-files' ]

c.action do |global_options,cmd_options,args|
raise "project-name is required" unless project_name = args.shift

Expand All @@ -253,6 +256,11 @@ def copy_packages_from_container(container, package_name, dev_package_name)
dir = cmd_options[:dir] || '.'
pwd = File.dirname(__FILE__)

additional_files = []
if cmd_options[:'additional-files']
additional_files = cmd_options[:'additional-files'].split(',').map(&:strip)
end

fpm_image = Docker::Image.build_from_dir File.expand_path('fpm', File.dirname(__FILE__)), tag: "debify-fpm", &DebugMixin::DOCKER
DebugMixin.debug_write "Built base fpm image '#{fpm_image.id}'\n"
dir = File.expand_path(dir)
Expand All @@ -265,12 +273,13 @@ def copy_packages_from_container(container, package_name, dev_package_name)
# that aren't mentioned in the dockerignore to the deb
temp_dir = Dir.mktmpdir
DebugMixin.debug_write "Copying git files to tmp dir '#{temp_dir}'\n"
git_files.each do |fname|
(git_files + additional_files).each do |fname|
original_file = File.join(dir, fname)
destination_path = File.join(temp_dir, fname)
FileUtils.mkdir_p(File.dirname(destination_path))
FileUtils.cp(original_file, destination_path)
end

# rename specified dockerfile to 'Dockerfile' during copy, incase name is different
dockerfile_path = cmd_options[:dockerfile] || File.expand_path("debify/Dockerfile.fpm", pwd)
temp_dockerfile = File.join(temp_dir, "Dockerfile")
Expand Down

0 comments on commit 046eb12

Please sign in to comment.