Skip to content

Commit 69d71dd

Browse files
committed
Refactor to shrink lines of code
This reduces the lines of code used to generate the source tarball.
1 parent fdbf1f6 commit 69d71dd

File tree

1 file changed

+9
-25
lines changed

1 file changed

+9
-25
lines changed

lib/fpm/package/rpm.rb

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -548,32 +548,16 @@ def output(output_path)
548548

549549
args += ["--define", "_builddir #{staging_path}"]
550550

551-
# Got to create a tarball to include in the SRPM
552-
sources_tar = "#{name}-#{version}-#{iteration}.tgz"
553-
554-
::Dir.chdir(build_path) do
555-
::Dir.chdir(build_sub_dir) do
556-
to_tar = ::Dir['*']
557-
558-
unless to_tar.empty?
559-
# If we have rpmbuild, we have tar, so just use it!
560-
tar_cmd = [
561-
'tar',
562-
'-cz',
563-
'-f',
564-
File.join(build_path, sources_sub_dir, sources_tar),
565-
to_tar
566-
].flatten
567-
568-
safesystem(*tar_cmd)
569-
end
570-
end
571-
end
572-
551+
# If there are files in the staging path, put them in a tarball so we can
552+
# produce an srpm.
573553
sources = []
574-
::Dir.chdir(File.join(build_path, sources_sub_dir)) do
575-
sources = ::Dir['**/*']
576-
sources.delete_if{|f| !File.file?(f)}
554+
if !::Dir.empty?(staging_path)
555+
# Got to create a tarball to include in the SRPM
556+
sources_tar = "#{name}-#{version}-#{iteration}.tgz"
557+
tarpath = File.join(build_path, sources_sub_dir, sources_tar)
558+
safesystem("tar", "-zcf", tarpath, "-C", staging_path, ".")
559+
560+
sources << tarpath
577561
end
578562

579563
rpmspec = template("rpm.erb").result(binding)

0 commit comments

Comments
 (0)