1
0
Fork 0
mirror of https://github.com/NixOS/nix synced 2025-06-27 08:31:16 +02:00

Check meta values and warn about bad ones

This commit is contained in:
Eelco Dolstra 2013-11-19 14:29:39 +01:00
parent 0f24400d90
commit 30b986908e
4 changed files with 54 additions and 26 deletions

View file

@ -91,12 +91,30 @@ StringSet DrvInfo::queryMetaNames()
}
bool DrvInfo::checkMeta(Value & v)
{
state->forceValue(v);
if (v.type == tList) {
for (unsigned int n = 0; n < v.list.length; ++n)
if (!checkMeta(*v.list.elems[n])) return false;
return true;
}
else if (v.type == tAttrs) {
Bindings::iterator i = v.attrs->find(state->sOutPath);
if (i != v.attrs->end()) return false;
foreach (Bindings::iterator, i, *v.attrs)
if (!checkMeta(*i->value)) return false;
return true;
}
else return v.type == tInt || v.type == tBool || v.type == tString;
}
Value * DrvInfo::queryMeta(const string & name)
{
if (!getMeta()) return 0;
Bindings::iterator a = meta->find(state->symbols.create(name));
if (a == meta->end()) return 0;
state->forceValue(*a->value);
if (a == meta->end() || !checkMeta(*a->value)) return 0;
return a->value;
}

View file

@ -30,6 +30,8 @@ private:
Bindings * getMeta();
bool checkMeta(Value & v);
public:
string name;
string attrPath; /* path towards the derivation */