about summary refs log tree commit diff
path: root/src/libexpr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libexpr')
-rw-r--r--src/libexpr/get-drvs.cc22
-rw-r--r--src/libexpr/get-drvs.hh2
2 files changed, 22 insertions, 2 deletions
diff --git a/src/libexpr/get-drvs.cc b/src/libexpr/get-drvs.cc
index 42776b22ac1c..0ed644e9bc5b 100644
--- a/src/libexpr/get-drvs.cc
+++ b/src/libexpr/get-drvs.cc
@@ -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;
 }
 
diff --git a/src/libexpr/get-drvs.hh b/src/libexpr/get-drvs.hh
index b5aebc188355..aaafff1905e7 100644
--- a/src/libexpr/get-drvs.hh
+++ b/src/libexpr/get-drvs.hh
@@ -30,6 +30,8 @@ private:
 
     Bindings * getMeta();
 
+    bool checkMeta(Value & v);
+
 public:
     string name;
     string attrPath; /* path towards the derivation */