Skip to content

Commit

Permalink
Add a new --rpm-compression-level option which addresses issue 1675:
Browse files Browse the repository at this point in the history
    #1675

The value can be a number from 0 to 9 inclusive. The default mirrors
the current behavior of 9. If the --rpm-compression value is set to
"none", this value is ignored.

Setting the value to 5 sped up RPM creation on my RPM from 9 to
3 minutes.
  • Loading branch information
Jeff Solomon authored and jordansissel committed Mar 8, 2020
1 parent 8a40cd1 commit b1e956e
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions lib/fpm/package/rpm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ class FPM::Package::RPM < FPM::Package

COMPRESSION_MAP = {
"none" => "w0.gzdio",
"xz" => "w9.xzdio",
"xzmt" => "w9T.xzdio",
"gzip" => "w9.gzdio",
"bzip2" => "w9.bzdio"
"xz" => ".xzdio",
"xzmt" => "T.xzdio",
"gzip" => ".gzdio",
"bzip2" => ".bzdio"
} unless defined?(COMPRESSION_MAP)

option "--use-file-permissions", :flag,
Expand Down Expand Up @@ -68,6 +68,15 @@ class FPM::Package::RPM < FPM::Package
value.downcase
end

option "--compression-level", "[0-9]", "Select a compression level. 0 is store-only. 9 is max compression.",
:default => "9" do |value|
valint = value.to_i
unless value =~ /^\d$/ && valint >= 0 && valint <= 9
raise "Invalid compression level '#{value}'. Valid values are integers between 0 and 9 inclusive."
end
valint
end

option "--compression", COMPRESSION_MAP.keys.join("|"),
"Select a compression method. gzip works on the most platforms.",
:default => "gzip" do |value|
Expand Down Expand Up @@ -602,7 +611,12 @@ def to_s(format=nil)
end # def to_s

def payload_compression
return COMPRESSION_MAP[attributes[:rpm_compression]]
if attributes[:rpm_compression] == 'none'
# when 'none' ignore any compression level and return w0.gzdio
return COMPRESSION_MAP[attributes[:rpm_compression]]
else
return "w#{attributes[:rpm_compression_level]}" + COMPRESSION_MAP[attributes[:rpm_compression]]
end
end # def payload_compression

def digest_algorithm
Expand Down

0 comments on commit b1e956e

Please sign in to comment.