-
Notifications
You must be signed in to change notification settings - Fork 47
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
Support bzip2ed binaries like restic #117
Comments
The issue is within func (f *Filter) processBz2(name string, r io.Reader) (string, io.Reader, error) {
br := bzip2.NewReader(r)
return "", br, nil
} Compared with // processGz receives a tar.gz file and returns the
// correct file for bin to download
func (f *Filter) processGz(name string, r io.Reader) (string, io.Reader, error) {
gr, err := gzip.NewReader(r)
if err != nil {
return "", nil, err
}
return gr.Name, gr, nil
} Problem is now, that bzip2 library is very limited compared to gzip library: It does not implement the the Header struct. Therefore we don't get back the name without Just for testing I added following bad hack: func (f *Filter) processBz2(name string, r io.Reader) (string, io.Reader, error) {
br := bzip2.NewReader(r)
name = strings.Replace(name, ".bz2", "", -1)
return name, br, nil
} Voilà, it works: go run main.go install github.com/restic/restic
• Getting latest release for restic/restic
• Starting download of https://github.com/restic/restic/releases/download/v0.12.1/restic_0.12.1_linux_amd64.bz2
5.92 MiB / 5.92 MiB [-------------------------------------------------------------------------------------------------------] 100.00% 17.34 MiB p/s 1s
• Copying for [email protected] into /home/user/bin/restic
• Done installing restic v0.12.1 What do you think. Should we implement the replacing in the filename on our own or ask the go team to implement that in the bzip2 lib? |
bz2 works differently than gzip, that's why you don't have a header struct with the name. Seems like your fix should be the correct thing to do. Let me do a quick test and we can merge it. |
From the discussion in #81
I tried to install restic (https://github.com/restic/restic/releases/tag/v0.12.1) which is a bzip2ed binary. But I get following error:
So I wonder if bzip2ed binaries are not supported at the moment?
[snip]
marcosnils commented 6 minutes ago
The text was updated successfully, but these errors were encountered: