Skip to content

Commit

Permalink
Try have the srpm match the output file name
Browse files Browse the repository at this point in the history
This is for cases like `fpm -p hello.rpm` and it seems like we'd want
the srpm named "hello.src.rpm" instead of whatever was generated by
rpmbuild. I don't know if this will make things less confusing, but I
hope it will make things more predictable :)
  • Loading branch information
jordansissel committed Nov 7, 2022
1 parent 1dc076b commit d1a9ef6
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion lib/fpm/package/rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -580,7 +580,29 @@ def output(output_path)

# Copy out the SRPM packages
::Dir["#{build_path}/SRPMS/**/*.rpm"].each do |rpmpath|
FileUtils.cp(rpmpath, File.dirname(output_path))
# Try to use the same naming scheme if we are specifying a custom output path?
# Replace the .ARCH.EXTENSION with .src.EXTENSION ?
#
# For example, if the output wanted "foo.noarch.rpm"
# then the srpm should be named "foo.src.rpm"
#
# But for the cases where someone asked for a file with just ".rpm" at the end,
# we can also write the srpm as ".src.rpm"
extension_checks = [
# Try .<arch>.rpm ending
Regexp.compile(to_s(".ARCH.EXTENSION$")),
# Try just .rpm ending
Regexp.compile(to_s(".EXTENSION$"))
]

extension_checks.each do |re|
if output_path =~ re
filename = File.basename(output_path).gsub(re, to_s(".src.EXTENSION"))
p [ "Copying", rpmpath => filename ]
FileUtils.cp(rpmpath, File.join(File.dirname(output_path), filename))
break
end
end
end
end # def output

Expand Down

0 comments on commit d1a9ef6

Please sign in to comment.