Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/989 add zstandard support #1002

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions deb/deb.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,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
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,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/mattn/go-colorable v0.1.2 h1:/bC9yWikZXAL9uJdulbSfyVNIR3n3trXl+v8+1sx8mU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-isatty v0.0.8 h1:HLtExJ+uU2HOZ+wI0Tt5DtUDrx8yhUqDcp7fYERX4CE=
Expand Down