Skip to content
Snippets Groups Projects
Unverified Commit 2d910127 authored by Eelco Dolstra's avatar Eelco Dolstra
Browse files

fetchurl: Respect unpack

Fixes #2393.
parent e0ddabb0
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
Path storePath = getAttr("out");
auto mainUrl = getAttr("url");
bool unpack = get(drv.env, "unpack", "") == "1";
/* Note: have to use a fresh downloader here because we're in
a forked process. */
......@@ -40,12 +41,12 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
request.decompress = false;
auto decompressor = makeDecompressionSink(
hasSuffix(mainUrl, ".xz") ? "xz" : "none", sink);
unpack && hasSuffix(mainUrl, ".xz") ? "xz" : "none", sink);
downloader->download(std::move(request), *decompressor);
decompressor->finish();
});
if (get(drv.env, "unpack", "") == "1")
if (unpack)
restorePath(storePath, *source);
else
writeFile(storePath, *source);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment