mirror of
https://github.com/NixOS/nix.git
synced 2025-11-27 04:30:59 +01:00
This commit is contained in:
parent
36b79c7135
commit
96a62bb7e6
9 changed files with 274 additions and 281 deletions
|
|
@ -120,8 +120,7 @@ Path makeStorePath(const string & type, const Hash & hash, const string & suffix
|
|||
Path makeStatePath(const string & componentHash, const string & suffix, const string & stateIdentifier)
|
||||
{
|
||||
string suffix_stateIdentifier = stateIdentifier;
|
||||
if(suffix_stateIdentifier != "")
|
||||
suffix_stateIdentifier = "-" + suffix_stateIdentifier;
|
||||
suffix_stateIdentifier = "-" + suffix_stateIdentifier;
|
||||
|
||||
string username = getCallingUserName(); //Can and Should NOT be faked
|
||||
|
||||
|
|
@ -152,32 +151,26 @@ void checkStatePath(const Derivation & drv)
|
|||
Error(format("The statepath from the Derivation does not match the recalculated statepath, are u trying to spoof the statepath?"));
|
||||
}
|
||||
|
||||
void calculateStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier, Path & path)
|
||||
Path getStateReposPath(const string & type, const Path statePath)
|
||||
{
|
||||
//This is a little trick: we could use the same hash as the statepath, but we change it so the repository also gets a unique scannable hash
|
||||
Hash hash = hashString(htSHA256, statePath);
|
||||
|
||||
string suffix_stateIdentifier = stateIdentifier;
|
||||
if(suffix_stateIdentifier != "")
|
||||
suffix_stateIdentifier = "-" + suffix_stateIdentifier;
|
||||
|
||||
//Extract suffix and stateIdentifier from statePath
|
||||
int pos = statePath.find_first_of("-");
|
||||
string suffix = statePath.substr(pos, statePath.length());
|
||||
|
||||
/* e.g., "source:sha256:1abc...:/nix/store:foo.tar.gz" */
|
||||
string s = type + ":sha256:" + printHash(hash) + ":"
|
||||
+ nixStoreState + ":" + suffix + ":" + stateIdentifier;
|
||||
+ nixStoreState + ":" + suffix;
|
||||
|
||||
checkStoreName(suffix);
|
||||
checkStoreName(stateIdentifier);
|
||||
|
||||
path = nixStoreStateRepos + "/"
|
||||
Path path = nixStoreStateRepos + "/"
|
||||
+ printHash32(compressHash(hashString(htSHA256, s), 20))
|
||||
+ "-" + suffix + suffix_stateIdentifier + "/";
|
||||
}
|
||||
|
||||
Path getStateReposPath(const string & type, const Path statePath, const string & suffix, const string & stateIdentifier)
|
||||
{
|
||||
Path path;
|
||||
calculateStateReposPath(type, statePath, suffix, stateIdentifier, path);
|
||||
return path;
|
||||
+ suffix + "/";
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue