fix(3p/nix): Update for usage of new attribute set API

The new attribute set API uses the iterators of the btree_map
directly. This requires changes in various files because the internals
of libexpr are very entangled.

This code runs and compiles, but there is a bug causing empty
attribute sets to be assigned incorrectly.
This commit is contained in:
Vincent Ambo 2020-05-22 01:58:12 +01:00
parent 42205f27fc
commit 986a8f6b75
14 changed files with 187 additions and 176 deletions

View file

@ -43,13 +43,13 @@ string resolveMirrorUri(EvalState& state, string uri) {
if (mirrorList == vMirrors.attrs->end()) {
throw Error(format("unknown mirror name '%1%'") % mirrorName);
}
state.forceList(*mirrorList->value);
state.forceList(*mirrorList->second.value);
if (mirrorList->value->listSize() < 1) {
if (mirrorList->second.value->listSize() < 1) {
throw Error(format("mirror URI '%1%' did not expand to anything") % uri);
}
string mirror = state.forceString(*mirrorList->value->listElems()[0]);
string mirror = state.forceString(*mirrorList->second.value->listElems()[0]);
return mirror + (hasSuffix(mirror, "/") ? "" : "/") + string(s, p + 1);
}
@ -130,25 +130,25 @@ static int _main(int argc, char** argv) {
if (attr == v.attrs->end()) {
throw Error("attribute set does not contain a 'urls' attribute");
}
state->forceList(*attr->value);
if (attr->value->listSize() < 1) {
state->forceList(*attr->second.value);
if (attr->second.value->listSize() < 1) {
throw Error("'urls' list is empty");
}
uri = state->forceString(*attr->value->listElems()[0]);
uri = state->forceString(*attr->second.value->listElems()[0]);
/* Extract the hash mode. */
attr = v.attrs->find(state->symbols.Create("outputHashMode"));
if (attr == v.attrs->end()) {
LOG(WARNING) << "this does not look like a fetchurl call";
} else {
unpack = state->forceString(*attr->value) == "recursive";
unpack = state->forceString(*attr->second.value) == "recursive";
}
/* Extract the name. */
if (name.empty()) {
attr = v.attrs->find(state->symbols.Create("name"));
if (attr != v.attrs->end()) {
name = state->forceString(*attr->value);
name = state->forceString(*attr->second.value);
}
}
}