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

fetchurl/fetchzip fails based on file extension? #60157

Open
deliciouslytyped opened this issue Apr 24, 2019 · 8 comments

Comments

@deliciouslytyped
Copy link
Contributor

commented Apr 24, 2019

with import <nixpkgs> {};
stdenv.mkDerivation {
   name = "test";
   src = fetchzip {
      name = "cs2d.zip";
      url = "http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266";
      sha256 = "1g66635m8zfsxdmg95c1xz72s6pam9w1myrjwk4dnw697dhpir1p";
      };
}

fails with

trying http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266
unpacking source archive /build/get.php?get=cs2d_1008_win.zip&p=1&cid=1266
do not know how to unpack source archive /build/get.php?get=cs2d_1008_win.zip&p=1&cid=1266

Also my understanding is maybe the result should be renamed to the name attribute?

@deliciouslytyped

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2019

The main culprit seems to be

if ! [[ "$curSrc" =~ \.zip$ ]]; then return 1; fi

which is called by
if ! runOneHook unpackCmd "$curSrc"; then

If we want to keep this behaviour maybe fetchurl should get some additional phases?

@deliciouslytyped

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2019

Alternatively the culprit is

renamed="$TMPDIR/${baseNameOf url}"

I thought passing curlOpts to fetchzip, which passes it through to fetchurl - might work but the -o option is already taken when downloadToTemp (

downloadToTemp = true;
) is true.

@deliciouslytyped

This comment has been minimized.

Copy link
Contributor Author

commented Apr 24, 2019

TODO: how is the name argument of fetchzip even used, and how is it expected to be used?
It only seems to get passed through to fetchurl.

@Luis-Hebendanz

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

@Mic92 Still broken also broken in stable :(

@Mic92

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

workaround atm would be:

with import <nixpkgs> {};
stdenv.mkDerivation {
   name = "test";
   src = fetchzip {
      name = "cs2d.zip";
-      url = "http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266";
+      url = "http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266#cs2d.zip";
      sha256 = "1g66635m8zfsxdmg95c1xz72s6pam9w1myrjwk4dnw697dhpir1p";
      };
}
@Mic92

This comment has been minimized.

Copy link
Contributor

commented Aug 26, 2019

or just:

with import <nixpkgs> {};
stdenv.mkDerivation {
   name = "test";
   src = fetchzip {
      name = "cs2d.zip";
-      url = "http://www.unrealsoftware.de/get.php?get=cs2d_1008_win.zip&p=1&cid=1266";
+      url = "http://www.unrealsoftware.de/get.php?p=1&cid=1266&get=cs2d_1008_win.zip";
      sha256 = "1g66635m8zfsxdmg95c1xz72s6pam9w1myrjwk4dnw697dhpir1p";
      };
}
@deliciouslytyped

This comment has been minimized.

Copy link
Contributor Author

commented Aug 26, 2019

@Mic92 Thanks, I hate it.
(no really, thanks though... facepalm)

@Mic92

This comment has been minimized.

Copy link
Contributor

commented Aug 27, 2019

Even when downloadedToTemp is set, it might be still possible to fix the file extension:

if [ -n "$downloadToTemp" ]; then downloadedFile="$TMPDIR/file"; fi

We just need to replace file with $(basename $out).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.