Skip to content

Conversation

@domwst
Copy link

@domwst domwst commented Nov 25, 2025

(Hopefully) fixes #2127

@NicholasBHubbard
Copy link
Contributor

Thanks for the PR! In this comment on issue #2127 I reproduced the problem of higher compression levels leading to larger packages. This PR does fix that problem:

$ git log -1 --oneline
8150c59 (HEAD -> domwst/main) Fix zstd compression level handling
$ bundle exec bin/fpm -s python -t deb --deb-compression=zst --deb-compression-level=3 django
Created package {path: "python-django_5.2.8_all.deb"}
$ stat -c %s python-django_5.2.8_all.deb
6991954
$ rm python-django_5.2.8_all.deb
$ bundle exec bin/fpm -s python -t deb --deb-compression=zst --deb-compression-level=9 django
Created package {path: "python-django_5.2.8_all.deb"}
$ stat -c %s python-django_5.2.8_all.deb
5992540

Issue #2127 mentions that values 0-19 are valid zstd compression levels, but fpm only allows values 0-9 for the --deb-compression flag. This problem is not addressed in this PR.

@domwst
Copy link
Author

domwst commented Nov 27, 2025

Yeah, it's kind of fixed by the environment variable ZSTD_CLEVEL which allows to pass an arbitrary compression level. I can try to find out how to broaden --deb-compression range for zstd compression, but it will take some time.

@NicholasBHubbard
Copy link
Contributor

Ah yes, I see that the ZSTD_CLEVEL env var could be used to pass an arbitrary compression level.

Something like the following (UNTESTED) update could be used to broaden the --deb-compression flag:

  option "--compression-level", "[0-9]", "Select a compression level. 0 is none or minimal. 9 is max compression.",
    # Specify which compression level to use on the compressor backend, when building a package
    :default => nil do |value|
    valint = value.to_i
    max_compression = 9
    if self.attributes[:deb_compression] == "zst"
      max_compression = 19
    end
    unless value =~ /^\d$/ && valint >= 0 && valint <= max_compression
      raise "Invalid compression level '#{value}'. Valid values are integers between 0 and #{max_compression} inclusive."
    end
    valint
  end

Do any of the other available compression types allow levels outside the range 0-9?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

deb: ZSTD_CLEVEL is set to negative values when using --deb-compression=zst

2 participants