forked from lix-project/lix
Always use base-16 for hashed mirror lookups
In particular, don't use base-64, which we don't support. (We do have base-32 redirects for hysterical reasons.) Also, add a test for the hashed mirror feature.
This commit is contained in:
parent
49304bae81
commit
bf6792c0df
|
@ -42,7 +42,8 @@ void builtinFetchurl(const BasicDerivation & drv, const std::string & netrcData)
|
||||||
for (auto hashedMirror : settings.hashedMirrors.get())
|
for (auto hashedMirror : settings.hashedMirrors.get())
|
||||||
try {
|
try {
|
||||||
if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/';
|
if (!hasSuffix(hashedMirror, "/")) hashedMirror += '/';
|
||||||
data = fetch(hashedMirror + getAttr("outputHashAlgo") + "/" + getAttr("outputHash"));
|
auto ht = parseHashType(getAttr("outputHashAlgo"));
|
||||||
|
data = fetch(hashedMirror + printHashType(ht) + "/" + Hash(getAttr("outputHash"), ht).to_string(Base16, false));
|
||||||
break;
|
break;
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
debug(e.what());
|
debug(e.what());
|
||||||
|
|
|
@ -18,6 +18,19 @@ outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file://$(pwd)/fetchurl.sh
|
||||||
|
|
||||||
cmp $outPath fetchurl.sh
|
cmp $outPath fetchurl.sh
|
||||||
|
|
||||||
|
# Test the hashed mirror feature.
|
||||||
|
clearStore
|
||||||
|
|
||||||
|
hash=$(nix hash-file --type sha512 --base64 ./fetchurl.sh)
|
||||||
|
hash32=$(nix hash-file --type sha512 --base16 ./fetchurl.sh)
|
||||||
|
|
||||||
|
mirror=$TMPDIR/hashed-mirror
|
||||||
|
rm -rf $mirror
|
||||||
|
mkdir -p $mirror/sha512
|
||||||
|
ln -s $(pwd)/fetchurl.sh $mirror/sha512/$hash32
|
||||||
|
|
||||||
|
outPath=$(nix-build '<nix/fetchurl.nix>' --argstr url file:///no-such-dir/fetchurl.sh --argstr sha512 $hash --no-out-link --option hashed-mirrors "file://$mirror")
|
||||||
|
|
||||||
# Test unpacking a NAR.
|
# Test unpacking a NAR.
|
||||||
rm -rf $TEST_ROOT/archive
|
rm -rf $TEST_ROOT/archive
|
||||||
mkdir -p $TEST_ROOT/archive
|
mkdir -p $TEST_ROOT/archive
|
||||||
|
|
Loading…
Reference in a new issue