mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-22 05:56:15 +02:00
Merge pull request #10675 from edolstra/zip-symlinks
Handle zip files containing symlinks
This commit is contained in:
commit
3026613893
4 changed files with 26 additions and 1 deletions
|
@ -145,9 +145,27 @@ DownloadTarballResult downloadTarball(
|
|||
|
||||
// TODO: fall back to cached value if download fails.
|
||||
|
||||
AutoDelete cleanupTemp;
|
||||
|
||||
/* Note: if the download is cached, `importTarball()` will receive
|
||||
no data, which causes it to import an empty tarball. */
|
||||
TarArchive archive { *source };
|
||||
auto archive =
|
||||
hasSuffix(toLower(parseURL(url).path), ".zip")
|
||||
? ({
|
||||
/* In streaming mode, libarchive doesn't handle
|
||||
symlinks in zip files correctly (#10649). So write
|
||||
the entire file to disk so libarchive can access it
|
||||
in random-access mode. */
|
||||
auto [fdTemp, path] = createTempFile("nix-zipfile");
|
||||
cleanupTemp.reset(path);
|
||||
debug("downloading '%s' into '%s'...", url, path);
|
||||
{
|
||||
FdSink sink(fdTemp.get());
|
||||
source->drainInto(sink);
|
||||
}
|
||||
TarArchive{path};
|
||||
})
|
||||
: TarArchive{*source};
|
||||
auto parseSink = getTarballCache()->getFileSystemObjectSink();
|
||||
auto lastModified = unpackTarfileToSink(archive, *parseSink);
|
||||
|
||||
|
|
6
tests/functional/flakes/prefetch.sh
Normal file
6
tests/functional/flakes/prefetch.sh
Normal file
|
@ -0,0 +1,6 @@
|
|||
source common.sh
|
||||
|
||||
# Test symlinks in zip files (#10649).
|
||||
path=$(nix flake prefetch --json file://$(pwd)/tree.zip | jq -r .storePath)
|
||||
[[ $(cat $path/foo) = foo ]]
|
||||
[[ $(readlink $path/bar) = foo ]]
|
BIN
tests/functional/flakes/tree.zip
Normal file
BIN
tests/functional/flakes/tree.zip
Normal file
Binary file not shown.
|
@ -15,6 +15,7 @@ nix_tests = \
|
|||
flakes/absolute-attr-paths.sh \
|
||||
flakes/build-paths.sh \
|
||||
flakes/flake-in-submodule.sh \
|
||||
flakes/prefetch.sh \
|
||||
gc.sh \
|
||||
nix-collect-garbage-d.sh \
|
||||
remote-store.sh \
|
||||
|
|
Loading…
Reference in a new issue