flatpak / flatpak-builder

Tool to build flatpaks from source
GNU Lesser General Public License v2.1
141 stars 93 forks source link

tar.gz Not Recognized as Gzip #600

Closed clseibold closed 6 months ago

clseibold commented 6 months ago

Checklist

flatpak-builder version

1.4.1

Flatpak version

1.15.8

How to reproduce

I'm using this archive as a source for a module: http://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-1.0.4.tar.gz

Expected Behavior

It should untar the archive

Actual Behavior

I'm getting this error:

FB: Running: git config --get user.email
FB: Running: git config --get user.name
Emptying app dir 'build-dir'
FB: Running: flatpak info --arch=x86_64 --show-commit org.freedesktop.Sdk 23.08
FB: Running: flatpak info --show-location --arch=x86_64 org.freedesktop.Sdk 23.08
FB: Running: flatpak info --arch=x86_64 --show-commit org.freedesktop.Platform 23.08
Downloading sources
Starting build of us.to.scrollprotocol.Profectus
Cache miss, checking out last cache hit
FB: Mounting read-only fs: rofiles-fuse /home/clseibold/Dev/profectus/build-dir /home/clseibold/Dev/profectus/.flatpak-builder/rofiles/rofiles-l3eSJx
========================================================================
Building module sdl2-gfx in /home/clseibold/Dev/profectus/.flatpak-builder/build/sdl2-gfx-7
========================================================================
FB: Running: tar xf /home/clseibold/Dev/profectus/.flatpak-builder/downloads/8b5048f99c006f3d3e53d1a049576a789dec2f5683157e36849bbc5c878778fc/SDL2_gfx-1.0.4.tar.gz --no-same-owner --strip-components=0 -z

gzip: stdin: not in gzip format
tar: Child returned status 1
tar: Error is not recoverable: exiting now
Error: module sdl2-gfx: Child process exited with code 2
FB: Unmounting read-only fs: fusermount -uz /home/clseibold/Dev/profectus/.flatpak-builder/rofiles/rofiles-l3eSJx

Additional Information

Here's the output of using the file command on the archive:

flatpaksources/SDL2_gfx-1.0.4.tar.gz: gzip compressed data, was "SDL2_gfx-1.0.4.tar", last modified: Sat Feb 24 05:36:39 2018, max compression, from FAT filesystem (MS-DOS, OS/2, NT), original size modulo 2^32 7728128
TingPing commented 6 months ago

The server hosting it is broken, pick a different mirror or set disable-http-decompression: true on the source.

clseibold commented 6 months ago

The server hosting it is broken

@TingPing No it's not. I can download the file just fine in a browser and open it just fine in Fedora KDE's Ark. I believe the problem is that the tarfile was created on a Windows system.

What a mystifying response...

TingPing commented 6 months ago

This project uses libcurl, your browser does not, they implement HTTP differently.

> curl -v https://www.ferzkopp.net/Software/SDL2_gfx/SDL2_gfx-1.0.4.tar.gz

...

< content-encoding: x-gzip

...

The server gives the wrong response. Another mirror works or enable the option to ignore the content-encoding.

clseibold commented 6 months ago

@TingPing It's a gzip file. What about the content encoding is incorrect?

TingPing commented 6 months ago

https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Encoding

This lets the recipient know how to decode the representation in order to obtain the original payload format.

So what libcurl does is ungzip the tar.gz, so the download becomes just a tar but has the filename tar.gz. gzip then errors when run on the tar file.

clseibold commented 6 months ago

x-gzip is a valid content-encoding as far as I'm aware, it's just historical.

clseibold commented 6 months ago

So what libcurl does is ungzip the tar.gz, so the download becomes just a tar but has the filename tar.gz. gzip then errors when run on the tar file.

Ok, thanks. Btw, this should have been the very first thing you mention in your first response to this issue.

TingPing commented 6 months ago

Yes it's totally valid, curl respects it and ungzips the file.

I assume browsers just have a

if content_encoding == 'x-gzip' and filename.endswith('tar.gz'):
   # The server is probably wrong don't ungzip

I guess we could do similar.

TingPing commented 6 months ago

I was on my phone, sorry.

clseibold commented 6 months ago

Having that check would probably be useful in case this comes up again, and to create consistency between browsers and flatpak-builder. Anyways, I'll see if a mirror works.