mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 20:20:58 +01:00
This commit is contained in:
parent
9c46444641
commit
bcf9d3ab2f
11 changed files with 194 additions and 20 deletions
|
|
@ -773,10 +773,11 @@ void DerivationGoal::haveDerivation()
|
|||
/* Check what outputs paths are not already valid. */
|
||||
PathSet invalidOutputs = checkPathValidity(false);
|
||||
|
||||
|
||||
|
||||
/* If they are all valid, then we're done. */
|
||||
if (invalidOutputs.size() == 0) {
|
||||
|
||||
printMsg(lvlError, format("Check State VALIDITY BEFORE: `%1%'") % drvPath);
|
||||
|
||||
amDone(ecSuccess);
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ const string drvExtension = ".drv";
|
|||
struct DerivationOutput
|
||||
{
|
||||
Path path;
|
||||
string hashAlgo; /* hash used for expected hash computation */
|
||||
string hash; /* expected hash, may be null */
|
||||
string hashAlgo; /* hash used for expected hash computation */
|
||||
string hash; /* expected hash, may be null */
|
||||
DerivationOutput()
|
||||
{
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
#include "derivations.hh"
|
||||
#include "misc.hh"
|
||||
|
||||
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
|
|
@ -19,7 +19,7 @@
|
|||
#include <sys/stat.h>
|
||||
#include <unistd.h>
|
||||
#include <utime.h>
|
||||
|
||||
#include <time.h>
|
||||
|
||||
namespace nix {
|
||||
|
||||
|
|
@ -82,6 +82,11 @@ static TableId dbDerivers = 0;
|
|||
*/
|
||||
static TableId dbStateCounters = 0;
|
||||
|
||||
/* Path
|
||||
|
||||
*/
|
||||
static TableId dbUpdatedDerivations = 0;
|
||||
|
||||
|
||||
bool Substitute::operator == (const Substitute & sub) const
|
||||
{
|
||||
|
|
@ -147,6 +152,7 @@ LocalStore::LocalStore(bool reserveSpace)
|
|||
dbSubstitutes = nixDB.openTable("substitutes");
|
||||
dbDerivers = nixDB.openTable("derivers");
|
||||
dbStateCounters = nixDB.openTable("statecounters");
|
||||
dbUpdatedDerivations = nixDB.openTable("updatedDerivations");
|
||||
|
||||
int curSchema = 0;
|
||||
Path schemaFN = nixDBPath + "/schema";
|
||||
|
|
@ -1217,6 +1223,79 @@ PathSet LocalStore::getStateReferencesClosure(const Path & path)
|
|||
}
|
||||
|
||||
|
||||
//TODO
|
||||
void setUpdatedStateDerivation(const Path & newdrv, const Path & olddrv)
|
||||
{
|
||||
Transaction txn(nixDB);
|
||||
|
||||
Strings data;
|
||||
data.push_back(olddrv);
|
||||
|
||||
time_t timestamp;
|
||||
time (×tamp);
|
||||
string timestamp_s = time_t2string(timestamp);
|
||||
printMsg(lvlError, format("Adding new drv (%1%) to replace old drv (%2%) with timestamp: %3%") % newdrv % olddrv % timestamp_s);
|
||||
data.push_back(timestamp_s); //create a timestamp to remember which one was last inserted
|
||||
|
||||
nixDB.setStrings(txn, dbUpdatedDerivations, newdrv, data);
|
||||
|
||||
//TODO check wheter were not duplicating an entry !!
|
||||
|
||||
txn.commit();
|
||||
}
|
||||
|
||||
//TODO
|
||||
void LocalStore::setUpdatedStateDerivation(const Path & newdrv, const Path & olddrv)
|
||||
{
|
||||
nix::setUpdatedStateDerivation(newdrv, olddrv);
|
||||
}
|
||||
|
||||
//TODO
|
||||
Path getUpdatedStateDerivation(const Path & olddrv) //TODO Path updateStateDerivationPath(const Path & storepath)
|
||||
{
|
||||
Transaction txn(nixDB); //TODO should u do a transaction here? ... this might delay the process ...
|
||||
|
||||
Path storepath = olddrv; //TODO FIX
|
||||
Path drvPath = getStateDerivation(storepath);
|
||||
Path newDerivation = drvPath; //the new drv path first equals the old one until a new one is found
|
||||
|
||||
Strings keys;
|
||||
|
||||
//Get the (multiple) derivations of references
|
||||
nixDB.enumTable(txn, dbUpdatedDerivations, keys);
|
||||
for (Strings::iterator i = keys.begin(); i != keys.end(); ++i)
|
||||
{
|
||||
string key = *i;
|
||||
printMsg(lvlError, format("getUpdatedStateDerivation KEY: `%1%'") % key);
|
||||
|
||||
Strings data;
|
||||
nixDB.queryStrings(txn, dbUpdatedDerivations, key, data);
|
||||
for (Strings::iterator j = data.begin(); j != data.end(); ++j)
|
||||
{
|
||||
printMsg(lvlError, format("getUpdatedStateDerivation: `%1%'") % *j);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Set the current derivation of derivers
|
||||
|
||||
|
||||
//if()
|
||||
// throw Error(format("T derivation: `%1%'") % path);
|
||||
|
||||
txn.commit();
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
//TODO
|
||||
Path LocalStore::getUpdatedStateDerivation(const Path & olddrv)
|
||||
{
|
||||
return nix::getUpdatedStateDerivation(olddrv);
|
||||
}
|
||||
|
||||
|
||||
/* Upgrade from schema 1 (Nix <= 0.7) to schema 2 (Nix >= 0.8). */
|
||||
static void upgradeStore07()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -83,6 +83,11 @@ public:
|
|||
Derivation getStateDerivation(const Path & path);
|
||||
|
||||
PathSet getStateReferencesClosure(const Path & path);
|
||||
|
||||
void setUpdatedStateDerivation(const Path & newdrv, const Path & olddrv);
|
||||
|
||||
Path getUpdatedStateDerivation(const Path & olddrv);
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -402,5 +402,18 @@ PathSet RemoteStore::getStateReferencesClosure(const Path & path)
|
|||
return empty;
|
||||
}
|
||||
|
||||
//TODO
|
||||
void RemoteStore::setUpdatedStateDerivation(const Path & newdrv, const Path & olddrv)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//TODO
|
||||
Path RemoteStore::getUpdatedStateDerivation(const Path & olddrv)
|
||||
{
|
||||
Path p;
|
||||
return p;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,6 +72,10 @@ public:
|
|||
|
||||
PathSet getStateReferencesClosure(const Path & path);
|
||||
|
||||
void setUpdatedStateDerivation(const Path & newdrv, const Path & olddrv);
|
||||
|
||||
Path getUpdatedStateDerivation(const Path & olddrv);
|
||||
|
||||
|
||||
private:
|
||||
AutoCloseFD fdSocket;
|
||||
|
|
|
|||
|
|
@ -193,6 +193,12 @@ public:
|
|||
/* TODO */
|
||||
virtual PathSet getStateReferencesClosure(const Path & path) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual void setUpdatedStateDerivation(const Path & newdrv, const Path & olddrv) = 0;
|
||||
|
||||
/* TODO */
|
||||
virtual Path getUpdatedStateDerivation(const Path & olddrv) = 0;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue