Add support for zst compression

This commit is contained in:
Matt Bearup
2022-03-22 20:20:42 +00:00
committed by Benj Fassbind
parent c46f12f0d6
commit 5a23f71a7f
3 changed files with 18 additions and 0 deletions

View File

@@ -16,6 +16,7 @@ import (
"github.com/aptly-dev/aptly/pgp"
"github.com/kjk/lzma"
"github.com/klauspost/compress/zstd"
"github.com/smira/go-xz"
)
@@ -74,6 +75,13 @@ func GetControlFileFromDeb(packageFile string) (Stanza, error) {
}
defer unxz.Close()
tarInput = unxz
case "control.tar.zst":
unzstd, err := zstd.NewReader(bufReader)
if err != nil {
return nil, errors.Wrapf(err, "unable to unzstd %s from %s", header.Name, packageFile)
}
defer unzstd.Close()
tarInput = unzstd
default:
return nil, fmt.Errorf("unsupported tar compression in %s: %s", packageFile, header.Name)
}
@@ -189,6 +197,13 @@ func GetContentsFromDeb(file io.Reader, packageFile string) ([]string, error) {
unlzma := lzma.NewReader(bufReader)
defer unlzma.Close()
tarInput = unlzma
case "data.tar.zst":
unzstd, err := zstd.NewReader(bufReader)
if err != nil {
return nil, errors.Wrapf(err, "unable to unzstd %s from %s", header.Name, packageFile)
}
defer unzstd.Close()
tarInput = unzstd
default:
return nil, fmt.Errorf("unsupported tar compression in %s: %s", packageFile, header.Name)
}

1
go.mod
View File

@@ -16,6 +16,7 @@ require (
github.com/h2non/filetype v1.0.5
github.com/jlaffaye/ftp v0.0.0-20180404123514-2403248fa8cc // indirect
github.com/kjk/lzma v0.0.0-20161016003348-3fd93898850d
github.com/klauspost/compress v1.13.6
github.com/mattn/go-colorable v0.1.2 // indirect
github.com/mattn/go-runewidth v0.0.2 // indirect
github.com/mattn/go-shellwords v1.0.2

2
go.sum
View File

@@ -52,6 +52,8 @@ github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5i
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/kjk/lzma v0.0.0-20161016003348-3fd93898850d h1:RnWZeH8N8KXfbwMTex/KKMYMj0FJRCF6tQubUuQ02GM=
github.com/kjk/lzma v0.0.0-20161016003348-3fd93898850d/go.mod h1:phT/jsRPBAEqjAibu1BurrabCBNTYiVI+zbmyCZJY6Q=
github.com/klauspost/compress v1.13.6 h1:P76CopJELS0TiO2mebmnzgWaajssP/EszplttgQxcgc=
github.com/klauspost/compress v1.13.6/go.mod h1:/3/Vjq9QcHkK5uEr5lBEmyoZ1iFhe47etQ6QUkpK6sk=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=
github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE=
github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI=