diff options
| author | Ludovic Courtès <ludovic.courtes@inria.fr> | 2018-03-29 16:56:00 +0200 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2018-03-30 23:42:07 +0200 |
| commit | c7589cce8d3f9fcb7769e424f341dba8fb3545d0 (patch) | |
| tree | 157c37d5933152efc20e2aa268a573b0ddad1bdc | |
| parent | dffd077c59e0faf8200422572b7d3aab611f0348 (diff) | |
daemon: Remove dead code.
* nix/libstore/globals.cc (Settings::loadConfFile, Settings::unpack):
Remove.
* nix/libstore/globals.hh: Adjust accordingly.
* nix/libstore/misc.cc (queryMissing): Remove.
* nix/libstore/misc.hh: Adjust accordingly.
* nix/libstore/store-api.cc (followLinksToStore)
(followLinksToStorePath, computeStorePathForHash): Remove.
* nix/libstore/store-api.hh: Adjust accordingly.
| -rw-r--r-- | nix/libstore/globals.cc | 44 | ||||
| -rw-r--r-- | nix/libstore/globals.hh | 4 | ||||
| -rw-r--r-- | nix/libstore/misc.cc | 114 | ||||
| -rw-r--r-- | nix/libstore/misc.hh | 7 | ||||
| -rw-r--r-- | nix/libstore/store-api.cc | 31 | ||||
| -rw-r--r-- | nix/libstore/store-api.hh | 17 |
6 files changed, 0 insertions, 217 deletions
diff --git a/nix/libstore/globals.cc b/nix/libstore/globals.cc index 4ab6c3a0f9c..fcafac2df62 100644 --- a/nix/libstore/globals.cc +++ b/nix/libstore/globals.cc | |||
| @@ -78,39 +78,6 @@ void Settings::processEnvironment() | |||
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | 80 | ||
| 81 | void Settings::loadConfFile() | ||
| 82 | { | ||
| 83 | Path settingsFile = (format("%1%/%2%") % nixConfDir % "nix.conf").str(); | ||
| 84 | if (!pathExists(settingsFile)) return; | ||
| 85 | string contents = readFile(settingsFile); | ||
| 86 | |||
| 87 | unsigned int pos = 0; | ||
| 88 | |||
| 89 | while (pos < contents.size()) { | ||
| 90 | string line; | ||
| 91 | while (pos < contents.size() && contents[pos] != '\n') | ||
| 92 | line += contents[pos++]; | ||
| 93 | pos++; | ||
| 94 | |||
| 95 | string::size_type hash = line.find('#'); | ||
| 96 | if (hash != string::npos) | ||
| 97 | line = string(line, 0, hash); | ||
| 98 | |||
| 99 | vector<string> tokens = tokenizeString<vector<string> >(line); | ||
| 100 | if (tokens.empty()) continue; | ||
| 101 | |||
| 102 | if (tokens.size() < 2 || tokens[1] != "=") | ||
| 103 | throw Error(format("illegal configuration line `%1%' in `%2%'") % line % settingsFile); | ||
| 104 | |||
| 105 | string name = tokens[0]; | ||
| 106 | |||
| 107 | vector<string>::iterator i = tokens.begin(); | ||
| 108 | advance(i, 2); | ||
| 109 | settings[name] = concatStringsSep(" ", Strings(i, tokens.end())); // FIXME: slow | ||
| 110 | }; | ||
| 111 | } | ||
| 112 | |||
| 113 | |||
| 114 | void Settings::set(const string & name, const string & value) | 81 | void Settings::set(const string & name, const string & value) |
| 115 | { | 82 | { |
| 116 | settings[name] = value; | 83 | settings[name] = value; |
| @@ -256,17 +223,6 @@ string Settings::pack() | |||
| 256 | } | 223 | } |
| 257 | 224 | ||
| 258 | 225 | ||
| 259 | void Settings::unpack(const string & pack) { | ||
| 260 | Strings lines = tokenizeString<Strings>(pack, "\n"); | ||
| 261 | foreach (Strings::iterator, i, lines) { | ||
| 262 | string::size_type eq = i->find('='); | ||
| 263 | if (eq == string::npos) | ||
| 264 | throw Error("illegal option name/value"); | ||
| 265 | set(i->substr(0, eq), i->substr(eq + 1)); | ||
| 266 | } | ||
| 267 | } | ||
| 268 | |||
| 269 | |||
| 270 | Settings::SettingsMap Settings::getOverrides() | 226 | Settings::SettingsMap Settings::getOverrides() |
| 271 | { | 227 | { |
| 272 | return overrides; | 228 | return overrides; |
diff --git a/nix/libstore/globals.hh b/nix/libstore/globals.hh index 24399369599..1293625e1f1 100644 --- a/nix/libstore/globals.hh +++ b/nix/libstore/globals.hh | |||
| @@ -26,8 +26,6 @@ struct Settings { | |||
| 26 | 26 | ||
| 27 | void processEnvironment(); | 27 | void processEnvironment(); |
| 28 | 28 | ||
| 29 | void loadConfFile(); | ||
| 30 | |||
| 31 | void set(const string & name, const string & value); | 29 | void set(const string & name, const string & value); |
| 32 | 30 | ||
| 33 | string get(const string & name, const string & def); | 31 | string get(const string & name, const string & def); |
| @@ -42,8 +40,6 @@ struct Settings { | |||
| 42 | 40 | ||
| 43 | string pack(); | 41 | string pack(); |
| 44 | 42 | ||
| 45 | void unpack(const string & pack); | ||
| 46 | |||
| 47 | SettingsMap getOverrides(); | 43 | SettingsMap getOverrides(); |
| 48 | 44 | ||
| 49 | /* The directory where we store sources and derived files. */ | 45 | /* The directory where we store sources and derived files. */ |
diff --git a/nix/libstore/misc.cc b/nix/libstore/misc.cc index 22363af1264..97618089bdf 100644 --- a/nix/libstore/misc.cc +++ b/nix/libstore/misc.cc | |||
| @@ -67,120 +67,6 @@ Path findOutput(const Derivation & drv, string id) | |||
| 67 | } | 67 | } |
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | void queryMissing(StoreAPI & store, const PathSet & targets, | ||
| 71 | PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown, | ||
| 72 | unsigned long long & downloadSize, unsigned long long & narSize) | ||
| 73 | { | ||
| 74 | downloadSize = narSize = 0; | ||
| 75 | |||
| 76 | PathSet todo(targets.begin(), targets.end()), done; | ||
| 77 | |||
| 78 | /* Getting substitute info has high latency when using the binary | ||
| 79 | cache substituter. Thus it's essential to do substitute | ||
| 80 | queries in parallel as much as possible. To accomplish this | ||
| 81 | we do the following: | ||
| 82 | |||
| 83 | - For all paths still to be processed (‘todo’), we add all | ||
| 84 | paths for which we need info to the set ‘query’. For an | ||
| 85 | unbuilt derivation this is the output paths; otherwise, it's | ||
| 86 | the path itself. | ||
| 87 | |||
| 88 | - We get info about all paths in ‘query’ in parallel. | ||
| 89 | |||
| 90 | - We process the results and add new items to ‘todo’ if | ||
| 91 | necessary. E.g. if a path is substitutable, then we need to | ||
| 92 | get info on its references. | ||
| 93 | |||
| 94 | - Repeat until ‘todo’ is empty. | ||
| 95 | */ | ||
| 96 | |||
| 97 | while (!todo.empty()) { | ||
| 98 | |||
| 99 | PathSet query, todoDrv, todoNonDrv; | ||
| 100 | |||
| 101 | foreach (PathSet::iterator, i, todo) { | ||
| 102 | if (done.find(*i) != done.end()) continue; | ||
| 103 | done.insert(*i); | ||
| 104 | |||
| 105 | DrvPathWithOutputs i2 = parseDrvPathWithOutputs(*i); | ||
| 106 | |||
| 107 | if (isDerivation(i2.first)) { | ||
| 108 | if (!store.isValidPath(i2.first)) { | ||
| 109 | // FIXME: we could try to substitute p. | ||
| 110 | unknown.insert(*i); | ||
| 111 | continue; | ||
| 112 | } | ||
| 113 | Derivation drv = derivationFromPath(store, i2.first); | ||
| 114 | |||
| 115 | PathSet invalid; | ||
| 116 | foreach (DerivationOutputs::iterator, j, drv.outputs) | ||
| 117 | if (wantOutput(j->first, i2.second) | ||
| 118 | && !store.isValidPath(j->second.path)) | ||
| 119 | invalid.insert(j->second.path); | ||
| 120 | if (invalid.empty()) continue; | ||
| 121 | |||
| 122 | todoDrv.insert(*i); | ||
| 123 | if (settings.useSubstitutes && substitutesAllowed(drv)) | ||
| 124 | query.insert(invalid.begin(), invalid.end()); | ||
| 125 | } | ||
| 126 | |||
| 127 | else { | ||
| 128 | if (store.isValidPath(*i)) continue; | ||
| 129 | query.insert(*i); | ||
| 130 | todoNonDrv.insert(*i); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 134 | todo.clear(); | ||
| 135 | |||
| 136 | SubstitutablePathInfos infos; | ||
| 137 | store.querySubstitutablePathInfos(query, infos); | ||
| 138 | |||
| 139 | foreach (PathSet::iterator, i, todoDrv) { | ||
| 140 | DrvPathWithOutputs i2 = parseDrvPathWithOutputs(*i); | ||
| 141 | |||
| 142 | // FIXME: cache this | ||
| 143 | Derivation drv = derivationFromPath(store, i2.first); | ||
| 144 | |||
| 145 | PathSet outputs; | ||
| 146 | bool mustBuild = false; | ||
| 147 | if (settings.useSubstitutes && substitutesAllowed(drv)) { | ||
| 148 | foreach (DerivationOutputs::iterator, j, drv.outputs) { | ||
| 149 | if (!wantOutput(j->first, i2.second)) continue; | ||
| 150 | if (!store.isValidPath(j->second.path)) { | ||
| 151 | if (infos.find(j->second.path) == infos.end()) | ||
| 152 | mustBuild = true; | ||
| 153 | else | ||
| 154 | outputs.insert(j->second.path); | ||
| 155 | } | ||
| 156 | } | ||
| 157 | } else | ||
| 158 | mustBuild = true; | ||
| 159 | |||
| 160 | if (mustBuild) { | ||
| 161 | willBuild.insert(i2.first); | ||
| 162 | todo.insert(drv.inputSrcs.begin(), drv.inputSrcs.end()); | ||
| 163 | foreach (DerivationInputs::iterator, j, drv.inputDrvs) | ||
| 164 | todo.insert(makeDrvPathWithOutputs(j->first, j->second)); | ||
| 165 | } else | ||
| 166 | todoNonDrv.insert(outputs.begin(), outputs.end()); | ||
| 167 | } | ||
| 168 | |||
| 169 | foreach (PathSet::iterator, i, todoNonDrv) { | ||
| 170 | done.insert(*i); | ||
| 171 | SubstitutablePathInfos::iterator info = infos.find(*i); | ||
| 172 | if (info != infos.end()) { | ||
| 173 | willSubstitute.insert(*i); | ||
| 174 | downloadSize += info->second.downloadSize; | ||
| 175 | narSize += info->second.narSize; | ||
| 176 | todo.insert(info->second.references.begin(), info->second.references.end()); | ||
| 177 | } else | ||
| 178 | unknown.insert(*i); | ||
| 179 | } | ||
| 180 | } | ||
| 181 | } | ||
| 182 | |||
| 183 | |||
| 184 | static void dfsVisit(StoreAPI & store, const PathSet & paths, | 70 | static void dfsVisit(StoreAPI & store, const PathSet & paths, |
| 185 | const Path & path, PathSet & visited, Paths & sorted, | 71 | const Path & path, PathSet & visited, Paths & sorted, |
| 186 | PathSet & parents) | 72 | PathSet & parents) |
diff --git a/nix/libstore/misc.hh b/nix/libstore/misc.hh index d3e31d51f72..edbf24047ed 100644 --- a/nix/libstore/misc.hh +++ b/nix/libstore/misc.hh | |||
| @@ -25,13 +25,6 @@ void computeFSClosure(StoreAPI & store, const Path & path, | |||
| 25 | given derivation. */ | 25 | given derivation. */ |
| 26 | Path findOutput(const Derivation & drv, string id); | 26 | Path findOutput(const Derivation & drv, string id); |
| 27 | 27 | ||
| 28 | /* Given a set of paths that are to be built, return the set of | ||
| 29 | derivations that will be built, and the set of output paths that | ||
| 30 | will be substituted. */ | ||
| 31 | void queryMissing(StoreAPI & store, const PathSet & targets, | ||
| 32 | PathSet & willBuild, PathSet & willSubstitute, PathSet & unknown, | ||
| 33 | unsigned long long & downloadSize, unsigned long long & narSize); | ||
| 34 | |||
| 35 | bool willBuildLocally(const Derivation & drv); | 28 | bool willBuildLocally(const Derivation & drv); |
| 36 | 29 | ||
| 37 | bool substitutesAllowed(const Derivation & drv); | 30 | bool substitutesAllowed(const Derivation & drv); |
diff --git a/nix/libstore/store-api.cc b/nix/libstore/store-api.cc index 30af5f5fed9..6742d2ed495 100644 --- a/nix/libstore/store-api.cc +++ b/nix/libstore/store-api.cc | |||
| @@ -48,26 +48,6 @@ Path toStorePath(const Path & path) | |||
| 48 | } | 48 | } |
| 49 | 49 | ||
| 50 | 50 | ||
| 51 | Path followLinksToStore(const Path & _path) | ||
| 52 | { | ||
| 53 | Path path = absPath(_path); | ||
| 54 | while (!isInStore(path)) { | ||
| 55 | if (!isLink(path)) break; | ||
| 56 | string target = readLink(path); | ||
| 57 | path = absPath(target, dirOf(path)); | ||
| 58 | } | ||
| 59 | if (!isInStore(path)) | ||
| 60 | throw Error(format("path `%1%' is not in the Nix store") % path); | ||
| 61 | return path; | ||
| 62 | } | ||
| 63 | |||
| 64 | |||
| 65 | Path followLinksToStorePath(const Path & path) | ||
| 66 | { | ||
| 67 | return toStorePath(followLinksToStore(path)); | ||
| 68 | } | ||
| 69 | |||
| 70 | |||
| 71 | string storePathToName(const Path & path) | 51 | string storePathToName(const Path & path) |
| 72 | { | 52 | { |
| 73 | assertStorePath(path); | 53 | assertStorePath(path); |
| @@ -200,17 +180,6 @@ Path makeFixedOutputPath(bool recursive, | |||
| 200 | } | 180 | } |
| 201 | 181 | ||
| 202 | 182 | ||
| 203 | std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath, | ||
| 204 | bool recursive, HashType hashAlgo, PathFilter & filter) | ||
| 205 | { | ||
| 206 | HashType ht(hashAlgo); | ||
| 207 | Hash h = recursive ? hashPath(ht, srcPath, filter).first : hashFile(ht, srcPath); | ||
| 208 | string name = baseNameOf(srcPath); | ||
| 209 | Path dstPath = makeFixedOutputPath(recursive, hashAlgo, h, name); | ||
| 210 | return std::pair<Path, Hash>(dstPath, h); | ||
| 211 | } | ||
| 212 | |||
| 213 | |||
| 214 | Path computeStorePathForText(const string & name, const string & s, | 183 | Path computeStorePathForText(const string & name, const string & s, |
| 215 | const PathSet & references) | 184 | const PathSet & references) |
| 216 | { | 185 | { |
diff --git a/nix/libstore/store-api.hh b/nix/libstore/store-api.hh index fa78d595f23..e957cedebcf 100644 --- a/nix/libstore/store-api.hh +++ b/nix/libstore/store-api.hh | |||
| @@ -311,15 +311,6 @@ void checkStoreName(const string & name); | |||
| 311 | Path toStorePath(const Path & path); | 311 | Path toStorePath(const Path & path); |
| 312 | 312 | ||
| 313 | 313 | ||
| 314 | /* Follow symlinks until we end up with a path in the Nix store. */ | ||
| 315 | Path followLinksToStore(const Path & path); | ||
| 316 | |||
| 317 | |||
| 318 | /* Same as followLinksToStore(), but apply toStorePath() to the | ||
| 319 | result. */ | ||
| 320 | Path followLinksToStorePath(const Path & path); | ||
| 321 | |||
| 322 | |||
| 323 | /* Constructs a unique store path name. */ | 314 | /* Constructs a unique store path name. */ |
| 324 | Path makeStorePath(const string & type, | 315 | Path makeStorePath(const string & type, |
| 325 | const Hash & hash, const string & name); | 316 | const Hash & hash, const string & name); |
| @@ -331,14 +322,6 @@ Path makeFixedOutputPath(bool recursive, | |||
| 331 | HashType hashAlgo, Hash hash, string name); | 322 | HashType hashAlgo, Hash hash, string name); |
| 332 | 323 | ||
| 333 | 324 | ||
| 334 | /* This is the preparatory part of addToStore() and addToStoreFixed(); | ||
| 335 | it computes the store path to which srcPath is to be copied. | ||
| 336 | Returns the store path and the cryptographic hash of the | ||
| 337 | contents of srcPath. */ | ||
| 338 | std::pair<Path, Hash> computeStorePathForPath(const Path & srcPath, | ||
| 339 | bool recursive = true, HashType hashAlgo = htSHA256, | ||
| 340 | PathFilter & filter = defaultPathFilter); | ||
| 341 | |||
| 342 | /* Preparatory part of addTextToStore(). | 325 | /* Preparatory part of addTextToStore(). |
| 343 | 326 | ||
| 344 | !!! Computation of the path should take the references given to | 327 | !!! Computation of the path should take the references given to |
