mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Almost finished the identifier/user/multiple-derivations mod
This commit is contained in:
parent
b909d57f5d
commit
76f5c8ba07
6 changed files with 50 additions and 13 deletions
|
|
@ -2480,6 +2480,8 @@ void LocalStore::buildDerivations(const PathSet & drvPaths)
|
|||
format("building %1%") % showPaths(drvPaths));
|
||||
|
||||
//Just before we build, we resolve the multiple derivations linked to one store path issue, by choosing the latest derivation
|
||||
|
||||
printMsg(lvlError, format("updateAllStateDerivations %1%") % showPaths(drvPaths));
|
||||
store->updateAllStateDerivations();
|
||||
|
||||
Worker worker;
|
||||
|
|
|
|||
|
|
@ -57,6 +57,7 @@ struct DerivationStateOutput
|
|||
{
|
||||
}
|
||||
|
||||
//TODO add const ??
|
||||
DerivationStateOutput(Path statepath, string componentHash, string hashAlgo, string hash, string stateIdentifier, string enabled, string shared, string synchronization, string createDirsBeforeInstall, string runtimeStateParamters, string username, bool check=true)
|
||||
{
|
||||
if(check){
|
||||
|
|
|
|||
|
|
@ -406,27 +406,42 @@ void setDeriver(const Transaction & txn, const Path & storePath, const Path & de
|
|||
if (!isRealisablePath(txn, storePath))
|
||||
throw Error(format("path `%1%' is not valid") % storePath);
|
||||
|
||||
Derivation drv = derivationFromPath(deriver); //Error if its a state component
|
||||
Derivation drv = derivationFromPath(deriver); //Redirect if its a state component
|
||||
if (drv.outputs.size() != 0)
|
||||
throw Error(format("path `%1%' is a state Path and its derivers need to be set by setDerivers") % storePath);
|
||||
addStateDeriver(txn, storePath, deriver); //TODO remove store->
|
||||
else
|
||||
nixDB.setString(txn, dbDerivers, storePath, deriver);
|
||||
}
|
||||
|
||||
|
||||
void setDerivers(const Transaction & txn, const Path & storePath, const PathSet & derivers)
|
||||
void addStateDeriver(const Transaction & txn, const Path & storePath, const Path & deriver)
|
||||
{
|
||||
printMsg(lvlError, format("Adding State Derivers into DB %1%") % deriver);
|
||||
|
||||
assertStorePath(storePath);
|
||||
if (deriver == "") return;
|
||||
assertStorePath(deriver);
|
||||
if (!isRealisablePath(txn, storePath))
|
||||
throw Error(format("path `%1%' is not valid") % storePath);
|
||||
|
||||
Derivation drv = derivationFromPath(deriver);
|
||||
string identifier = drv.stateOutputs.find("state")->second.stateIdentifier;
|
||||
string user = drv.stateOutputs.find("state")->second.username;
|
||||
|
||||
PathSet currentDerivers = queryDerivers(txn, storePath, identifier, user);
|
||||
PathSet updatedDerivers = mergeNewDerivationIntoList(storePath, deriver, currentDerivers, true);
|
||||
|
||||
Strings data;
|
||||
for (PathSet::iterator i = derivers.begin(); i != derivers.end(); ++i){
|
||||
for (PathSet::iterator i = updatedDerivers.begin(); i != updatedDerivers.end(); ++i){
|
||||
string deriver = *i;
|
||||
|
||||
//TODO Remove obsolete check
|
||||
assertStorePath(deriver);
|
||||
Derivation drv = derivationFromPath(deriver);
|
||||
if (drv.outputs.size() == 0) //Error if its not a state component
|
||||
throw Error(format("path `%1%' is a NOT state Path at setDerivers") % storePath);
|
||||
throw Error(format("path `%1%' is a NOT state Path at addStateDeriver") % storePath);
|
||||
//TODO Remove obsolete check
|
||||
|
||||
data.push_back(deriver);
|
||||
}
|
||||
|
||||
|
|
@ -440,7 +455,14 @@ Path queryDeriver(const Transaction & txn, const Path & storePath)
|
|||
throw Error(format("path `%1%' is not valid") % storePath);
|
||||
Path deriver;
|
||||
|
||||
if (nixDB.queryString(txn, dbDerivers, storePath, deriver))
|
||||
|
||||
bool b = nixDB.queryString(txn, dbDerivers, storePath, deriver);
|
||||
|
||||
Derivation drv = derivationFromPath(deriver); //Redirect if its a state component
|
||||
if (drv.outputs.size() != 0)
|
||||
throw Error(format("This deriver `%1%' is a state deriver, u should use queryDerivers instead of queryDeriver") % deriver);
|
||||
|
||||
if (b)
|
||||
return deriver;
|
||||
else
|
||||
return "";
|
||||
|
|
@ -474,9 +496,6 @@ PathSet queryDerivers(const Transaction & txn, const Path & storePath, const str
|
|||
filtereddata.insert(derivationpath);
|
||||
}
|
||||
|
||||
if(filtereddata.size() == 0)
|
||||
throw Error(format("There are no matching derivations with identifier %2% and user %3% for %1%") % storePath % identifier % user);
|
||||
|
||||
return filtereddata;
|
||||
}
|
||||
|
||||
|
|
@ -1255,7 +1274,7 @@ PathSet LocalStore::getStateReferencesClosure(const Path & path)
|
|||
//Merges a new .... into the list TODO
|
||||
//This is all about one store path
|
||||
//We assume newdrv is the newest
|
||||
PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, const PathSet drvs)
|
||||
PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, const PathSet drvs, bool deleteDrvs)
|
||||
{
|
||||
PathSet newdrvs;
|
||||
|
||||
|
|
@ -1272,6 +1291,12 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
|
|||
|
||||
if( !(identifier == getIdentifier && getUser == user) ) //only insert if it doenst already exist
|
||||
newdrvs.insert(drv);
|
||||
else{
|
||||
if(deleteDrvs){
|
||||
printMsg(lvlError, format("Deleting decrepated state derivation: %1%") % drv);
|
||||
deletePath(drv); //Deletes the DRV from DISK!
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newdrvs.insert(newdrv);
|
||||
|
|
@ -1282,6 +1307,9 @@ PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv,
|
|||
//TODO add mergeNewDerivationIntoList
|
||||
void updateAllStateDerivations()
|
||||
{
|
||||
|
||||
//call AddStateDerivation !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
|
||||
/*
|
||||
Transaction txn(nixDB);
|
||||
|
||||
|
|
|
|||
|
|
@ -178,6 +178,12 @@ void deletePathWrapped(const Path & path,
|
|||
|
||||
void deletePathWrapped(const Path & path);
|
||||
|
||||
/* TODO */
|
||||
void addStateDeriver(const Transaction & txn, const Path & storePath, const Path & deriver);
|
||||
|
||||
/* TODO */
|
||||
PathSet mergeNewDerivationIntoList(const Path & storepath, const Path & newdrv, const PathSet drvs, bool deleteDrvs = false);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -60,9 +60,9 @@ void createStateDirs(const DerivationStateOutputDirs & stateOutputDirs, const De
|
|||
executeAndPrintShellCommand("mkdir -p " + repos, "mkdir");
|
||||
|
||||
if(IsDirectory(repos))
|
||||
executeAndPrintShellCommand(svnadminbin + " create " + repos, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit than ??
|
||||
else
|
||||
printMsg(lvlError, format("Repos %1% already exists, so we use that repository") % repos);
|
||||
else
|
||||
executeAndPrintShellCommand(svnadminbin + " create " + repos, "svnadmin"); //TODO create as nixbld.nixbld chmod 700... can you still commit than ??
|
||||
|
||||
if(d.type == "interval"){
|
||||
intervalPaths.insert(statePath);
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
|
|||
# if CDPATH is set.
|
||||
(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
|
||||
|
||||
relink_command="(cd /root/dev/nix-state/src/nix-state; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/root/bin:/nix/var/nix/profiles/per-user/root/profile/bin:/nix/var/nix/profiles/per-user/root/profile/sbin:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/var/setuid-wrappers:/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin:/home/share/bin:/home/share/bin:/home/share/bin\"; export PATH; g++ -I./.. -I/root/.nix-profile/include -I/root/.nix-profile/include -I./../libutil -I./../libstore -I./../libmain -D_FILE_OFFSET_BITS=64 -g -O2 -o \$progdir/\$file nix-state.o ../libmain/.libs/libmain.so -L/tmp/nix-14177-0/build/i686-pc-linux-gnu/libstdc++-v3/src -L/tmp/nix-14177-0/build/i686-pc-linux-gnu/libstdc++-v3/src/.libs ../libstore/.libs/libstore.so /root/dev/nix-state/src/libutil/.libs/libutil.so ../libutil/.libs/libutil.so /root/dev/nix-state/src/boost/format/.libs/libformat.so ../boost/format/.libs/libformat.so /nix/store/kpqz9a4clx96538rr0zmsy3v40iqd88g-gcc-4.1.1/lib/libstdc++.so -L/root/.nix-profile/lib -ldb_cxx /nix/store/pkmzbb613wa8cwngx8jjb5jaic8yhyzs-aterm-2.4.2-fixes/lib/libATerm -lpthread -Wl,--rpath -Wl,/root/dev/nix-state/src/libmain/.libs -Wl,--rpath -Wl,/root/dev/nix-state/src/libstore/.libs -Wl,--rpath -Wl,/root/dev/nix-state/src/libutil/.libs -Wl,--rpath -Wl,/root/dev/nix-state/src/boost/format/.libs -Wl,--rpath -Wl,/nix/store/kpqz9a4clx96538rr0zmsy3v40iqd88g-gcc-4.1.1/lib -Wl,--rpath -Wl,/nix/store/pkmzbb613wa8cwngx8jjb5jaic8yhyzs-aterm-2.4.2-fixes/lib -Wl,--rpath -Wl,/nixstate/nix/lib/nix -Wl,--rpath -Wl,/nix/store/kpqz9a4clx96538rr0zmsy3v40iqd88g-gcc-4.1.1/lib -Wl,--rpath -Wl,/nix/store/pkmzbb613wa8cwngx8jjb5jaic8yhyzs-aterm-2.4.2-fixes/lib)"
|
||||
relink_command="(cd /root/dev/nix-state/src/nix-state; { test -z \"\${LIBRARY_PATH+set}\" || unset LIBRARY_PATH || { LIBRARY_PATH=; export LIBRARY_PATH; }; }; { test -z \"\${COMPILER_PATH+set}\" || unset COMPILER_PATH || { COMPILER_PATH=; export COMPILER_PATH; }; }; { test -z \"\${GCC_EXEC_PREFIX+set}\" || unset GCC_EXEC_PREFIX || { GCC_EXEC_PREFIX=; export GCC_EXEC_PREFIX; }; }; { test -z \"\${LD_RUN_PATH+set}\" || unset LD_RUN_PATH || { LD_RUN_PATH=; export LD_RUN_PATH; }; }; { test -z \"\${LD_LIBRARY_PATH+set}\" || unset LD_LIBRARY_PATH || { LD_LIBRARY_PATH=; export LD_LIBRARY_PATH; }; }; PATH=\"/root/bin:/nix/var/nix/profiles/per-user/root/profile/bin:/nix/var/nix/profiles/per-user/root/profile/sbin:/nix/var/nix/profiles/default/bin:/nix/var/nix/profiles/default/sbin:/var/setuid-wrappers:/var/run/current-system/sw/bin:/var/run/current-system/sw/sbin:/home/share/bin:/home/share/bin:/home/share/bin\"; export PATH; g++ -I./.. -I/root/.nix-profile/include -I/root/.nix-profile/include -I./../libutil -I./../libstore -I./../libmain -D_FILE_OFFSET_BITS=64 -g -O2 -o \$progdir/\$file nix-state.o ../libmain/.libs/libmain.so -L/tmp/nix-16643-9/build/i686-pc-linux-gnu/libstdc++-v3/src -L/tmp/nix-16643-9/build/i686-pc-linux-gnu/libstdc++-v3/src/.libs ../libstore/.libs/libstore.so /root/dev/nix-state/src/libutil/.libs/libutil.so ../libutil/.libs/libutil.so /root/dev/nix-state/src/boost/format/.libs/libformat.so ../boost/format/.libs/libformat.so /nix/store/vv1f74giym9ixgp10jl9a8sgsjylf9n1-gcc-4.1.2/lib/libstdc++.so -L/root/.nix-profile/lib -ldb_cxx /nix/store/y8lwp0gz4ag6yiwnywv5xgfbay8f6l2n-aterm-2.4.2-fixes/lib/libATerm -lpthread -Wl,--rpath -Wl,/root/dev/nix-state/src/libmain/.libs -Wl,--rpath -Wl,/root/dev/nix-state/src/libstore/.libs -Wl,--rpath -Wl,/root/dev/nix-state/src/libutil/.libs -Wl,--rpath -Wl,/root/dev/nix-state/src/boost/format/.libs -Wl,--rpath -Wl,/nix/store/vv1f74giym9ixgp10jl9a8sgsjylf9n1-gcc-4.1.2/lib -Wl,--rpath -Wl,/nix/store/y8lwp0gz4ag6yiwnywv5xgfbay8f6l2n-aterm-2.4.2-fixes/lib -Wl,--rpath -Wl,/nixstate/nix/lib/nix -Wl,--rpath -Wl,/nix/store/vv1f74giym9ixgp10jl9a8sgsjylf9n1-gcc-4.1.2/lib -Wl,--rpath -Wl,/nix/store/y8lwp0gz4ag6yiwnywv5xgfbay8f6l2n-aterm-2.4.2-fixes/lib)"
|
||||
|
||||
# This environment variable determines our operation mode.
|
||||
if test "$libtool_install_magic" = "%%%MAGIC variable%%%"; then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue