about summary refs log tree commit diff
path: root/src/nix.cc
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2003-04-25T15·01+0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2003-04-25T15·01+0000
commitfcc5ae151bb78006e7acc5ab8bf6b54692281777 (patch)
treef4ef9a94d0ece128af18c0ea833feeec79c69fad /src/nix.cc
parent76205df09cd6ac700f002f22e285440364d96ccd (diff)
* Remove build directory from a package directory after building it.
Diffstat (limited to 'src/nix.cc')
-rw-r--r--src/nix.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/nix.cc b/src/nix.cc
index a8d2d78806f9..973c36727ac2 100644
--- a/src/nix.cc
+++ b/src/nix.cc
@@ -332,6 +332,11 @@ build:
     
         if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
             throw Error("unable to build package");
+
+        /* Remove write permission from the build directory. */
+        int res = system(("chmod -R -w " + path).c_str()); // !!! escaping
+        if (WEXITSTATUS(res) != 0)
+            throw Error("cannot remove write permission from " + path);
     
     } catch (exception &) {
         system(("rm -rf " + path).c_str());
@@ -411,10 +416,10 @@ void delPkg(string hash)
     string path;
     checkHash(hash);
     if (queryDB(dbInstPkgs, hash, path)) {
-        int res = system(("rm -rf " + path).c_str()); // !!! escaping
-        delDB(dbInstPkgs, hash); // not a bug
+        int res = system(("chmod -R +w " + path + " && rm -rf " + path).c_str()); // !!! escaping
+        delDB(dbInstPkgs, hash); // not a bug ??? 
         if (WEXITSTATUS(res) != 0)
-            throw Error("cannot delete " + path);
+            cerr << "errors deleting " + path + ", ignoring" << endl;
     }
 }