summary refs log tree commit diff
diff options
context:
space:
mode:
authorEelco Dolstra <e.dolstra@tudelft.nl>2009-09-23 17:05:51 +0000
committerEelco Dolstra <e.dolstra@tudelft.nl>2009-09-23 17:05:51 +0000
commit64e89980e880826fec3e973e50edebf24278c7b8 (patch)
treec6a6ff51971f9d23622e3884bd37efef6cefc862
parent48b58617e9e84fd1a0e4bd11798bd6b9d04a1633 (diff)
downloadguix-64e89980e880826fec3e973e50edebf24278c7b8.tar.gz
* Create some state directories automatically as a convenience.
-rw-r--r--src/libstore/build.cc2
-rw-r--r--src/libstore/local-store.cc21
2 files changed, 17 insertions, 6 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 81a776e4fd..cd3dddab6c 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -467,6 +467,8 @@ void UserLock::acquire()
         if (!pw)
             throw Error(format("the user `%1%' in the group `%2%' does not exist")
                 % *i % buildUsersGroup);
+
+        createDirs(nixStateDir + "/userpool");
         
         fnUserLock = (format("%1%/userpool/%2%") % nixStateDir % pw->pw_uid).str();
 
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 704bb1a066..e91a2559b1 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -47,8 +47,21 @@ LocalStore::LocalStore()
     
     if (readOnlyMode) return;
 
+    /* Create missing state directories if they don't already exist. */
     createDirs(nixStore);
-    
+    createDirs(nixDBPath + "/info");
+    createDirs(nixDBPath + "/referrer");
+    createDirs(nixDBPath + "/failed");
+    Path profilesDir = nixStateDir + "/profiles";
+    createDirs(nixStateDir + "/profiles");
+    createDirs(nixStateDir + "/temproots");
+    Path gcRootsDir = nixStateDir + "/gcroots";
+    if (!pathExists(gcRootsDir)) {
+        createDirs(gcRootsDir);
+        if (symlink(profilesDir.c_str(), (gcRootsDir + "/profiles").c_str()) == -1)
+            throw SysError(format("creating symlink to `%1%'") % profilesDir);
+    }
+  
     checkStoreNotSymlink();
 
     try {
@@ -64,11 +77,7 @@ LocalStore::LocalStore()
         printMsg(lvlError, "waiting for the big Nix store lock...");
         lockFile(globalLock, ltRead, true);
     }
-
-    createDirs(nixDBPath + "/info");
-    createDirs(nixDBPath + "/referrer");
-    createDirs(nixDBPath + "/failed");
-
+    
     int curSchema = getSchema();
     if (curSchema > nixSchemaVersion)
         throw Error(format("current Nix store schema is version %1%, but I only support %2%")