forked from lix-project/lix
makeFixedOutputPath(): Drop superfluous HashType argument
This commit is contained in:
parent
06bbfb6004
commit
ee22a91ab8
|
@ -288,8 +288,8 @@ SV * makeFixedOutputPath(int recursive, char * algo, char * hash, char * name)
|
||||||
PPCODE:
|
PPCODE:
|
||||||
try {
|
try {
|
||||||
HashType ht = parseHashType(algo);
|
HashType ht = parseHashType(algo);
|
||||||
Path path = store()->makeFixedOutputPath(recursive, ht,
|
Hash h = parseHash16or32(ht, hash);
|
||||||
parseHash16or32(ht, hash), name);
|
Path path = store()->makeFixedOutputPath(recursive, h, name);
|
||||||
XPUSHs(sv_2mortal(newSVpv(path.c_str(), 0)));
|
XPUSHs(sv_2mortal(newSVpv(path.c_str(), 0)));
|
||||||
} catch (Error & e) {
|
} catch (Error & e) {
|
||||||
croak("%s", e.what());
|
croak("%s", e.what());
|
||||||
|
|
|
@ -624,7 +624,7 @@ static void prim_derivationStrict(EvalState & state, const Pos & pos, Value * *
|
||||||
outputHash = printHash(h);
|
outputHash = printHash(h);
|
||||||
if (outputHashRecursive) outputHashAlgo = "r:" + outputHashAlgo;
|
if (outputHashRecursive) outputHashAlgo = "r:" + outputHashAlgo;
|
||||||
|
|
||||||
Path outPath = state.store->makeFixedOutputPath(outputHashRecursive, ht, h, drvName);
|
Path outPath = state.store->makeFixedOutputPath(outputHashRecursive, h, drvName);
|
||||||
drv.env["out"] = outPath;
|
drv.env["out"] = outPath;
|
||||||
drv.outputs["out"] = DerivationOutput(outPath, outputHashAlgo, outputHash);
|
drv.outputs["out"] = DerivationOutput(outPath, outputHashAlgo, outputHash);
|
||||||
}
|
}
|
||||||
|
|
|
@ -209,7 +209,7 @@ Path BinaryCacheStore::addToStore(const string & name, const Path & srcPath,
|
||||||
}
|
}
|
||||||
|
|
||||||
ValidPathInfo info;
|
ValidPathInfo info;
|
||||||
info.path = makeFixedOutputPath(recursive, hashAlgo, h, name);
|
info.path = makeFixedOutputPath(recursive, h, name);
|
||||||
|
|
||||||
addToStore(info, *sink.s, repair);
|
addToStore(info, *sink.s, repair);
|
||||||
|
|
||||||
|
|
|
@ -2706,8 +2706,8 @@ void DerivationGoal::registerOutputs()
|
||||||
hash). */
|
hash). */
|
||||||
if (i.second.hash != "") {
|
if (i.second.hash != "") {
|
||||||
|
|
||||||
bool recursive; HashType ht; Hash h;
|
bool recursive; Hash h;
|
||||||
i.second.parseHashInfo(recursive, ht, h);
|
i.second.parseHashInfo(recursive, h);
|
||||||
|
|
||||||
if (!recursive) {
|
if (!recursive) {
|
||||||
/* The output path should be a regular file without
|
/* The output path should be a regular file without
|
||||||
|
@ -2719,11 +2719,11 @@ void DerivationGoal::registerOutputs()
|
||||||
|
|
||||||
/* Check the hash. In hash mode, move the path produced by
|
/* Check the hash. In hash mode, move the path produced by
|
||||||
the derivation to its content-addressed location. */
|
the derivation to its content-addressed location. */
|
||||||
Hash h2 = recursive ? hashPath(ht, actualPath).first : hashFile(ht, actualPath);
|
Hash h2 = recursive ? hashPath(h.type, actualPath).first : hashFile(h.type, actualPath);
|
||||||
if (buildMode == bmHash) {
|
if (buildMode == bmHash) {
|
||||||
Path dest = worker.store.makeFixedOutputPath(recursive, ht, h2, drv->env["name"]);
|
Path dest = worker.store.makeFixedOutputPath(recursive, h2, drv->env["name"]);
|
||||||
printMsg(lvlError, format("build produced path ‘%1%’ with %2% hash ‘%3%’")
|
printMsg(lvlError, format("build produced path ‘%1%’ with %2% hash ‘%3%’")
|
||||||
% dest % printHashType(ht) % printHash16or32(h2));
|
% dest % printHashType(h.type) % printHash16or32(h2));
|
||||||
if (worker.store.isValidPath(dest))
|
if (worker.store.isValidPath(dest))
|
||||||
return;
|
return;
|
||||||
Path actualDest = worker.store.toRealPath(dest);
|
Path actualDest = worker.store.toRealPath(dest);
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
namespace nix {
|
namespace nix {
|
||||||
|
|
||||||
|
|
||||||
void DerivationOutput::parseHashInfo(bool & recursive, HashType & hashType, Hash & hash) const
|
void DerivationOutput::parseHashInfo(bool & recursive, Hash & hash) const
|
||||||
{
|
{
|
||||||
recursive = false;
|
recursive = false;
|
||||||
string algo = hashAlgo;
|
string algo = hashAlgo;
|
||||||
|
@ -19,7 +19,7 @@ void DerivationOutput::parseHashInfo(bool & recursive, HashType & hashType, Hash
|
||||||
algo = string(algo, 2);
|
algo = string(algo, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
hashType = parseHashType(algo);
|
HashType hashType = parseHashType(algo);
|
||||||
if (hashType == htUnknown)
|
if (hashType == htUnknown)
|
||||||
throw Error(format("unknown hash algorithm ‘%1%’") % algo);
|
throw Error(format("unknown hash algorithm ‘%1%’") % algo);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct DerivationOutput
|
||||||
this->hashAlgo = hashAlgo;
|
this->hashAlgo = hashAlgo;
|
||||||
this->hash = hash;
|
this->hash = hash;
|
||||||
}
|
}
|
||||||
void parseHashInfo(bool & recursive, HashType & hashType, Hash & hash) const;
|
void parseHashInfo(bool & recursive, Hash & hash) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::map<string, DerivationOutput> DerivationOutputs;
|
typedef std::map<string, DerivationOutput> DerivationOutputs;
|
||||||
|
|
|
@ -232,7 +232,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
|
||||||
|
|
||||||
Path expectedStorePath;
|
Path expectedStorePath;
|
||||||
if (expectedHash) {
|
if (expectedHash) {
|
||||||
expectedStorePath = store->makeFixedOutputPath(unpack, expectedHash.type, expectedHash, name);
|
expectedStorePath = store->makeFixedOutputPath(unpack, expectedHash, name);
|
||||||
if (store->isValidPath(expectedStorePath))
|
if (store->isValidPath(expectedStorePath))
|
||||||
return expectedStorePath;
|
return expectedStorePath;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +282,7 @@ Path Downloader::downloadCached(ref<Store> store, const string & url_, bool unpa
|
||||||
StringSink sink;
|
StringSink sink;
|
||||||
dumpString(*res.data, sink);
|
dumpString(*res.data, sink);
|
||||||
Hash hash = hashString(expectedHash ? expectedHash.type : htSHA256, *res.data);
|
Hash hash = hashString(expectedHash ? expectedHash.type : htSHA256, *res.data);
|
||||||
info.path = store->makeFixedOutputPath(false, hash.type, hash, name);
|
info.path = store->makeFixedOutputPath(false, hash, name);
|
||||||
info.narHash = hashString(htSHA256, *sink.s);
|
info.narHash = hashString(htSHA256, *sink.s);
|
||||||
store->addToStore(info, *sink.s, false, true);
|
store->addToStore(info, *sink.s, false, true);
|
||||||
storePath = info.path;
|
storePath = info.path;
|
||||||
|
|
|
@ -486,9 +486,9 @@ void LocalStore::checkDerivationOutputs(const Path & drvPath, const Derivation &
|
||||||
if (out == drv.outputs.end())
|
if (out == drv.outputs.end())
|
||||||
throw Error(format("derivation ‘%1%’ does not have an output named ‘out’") % drvPath);
|
throw Error(format("derivation ‘%1%’ does not have an output named ‘out’") % drvPath);
|
||||||
|
|
||||||
bool recursive; HashType ht; Hash h;
|
bool recursive; Hash h;
|
||||||
out->second.parseHashInfo(recursive, ht, h);
|
out->second.parseHashInfo(recursive, h);
|
||||||
Path outPath = makeFixedOutputPath(recursive, ht, h, drvName);
|
Path outPath = makeFixedOutputPath(recursive, h, drvName);
|
||||||
|
|
||||||
StringPairs::const_iterator j = drv.env.find("out");
|
StringPairs::const_iterator j = drv.env.find("out");
|
||||||
if (out->second.path != outPath || j == drv.env.end() || j->second != outPath)
|
if (out->second.path != outPath || j == drv.env.end() || j->second != outPath)
|
||||||
|
@ -940,7 +940,7 @@ Path LocalStore::addToStoreFromDump(const string & dump, const string & name,
|
||||||
{
|
{
|
||||||
Hash h = hashString(hashAlgo, dump);
|
Hash h = hashString(hashAlgo, dump);
|
||||||
|
|
||||||
Path dstPath = makeFixedOutputPath(recursive, hashAlgo, h, name);
|
Path dstPath = makeFixedOutputPath(recursive, h, name);
|
||||||
|
|
||||||
addTempRoot(dstPath);
|
addTempRoot(dstPath);
|
||||||
|
|
||||||
|
|
|
@ -191,13 +191,13 @@ Path Store::makeOutputPath(const string & id,
|
||||||
|
|
||||||
|
|
||||||
Path Store::makeFixedOutputPath(bool recursive,
|
Path Store::makeFixedOutputPath(bool recursive,
|
||||||
HashType hashAlgo, Hash hash, string name) const
|
const Hash & hash, const string & name) const
|
||||||
{
|
{
|
||||||
return hashAlgo == htSHA256 && recursive
|
return hash.type == htSHA256 && recursive
|
||||||
? makeStorePath("source", hash, name)
|
? makeStorePath("source", hash, name)
|
||||||
: makeStorePath("output:out", hashString(htSHA256,
|
: makeStorePath("output:out", hashString(htSHA256,
|
||||||
"fixed:out:" + (recursive ? (string) "r:" : "") +
|
"fixed:out:" + (recursive ? (string) "r:" : "") +
|
||||||
printHashType(hashAlgo) + ":" + printHash(hash) + ":"),
|
printHashType(hash.type) + ":" + printHash(hash) + ":"),
|
||||||
name);
|
name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,10 +205,9 @@ Path Store::makeFixedOutputPath(bool recursive,
|
||||||
std::pair<Path, Hash> Store::computeStorePathForPath(const Path & srcPath,
|
std::pair<Path, Hash> Store::computeStorePathForPath(const Path & srcPath,
|
||||||
bool recursive, HashType hashAlgo, PathFilter & filter) const
|
bool recursive, HashType hashAlgo, PathFilter & filter) const
|
||||||
{
|
{
|
||||||
HashType ht(hashAlgo);
|
Hash h = recursive ? hashPath(hashAlgo, srcPath, filter).first : hashFile(hashAlgo, srcPath);
|
||||||
Hash h = recursive ? hashPath(ht, srcPath, filter).first : hashFile(ht, srcPath);
|
|
||||||
string name = baseNameOf(srcPath);
|
string name = baseNameOf(srcPath);
|
||||||
Path dstPath = makeFixedOutputPath(recursive, hashAlgo, h, name);
|
Path dstPath = makeFixedOutputPath(recursive, h, name);
|
||||||
return std::pair<Path, Hash>(dstPath, h);
|
return std::pair<Path, Hash>(dstPath, h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -232,7 +232,7 @@ public:
|
||||||
const Hash & hash, const string & name) const;
|
const Hash & hash, const string & name) const;
|
||||||
|
|
||||||
Path makeFixedOutputPath(bool recursive,
|
Path makeFixedOutputPath(bool recursive,
|
||||||
HashType hashAlgo, Hash hash, string name) const;
|
const Hash & hash, const string & name) const;
|
||||||
|
|
||||||
/* This is the preparatory part of addToStore() and
|
/* This is the preparatory part of addToStore() and
|
||||||
addToStoreFixed(); it computes the store path to which srcPath
|
addToStoreFixed(); it computes the store path to which srcPath
|
||||||
|
|
|
@ -146,7 +146,7 @@ int main(int argc, char * * argv)
|
||||||
Path storePath;
|
Path storePath;
|
||||||
if (args.size() == 2) {
|
if (args.size() == 2) {
|
||||||
expectedHash = parseHash16or32(ht, args[1]);
|
expectedHash = parseHash16or32(ht, args[1]);
|
||||||
storePath = store->makeFixedOutputPath(unpack, ht, expectedHash, name);
|
storePath = store->makeFixedOutputPath(unpack, expectedHash, name);
|
||||||
if (store->isValidPath(storePath))
|
if (store->isValidPath(storePath))
|
||||||
hash = expectedHash;
|
hash = expectedHash;
|
||||||
else
|
else
|
||||||
|
@ -197,7 +197,7 @@ int main(int argc, char * * argv)
|
||||||
into the Nix store. */
|
into the Nix store. */
|
||||||
storePath = store->addToStore(name, tmpFile, unpack, ht);
|
storePath = store->addToStore(name, tmpFile, unpack, ht);
|
||||||
|
|
||||||
assert(storePath == store->makeFixedOutputPath(unpack, ht, hash, name));
|
assert(storePath == store->makeFixedOutputPath(unpack, hash, name));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!printPath)
|
if (!printPath)
|
||||||
|
|
|
@ -213,8 +213,7 @@ static void opPrintFixedPath(Strings opFlags, Strings opArgs)
|
||||||
string name = *i++;
|
string name = *i++;
|
||||||
|
|
||||||
cout << format("%1%\n") %
|
cout << format("%1%\n") %
|
||||||
store->makeFixedOutputPath(recursive, hashAlgo,
|
store->makeFixedOutputPath(recursive, parseHash16or32(hashAlgo, hash), name);
|
||||||
parseHash16or32(hashAlgo, hash), name);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue