incusd/images: Support reproducible pigz output

Signed-off-by: René Jochum <rene@jochum.dev>
This commit is contained in:
René Jochum 2026-07-29 20:58:05 -04:00 committed by Stéphane Graber
parent cfc23dc647
commit 571befc069
No known key found for this signature in database
GPG Key ID: C638974D64792D67

View File

@ -133,7 +133,12 @@ var imagePublishLock sync.Mutex
var imageTaskMu sync.Mutex
func compressFile(compress string, infile io.Reader, outfile io.Writer) error {
reproducible := []string{"gzip"}
// Compressors with reproducible output and the flags needed for it.
reproducible := map[string][]string{
"gzip": {"-n"},
"pigz": {"-n", "-m"},
}
var cmd *exec.Cmd
// Parse the command.
@ -183,8 +188,9 @@ func compressFile(compress string, infile io.Reader, outfile io.Writer) error {
args = append(args, fields[1:]...)
}
if slices.Contains(reproducible, fields[0]) {
args = append(args, "-n")
flags, ok := reproducible[fields[0]]
if ok {
args = append(args, flags...)
}
cmd := exec.Command(fields[0], args...)