summary refs log tree commit diff
path: root/nix
diff options
context:
space:
mode:
Diffstat (limited to 'nix')
-rw-r--r--nix/libstore/globals.cc44
-rw-r--r--nix/libstore/globals.hh4
-rw-r--r--nix/libstore/local-store.cc159
-rw-r--r--nix/libstore/local-store.hh7
-rw-r--r--nix/libstore/misc.cc114
-rw-r--r--nix/libstore/misc.hh7
-rw-r--r--nix/libstore/store-api.cc31
-rw-r--r--nix/libstore/store-api.hh17
8 files changed, 5 insertions, 378 deletions
diff --git a/nix/libstore/globals.cc b/nix/libstore/globals.cc
index 4ab6c3a0f9..fcafac2df6 100644
--- a/nix/libstore/globals.cc
+++ b/nix/libstore/globals.cc
@@ -78,39 +78,6 @@ void Settings::processEnvironment()
 }
 
 
-void Settings::loadConfFile()
-{
-    Path settingsFile = (format("%1%/%2%") % nixConfDir % "nix.conf").str();
-    if (!pathExists(settingsFile)) return;
-    string contents = readFile(settingsFile);
-
-    unsigned int pos = 0;
-
-    while (pos < contents.size()) {
-        string line;
-        while (pos < contents.size() && contents[pos] != '\n')
-            line += contents[pos++];
-        pos++;
-
-        string::size_type hash = line.find('#');
-        if (hash != string::npos)
-            line = string(line, 0, hash);
-
-        vector<string> tokens = tokenizeString<vector<string> >(line);
-        if (tokens.empty()) continue;
-
-        if (tokens.size() < 2 || tokens[1] != "=")
-            throw Error(format("illegal configuration line `%1%' in `%2%'") % line % settingsFile);
-
-        string name = tokens[0];
-
-        vector<string>::iterator i = tokens.begin();
-        advance(i, 2);
-        settings[name] = concatStringsSep(" ", Strings(i, tokens.end())); // FIXME: slow
-    };
-}
-
-
 void Settings::set(const string & name, const string & value)
 {
     settings[name] = value;
@@ -256,17 +223,6 @@ string Settings::pack()
 }
 
 
-void Settings::unpack(const string & pack) {
-    Strings lines = tokenizeString<Strings>(pack, "\n");
-    foreach (Strings::iterator, i, lines) {
-        string::size_type eq = i->find('=');
-        if (eq == string::npos)
-            throw Error("illegal option name/value");
-        set(i->substr(0, eq), i->substr(eq + 1));
-    }
-}
-
-
 Settings::SettingsMap Settings::getOverrides()
 {
     return overrides;
diff --git a/nix/libstore/globals.hh b/nix/libstore/globals.hh
index 2439936959..1293625e1f 100644
--- a/nix/libstore/globals.hh
+++ b/nix/libstore/globals.hh
@@ -26,8 +26,6 @@ struct Settings {
 
     void processEnvironment();
 
-    void loadConfFile();
-
     void set(const string & name, const string & value);
 
     string get(const string & name, const string & def);
@@ -42,8 +40,6 @@ struct Settings {
 
     string pack();
 
-    void unpack(const string & pack);
-
     SettingsMap getOverrides();
 
     /* The directory where we store sources and derived files. */
diff --git a/nix/libstore/local-store.cc b/nix/libstore/local-store.cc
index 882bce1f40..4c55c6ea0d 100644
--- a/nix/libstore/local-store.cc
+++ b/nix/libstore/local-store.cc
@@ -171,27 +171,10 @@ LocalStore::LocalStore(bool reserveSpace)
     }
 
     else if (curSchema < nixSchemaVersion) {
-        if (curSchema < 5)
-            throw Error(
-                "Your Nix store has a database in Berkeley DB format,\n"
-                "which is no longer supported. To convert to the new format,\n"
-                "please upgrade Nix to version 0.12 first.");
-
-        if (!lockFile(globalLock, ltWrite, false)) {
-            printMsg(lvlError, "waiting for exclusive access to the Nix store...");
-            lockFile(globalLock, ltWrite, true);
-        }
-
-        /* Get the schema version again, because another process may
-           have performed the upgrade already. */
-        curSchema = getSchema();
-
-        if (curSchema < 6) upgradeStore6();
-        else if (curSchema < 7) { upgradeStore7(); openDB(true); }
-
-        writeFile(schemaPath, (format("%1%") % nixSchemaVersion).str());
-
-        lockFile(globalLock, ltRead, true);
+	/* Guix always used version 7 of the schema.  */
+	throw Error(
+	    format("Your store database uses an implausibly old schema, version %1%.")
+	    % curSchema);
     }
 
     else openDB(false);
@@ -1633,140 +1616,6 @@ void LocalStore::markContentsGood(const Path & path)
 }
 
 
-/* Functions for upgrading from the pre-SQLite database. */
-
-PathSet LocalStore::queryValidPathsOld()
-{
-    PathSet paths;
-    for (auto & i : readDirectory(settings.nixDBPath + "/info"))
-        if (i.name.at(0) != '.') paths.insert(settings.nixStore + "/" + i.name);
-    return paths;
-}
-
-
-ValidPathInfo LocalStore::queryPathInfoOld(const Path & path)
-{
-    ValidPathInfo res;
-    res.path = path;
-
-    /* Read the info file. */
-    string baseName = baseNameOf(path);
-    Path infoFile = (format("%1%/info/%2%") % settings.nixDBPath % baseName).str();
-    if (!pathExists(infoFile))
-        throw Error(format("path `%1%' is not valid") % path);
-    string info = readFile(infoFile);
-
-    /* Parse it. */
-    Strings lines = tokenizeString<Strings>(info, "\n");
-
-    foreach (Strings::iterator, i, lines) {
-        string::size_type p = i->find(':');
-        if (p == string::npos)
-            throw Error(format("corrupt line in `%1%': %2%") % infoFile % *i);
-        string name(*i, 0, p);
-        string value(*i, p + 2);
-        if (name == "References") {
-            Strings refs = tokenizeString<Strings>(value, " ");
-            res.references = PathSet(refs.begin(), refs.end());
-        } else if (name == "Deriver") {
-            res.deriver = value;
-        } else if (name == "Hash") {
-            res.hash = parseHashField(path, value);
-        } else if (name == "Registered-At") {
-            int n = 0;
-            string2Int(value, n);
-            res.registrationTime = n;
-        }
-    }
-
-    return res;
-}
-
-
-/* Upgrade from schema 5 (Nix 0.12) to schema 6 (Nix >= 0.15). */
-void LocalStore::upgradeStore6()
-{
-    printMsg(lvlError, "upgrading Nix store to new schema (this may take a while)...");
-
-    openDB(true);
-
-    PathSet validPaths = queryValidPathsOld();
-
-    SQLiteTxn txn(db);
-
-    foreach (PathSet::iterator, i, validPaths) {
-        addValidPath(queryPathInfoOld(*i), false);
-        std::cerr << ".";
-    }
-
-    std::cerr << "|";
-
-    foreach (PathSet::iterator, i, validPaths) {
-        ValidPathInfo info = queryPathInfoOld(*i);
-        unsigned long long referrer = queryValidPathId(*i);
-        foreach (PathSet::iterator, j, info.references)
-            addReference(referrer, queryValidPathId(*j));
-        std::cerr << ".";
-    }
-
-    std::cerr << "\n";
-
-    txn.commit();
-}
-
-
-#if defined(FS_IOC_SETFLAGS) && defined(FS_IOC_GETFLAGS) && defined(FS_IMMUTABLE_FL)
-
-static void makeMutable(const Path & path)
-{
-    checkInterrupt();
-
-    struct stat st = lstat(path);
-
-    if (!S_ISDIR(st.st_mode) && !S_ISREG(st.st_mode)) return;
-
-    if (S_ISDIR(st.st_mode)) {
-        for (auto & i : readDirectory(path))
-            makeMutable(path + "/" + i.name);
-    }
-
-    /* The O_NOFOLLOW is important to prevent us from changing the
-       mutable bit on the target of a symlink (which would be a
-       security hole). */
-    AutoCloseFD fd = open(path.c_str(), O_RDONLY | O_NOFOLLOW);
-    if (fd == -1) {
-        if (errno == ELOOP) return; // it's a symlink
-        throw SysError(format("opening file `%1%'") % path);
-    }
-
-    unsigned int flags = 0, old;
-
-    /* Silently ignore errors getting/setting the immutable flag so
-       that we work correctly on filesystems that don't support it. */
-    if (ioctl(fd, FS_IOC_GETFLAGS, &flags)) return;
-    old = flags;
-    flags &= ~FS_IMMUTABLE_FL;
-    if (old == flags) return;
-    if (ioctl(fd, FS_IOC_SETFLAGS, &flags)) return;
-}
-
-/* Upgrade from schema 6 (Nix 0.15) to schema 7 (Nix >= 1.3). */
-void LocalStore::upgradeStore7()
-{
-    if (getuid() != 0) return;
-    printMsg(lvlError, "removing immutable bits from the Nix store (this may take a while)...");
-    makeMutable(settings.nixStore);
-}
-
-#else
-
-void LocalStore::upgradeStore7()
-{
-}
-
-#endif
-
-
 void LocalStore::vacuumDB()
 {
     if (sqlite3_exec(db, "vacuum;", 0, 0, 0) != SQLITE_OK)
diff --git a/nix/libstore/local-store.hh b/nix/libstore/local-store.hh
index 6110468498..4e6b4cfc1d 100644
--- a/nix/libstore/local-store.hh
+++ b/nix/libstore/local-store.hh
@@ -15,7 +15,7 @@ namespace nix {
 /* Nix store and database schema version.  Version 1 (or 0) was Nix <=
    0.7.  Version 2 was Nix 0.8 and 0.9.  Version 3 is Nix 0.10.
    Version 4 is Nix 0.11.  Version 5 is Nix 0.12-0.16.  Version 6 is
-   Nix 1.0.  Version 7 is Nix 1.3. */
+   Nix 1.0.  Version 7 is Nix 1.3.  Guix has always used version 7.  */
 const int nixSchemaVersion = 7;
 
 
@@ -244,11 +244,6 @@ private:
 
     void updatePathInfo(const ValidPathInfo & info);
 
-    void upgradeStore6();
-    void upgradeStore7();
-    PathSet queryValidPathsOld();
-    ValidPathInfo queryPathInfoOld(const Path & path);
-
     struct GCState;
 
     void deleteGarbage(GCState & state, const Path & path);
diff --git a/nix/libstore/misc.cc b/nix/libstore/misc.cc
index 22363af126..97618089bd 100644
--- a/nix/libstore/misc.cc
+++ b/nix/libstore/misc.cc
@@ -67,120 +67,6 @@ Path findOutput(const Derivation & drv, string id)
 }
 
 
-void queryMissing(StoreAPI & store, const PathSet & targets,
-    PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
-    unsigned long long & downloadSize, unsigned long long & narSize)
-{
-    downloadSize = narSize = 0;
-
-    PathSet todo(targets.begin(), targets.end()), done;
-
-    /* Getting substitute info has high latency when using the binary
-       cache substituter.  Thus it's essential to do substitute
-       queries in parallel as much as possible.  To accomplish this
-       we do the following:
-
-       - For all paths still to be processed (‘todo’), we add all
-         paths for which we need info to the set ‘query’.  For an
-         unbuilt derivation this is the output paths; otherwise, it's
-         the path itself.
-
-       - We get info about all paths in ‘query’ in parallel.
-
-       - We process the results and add new items to ‘todo’ if
-         necessary.  E.g. if a path is substitutable, then we need to
-         get info on its references.
-
-       - Repeat until ‘todo’ is empty.
-    */
-
-    while (!todo.empty()) {
-
-        PathSet query, todoDrv, todoNonDrv;
-
-        foreach (PathSet::iterator, i, todo) {
-            if (done.find(*i) != done.end()) continue;
-            done.insert(*i);
-
-            DrvPathWithOutputs i2 = parseDrvPathWithOutputs(*i);
-
-            if (isDerivation(i2.first)) {
-                if (!store.isValidPath(i2.first)) {
-                    // FIXME: we could try to substitute p.
-                    unknown.insert(*i);
-                    continue;
-                }
-                Derivation drv = derivationFromPath(store, i2.first);
-
-                PathSet invalid;
-                foreach (DerivationOutputs::iterator, j, drv.outputs)
-                    if (wantOutput(j->first, i2.second)
-                        && !store.isValidPath(j->second.path))
-                        invalid.insert(j->second.path);
-                if (invalid.empty()) continue;
-
-                todoDrv.insert(*i);
-                if (settings.useSubstitutes && substitutesAllowed(drv))
-                    query.insert(invalid.begin(), invalid.end());
-            }
-
-            else {
-                if (store.isValidPath(*i)) continue;
-                query.insert(*i);
-                todoNonDrv.insert(*i);
-            }
-        }
-
-        todo.clear();
-
-        SubstitutablePathInfos infos;
-        store.querySubstitutablePathInfos(query, infos);
-
-        foreach (PathSet::iterator, i, todoDrv) {
-            DrvPathWithOutputs i2 = parseDrvPathWithOutputs(*i);
-
-            // FIXME: cache this
-            Derivation drv = derivationFromPath(store, i2.first);
-
-            PathSet outputs;
-            bool mustBuild = false;
-            if (settings.useSubstitutes && substitutesAllowed(drv)) {
-                foreach (DerivationOutputs::iterator, j, drv.outputs) {
-                    if (!wantOutput(j->first, i2.second)) continue;
-                    if (!store.isValidPath(j->second.path)) {
-                        if (infos.find(j->second.path) == infos.end())
-                            mustBuild = true;
-                        else
-                            outputs.insert(j->second.path);
-                    }
-                }
-            } else
-                mustBuild = true;
-
-            if (mustBuild) {
-                willBuild.insert(i2.first);
-                todo.insert(drv.inputSrcs.begin(), drv.inputSrcs.end());
-                foreach (DerivationInputs::iterator, j, drv.inputDrvs)
-                    todo.insert(makeDrvPathWithOutputs(j->first, j->second));
-            } else
-                todoNonDrv.insert(outputs.begin(), outputs.end());
-        }
-
-        foreach (PathSet::iterator, i, todoNonDrv) {
-            done.insert(*i);
-            SubstitutablePathInfos::iterator info = infos.find(*i);
-            if (info != infos.end()) {
-                willSubstitute.insert(*i);
-                downloadSize += info->second.downloadSize;
-                narSize += info->second.narSize;
-                todo.insert(info->second.references.begin(), info->second.references.end());
-            } else
-                unknown.insert(*i);
-        }
-    }
-}
-
-
 static void dfsVisit(StoreAPI & store, const PathSet & paths,
     const Path & path, PathSet & visited, Paths & sorted,
     PathSet & parents)
diff --git a/nix/libstore/misc.hh b/nix/libstore/misc.hh
index d3e31d51f7..edbf24047e 100644
--- a/nix/libstore/misc.hh
+++ b/nix/libstore/misc.hh
@@ -25,13 +25,6 @@ void computeFSClosure(StoreAPI & store, const Path & path,
    given derivation. */
 Path findOutput(const Derivation & drv, string id);
 
-/* Given a set of paths that are to be built, return the set of
-   derivations that will be built, and the set of output paths that
-   will be substituted. */
-void queryMissing(StoreAPI & store, const PathSet & targets,
-    PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown,
-    unsigned long long & downloadSize, unsigned long long & narSize);
-
 bool willBuildLocally(const Derivation & drv);
 
 bool substitutesAllowed(const Derivation & drv);
diff --git a/nix/libstore/store-api.cc b/nix/libstore/store-api.cc
index 30af5f5fed..6742d2ed49 100644
--- a/nix/libstore/store-api.cc
+++ b/nix/libstore/store-api.cc
@@ -48,26 +48,6 @@ Path toStorePath(const Path & path)
 }
 
 
-Path followLinksToStore(const Path & _path)
-{
-    Path path = absPath(_path);
-    while (!isInStore(path)) {
-        if (!isLink(path)) break;
-        string target = readLink(path);
-        path = absPath(target, dirOf(path));
-    }
-    if (!isInStore(path))
-        throw Error(format("path `%1%' is not in the Nix store") % path);
-    return path;
-}
-
-
-Path followLinksToStorePath(const Path & path)
-{
-    return toStorePath(followLinksToStore(path));
-}
-
-
 string storePathToName(const Path & path)
 {
     assertStorePath(path);
@@ -200,17 +180,6 @@ Path makeFixedOutputPath(bool recursive,
 }
 
 
-std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath,
-    bool recursive, HashType hashAlgo, PathFilter & filter)
-{
-    HashType ht(hashAlgo);
-    Hash h = recursive ? hashPath(ht, srcPath, filter).first : hashFile(ht, srcPath);
-    string name = baseNameOf(srcPath);
-    Path dstPath = makeFixedOutputPath(recursive, hashAlgo, h, name);
-    return std::pair<Path, Hash>(dstPath, h);
-}
-
-
 Path computeStorePathForText(const string & name, const string & s,
     const PathSet & references)
 {
diff --git a/nix/libstore/store-api.hh b/nix/libstore/store-api.hh
index fa78d595f2..e957cedebc 100644
--- a/nix/libstore/store-api.hh
+++ b/nix/libstore/store-api.hh
@@ -311,15 +311,6 @@ void checkStoreName(const string & name);
 Path toStorePath(const Path & path);
 
 
-/* Follow symlinks until we end up with a path in the Nix store. */
-Path followLinksToStore(const Path & path);
-
-
-/* Same as followLinksToStore(), but apply toStorePath() to the
-   result. */
-Path followLinksToStorePath(const Path & path);
-
-
 /* Constructs a unique store path name. */
 Path makeStorePath(const string & type,
     const Hash & hash, const string & name);
@@ -331,14 +322,6 @@ Path makeFixedOutputPath(bool recursive,
     HashType hashAlgo, Hash hash, string name);
 
 
-/* This is the preparatory part of addToStore() and addToStoreFixed();
-   it computes the store path to which srcPath is to be copied.
-   Returns the store path and the cryptographic hash of the
-   contents of srcPath. */
-std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath,
-    bool recursive = true, HashType hashAlgo = htSHA256,
-    PathFilter & filter = defaultPathFilter);
-
 /* Preparatory part of addTextToStore().
 
    !!! Computation of the path should take the references given to