-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Description
fpm 1.17.0 appears to be setting the ZSTD_CLEVEL environment variable to negative values whenever --output-type=deb --deb-compression=zst is specified.
The ZSTD_CLEVEL environment variable is documented as being an integer between 1 and 19 inclusive. Despite the docs, zstd doesn't appear to raise an error if negative values are used here; negative values seem to enable its 'fast' compression levels, and using ZSTD_CLEVEL=0 sets the compression to the default level.
I suspect the issue lies in deb.rb; note the leading - for the ZSTD_CLEVEL value. This has the perverse effect of making, say, --deb-compression-level=9 generate a larger Debian package than --deb-compression-level=3.
https://github.com/jordansissel/fpm/blob/v1.17.0/lib/fpm/package/deb.rb#L698
when "zst"
datatar = build_path("data.tar.zst")
controltar = build_path("control.tar.zst")
compression_flags = ["--use-compress-program", "zstd"]
compressor_options = {"ZSTD_CLEVEL" => "-#{self.attributes[:deb_compression_level] || 3}"}
Further, --deb-compression-level currently restricts the permitted values to 0 to 9 (inclusive), even when using --deb-compression=zst. Passing --deb-compression-level=19 to fpm ought to succeed, but will instead raise an error: Invalid compression level '19'. Valid values are integers between 0 and 9 inclusive.
Tested on Ubuntu 22.04.
$ zstd --version
*** zstd command line interface 64-bits v1.4.8, by Yann Collet ***
$ fpm --version
1.17.0
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04.5 LTS"