Skip to content

Commit

Permalink
Add package_name_format field to recipe
Browse files Browse the repository at this point in the history
Setting the field to a format string value changes the filename of the
created package. If unset, FPM chooses its default format.

See the following code section for available format strings:
https://github.com/jordansissel/fpm/blob/c40f6818f88a6dd3df7bc19b6007b03a716949f8/lib/fpm/package.rb#L355-L365

Fixes #210
  • Loading branch information
bernd committed Jul 13, 2022
1 parent deb1df8 commit dac4928
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions lib/fpm/cookery/packager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,19 @@ def build_package(recipe, config)

output = input.convert(output_class)

output_filename = output.to_s(recipe.package_name_format)
recipe.run_lifecycle_hook(:before_package_create, output)
begin
output.output(output.to_s)
output.output(output_filename)
recipe.run_lifecycle_hook(:after_package_create, output)
rescue FPM::Package::FileAlreadyExists
Log.info "Removing existing package file: #{output.to_s}"
FileUtils.rm_f(output.to_s)
Log.info "Removing existing package file: #{output_filename}"
FileUtils.rm_f(output_filename)
retry
ensure
input.cleanup if input
output.cleanup if output
Log.info "Created package: #{File.join(Dir.pwd, output.to_s)}"
Log.info "Created package: #{File.join(Dir.pwd, output_filename)}"
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion lib/fpm/cookery/recipe.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class BaseRecipe
:pre_install, :post_install, :pre_uninstall, :post_uninstall,
:license, :omnibus_package, :omnibus_dir, :chain_package,
:default_prefix, :docker, :docker_image, :dockerfile,
:epoch
:package_name_format, :epoch

attr_rw_list :build_depends, :config_files, :conflicts, :depends,
:exclude, :patches, :provides, :replaces, :omnibus_recipes,
Expand Down

0 comments on commit dac4928

Please sign in to comment.