about summary refs log tree commit diff
path: root/src/libexpr/primops.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2005-01-20T15·25+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2005-01-20T15·25+0000
commit6bb5efadeceb8c4666c227a44113709bb47d23cb (patch)
tree2362c5689000d1889ff7f64b73c90662d3605603 /src/libexpr/primops.cc
parent05f0430de1d8eeae222a1306d4d0f7f407c8ce7d (diff)
* Ensure that derivation names and sources don't end in `.drv'.
Diffstat (limited to 'src/libexpr/primops.cc')
-rw-r--r--src/libexpr/primops.cc24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/libexpr/primops.cc b/src/libexpr/primops.cc
index f105975572..013eba5947 100644
--- a/src/libexpr/primops.cc
+++ b/src/libexpr/primops.cc
@@ -16,21 +16,6 @@ static Expr primImport(EvalState & state, const ATermVector & args)
 }
 
 
-#if 0
-static PathSet storeExprRootsCached(EvalState & state, const Path & nePath)
-{
-    DrvRoots::iterator i = state.drvRoots.find(nePath);
-    if (i != state.drvRoots.end())
-        return i->second;
-    else {
-        PathSet paths = storeExprRoots(nePath);
-        state.drvRoots[nePath] = paths;
-        return paths;
-    }
-}
-#endif
-
-
 /* Returns the hash of a derivation modulo fixed-output
    subderivations.  A fixed-output derivation is a derivation with one
    output (`out') for which an expected hash and hash algorithm are
@@ -128,7 +113,10 @@ static void processBinding(EvalState & state, Expr e, Derivation & drv,
     }
 
     else if (matchPath(e, s)) {
-        Path srcPath(aterm2String(s));
+        Path srcPath(canonPath(aterm2String(s)));
+        if (isDerivation(srcPath))
+            throw Error(format("file names are not allowed to end in `%1%'")
+                % drvExtension);
         Path dstPath(addToStore(srcPath));
         printMsg(lvlChatty, format("copied source `%1%' -> `%2%'")
             % srcPath % dstPath);
@@ -272,6 +260,10 @@ static Expr primDerivation(EvalState & state, const ATermVector & _args)
                 % *i % drvName);
         }
 
+    if (isDerivation(drvName))
+        throw Error(format("derivation names are not allowed to end in `%1%'")
+            % drvExtension);
+
     /* !!! the name should not end in the derivation extension (.drv).
        Likewise for sources. */