mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Partially integrated state components (startscripts) into nix-env
This commit is contained in:
parent
13f321e397
commit
7424d72098
17 changed files with 241 additions and 122 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
use strict;
|
use strict;
|
||||||
use Cwd;
|
use Cwd;
|
||||||
use IO::Handle;
|
use IO::Handle;
|
||||||
|
use Fcntl;
|
||||||
|
|
||||||
STDOUT->autoflush(1);
|
STDOUT->autoflush(1);
|
||||||
|
|
||||||
|
|
@ -11,15 +12,29 @@ mkdir "$out", 0755 || die "error creating $out";
|
||||||
|
|
||||||
|
|
||||||
my $symlinks = 0;
|
my $symlinks = 0;
|
||||||
|
my %path_identifier;
|
||||||
|
my $srcDirSlashes = 3;
|
||||||
|
|
||||||
# For each activated package, create symlinks.
|
# For each activated package, create symlinks.
|
||||||
|
|
||||||
sub createLinks {
|
sub createLinks {
|
||||||
my $srcDir = shift;
|
my $srcDir = shift;
|
||||||
|
|
||||||
|
my @srcDirParts = split /\// , $srcDir;
|
||||||
|
my $srcDirRoot = "";
|
||||||
|
my $srcDirCounter=1;
|
||||||
|
while ($srcDirCounter <= $srcDirSlashes) {
|
||||||
|
$srcDirRoot = $srcDirRoot . "/" . $srcDirParts[$srcDirCounter];
|
||||||
|
$srcDirCounter++;
|
||||||
|
}
|
||||||
|
#print "srcDirRoot $srcDirRoot \n";
|
||||||
|
|
||||||
|
my $pkgStateIdentifier = $path_identifier{$srcDirRoot};
|
||||||
my $dstDir = shift;
|
my $dstDir = shift;
|
||||||
my $ignoreCollisions = shift;
|
my $ignoreCollisions = shift;
|
||||||
|
|
||||||
|
# print "createLinks $srcDir to $dstDir with iden $pkgStateIdentifier \n";
|
||||||
|
|
||||||
my @srcFiles = glob("$srcDir/*");
|
my @srcFiles = glob("$srcDir/*");
|
||||||
|
|
||||||
foreach my $srcFile (@srcFiles) {
|
foreach my $srcFile (@srcFiles) {
|
||||||
|
|
@ -41,6 +56,7 @@ sub createLinks {
|
||||||
|
|
||||||
lstat $dstFile;
|
lstat $dstFile;
|
||||||
|
|
||||||
|
#go recursive on directorys
|
||||||
if (-d _) {
|
if (-d _) {
|
||||||
createLinks($srcFile, $dstFile, $ignoreCollisions);
|
createLinks($srcFile, $dstFile, $ignoreCollisions);
|
||||||
}
|
}
|
||||||
|
|
@ -51,32 +67,68 @@ sub createLinks {
|
||||||
die "collission between directory `$srcFile' and non-directory `$target'";
|
die "collission between directory `$srcFile' and non-directory `$target'";
|
||||||
}
|
}
|
||||||
unlink $dstFile or die "error unlinking `$dstFile': $!";
|
unlink $dstFile or die "error unlinking `$dstFile': $!";
|
||||||
mkdir $dstFile, 0755 ||
|
mkdir $dstFile, 0755 || die "error creating directory `$dstFile': $!";
|
||||||
die "error creating directory `$dstFile': $!";
|
|
||||||
createLinks($target, $dstFile, $ignoreCollisions);
|
createLinks($target, $dstFile, $ignoreCollisions);
|
||||||
createLinks($srcFile, $dstFile, $ignoreCollisions);
|
createLinks($srcFile, $dstFile, $ignoreCollisions);
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
else {
|
||||||
|
|
||||||
|
# print "1STLINK $srcFile to $dstFile with iden $pkgStateIdentifier \n";
|
||||||
|
|
||||||
symlink($srcFile, $dstFile) ||
|
symlink($srcFile, $dstFile) ||
|
||||||
die "error creating link `$dstFile': $!";
|
die "error creating link `$dstFile': $!";
|
||||||
$symlinks++;
|
$symlinks++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
elsif (-l $dstFile) {
|
else {
|
||||||
|
|
||||||
|
# print "ELSE LINK $srcFile to $dstFile with iden $pkgStateIdentifier \n";
|
||||||
|
|
||||||
|
# if we have .....
|
||||||
|
if($pkgStateIdentifier ne "__NOSTATE__" && $pkgStateIdentifier ne ""){
|
||||||
|
|
||||||
|
my @pathparts = split /\// , $srcFile;
|
||||||
|
my $parentDir = $pathparts[scalar(@pathparts) - 2];
|
||||||
|
|
||||||
|
if( $parentDir eq "bin" || $parentDir eq "sbin"){ #hacky....
|
||||||
|
|
||||||
|
print "STATELINK $srcFile to $dstFile \n";
|
||||||
|
|
||||||
|
my $new_dstFile;
|
||||||
|
if($pkgStateIdentifier eq "__EMTPY__")
|
||||||
|
{ $new_dstFile = $dstFile; }
|
||||||
|
else
|
||||||
|
{ $new_dstFile = "$dstFile-$pkgStateIdentifier"; }
|
||||||
|
|
||||||
|
if (-l $new_dstFile) {
|
||||||
|
if (!$ignoreCollisions) {
|
||||||
|
my $target = readlink $new_dstFile;
|
||||||
|
die "(state) collission between `$srcFile' and `$target'";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sysopen (DSTFILEHANDLE, $new_dstFile, O_RDWR|O_EXCL|O_CREAT, 0755);
|
||||||
|
printf DSTFILEHANDLE "#! @shell@ \n";
|
||||||
|
printf DSTFILEHANDLE "/nixstate/nix/bin/nix-state --run --identifier=$pkgStateIdentifier \$* $srcFile \n";
|
||||||
|
close (DSTFILEHANDLE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
if (-l $dstFile) {
|
||||||
if (!$ignoreCollisions) {
|
if (!$ignoreCollisions) {
|
||||||
my $target = readlink $dstFile;
|
my $target = readlink $dstFile;
|
||||||
die "collission between `$srcFile' and `$target'";
|
die "collission between `$srcFile' and `$target'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else {
|
|
||||||
symlink($srcFile, $dstFile) ||
|
symlink($srcFile, $dstFile) ||
|
||||||
die "error creating link `$dstFile': $!";
|
die "error creating link `$dstFile': $!";
|
||||||
$symlinks++;
|
$symlinks++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -86,6 +138,7 @@ my %postponed;
|
||||||
sub addPkg;
|
sub addPkg;
|
||||||
sub addPkg {
|
sub addPkg {
|
||||||
my $pkgDir = shift;
|
my $pkgDir = shift;
|
||||||
|
my $pkgStateIdentifier = shift;
|
||||||
my $ignoreCollisions = shift;
|
my $ignoreCollisions = shift;
|
||||||
|
|
||||||
return if (defined $done{$pkgDir});
|
return if (defined $done{$pkgDir});
|
||||||
|
|
@ -108,10 +161,18 @@ sub addPkg {
|
||||||
|
|
||||||
|
|
||||||
# Symlink to the packages that have been installed explicitly by the user.
|
# Symlink to the packages that have been installed explicitly by the user.
|
||||||
my @args = split ' ', $ENV{"derivations"};
|
my @storePaths = split ' ', $ENV{"derivations"};
|
||||||
|
my @stateIdentifiers = split ' ', $ENV{"stateIdentifiers"};
|
||||||
|
my $si_counter = 0;
|
||||||
|
|
||||||
foreach my $pkgDir (sort @args) {
|
foreach my $pkgDir (@storePaths) { #Commented the sort out
|
||||||
addPkg($pkgDir, 0);
|
|
||||||
|
print "SP: $pkgDir \n";
|
||||||
|
$path_identifier{$pkgDir} = $stateIdentifiers[$si_counter];
|
||||||
|
print "SI: $path_identifier{$pkgDir} \n";
|
||||||
|
|
||||||
|
addPkg($pkgDir, $stateIdentifiers[$si_counter], 0);
|
||||||
|
$si_counter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -120,7 +181,8 @@ foreach my $pkgDir (sort @args) {
|
||||||
# installed as well). We do these later because they have a lower
|
# installed as well). We do these later because they have a lower
|
||||||
# priority in case of collisions.
|
# priority in case of collisions.
|
||||||
while (scalar(keys %postponed) > 0) {
|
while (scalar(keys %postponed) > 0) {
|
||||||
my @pkgDirs = keys %postponed;
|
|
||||||
|
my @pkgDirs = keys %postponed; # TODODODODODOD !!!!!!!!!!!!!!!!!!!!!
|
||||||
%postponed = ();
|
%postponed = ();
|
||||||
foreach my $pkgDir (sort @pkgDirs) {
|
foreach my $pkgDir (sort @pkgDirs) {
|
||||||
addPkg($pkgDir, 1);
|
addPkg($pkgDir, 1);
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
{system, derivations, manifest}:
|
{system, derivations, stateIdentifiers, manifest}:
|
||||||
|
|
||||||
derivation {
|
derivation {
|
||||||
name = "user-environment";
|
name = "user-environment";
|
||||||
system = system;
|
system = system;
|
||||||
builder = ./builder.pl;
|
builder = ./builder.pl;
|
||||||
derivations = derivations;
|
derivations = derivations;
|
||||||
|
stateIdentifiers = stateIdentifiers;
|
||||||
manifest = manifest;
|
manifest = manifest;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ bin_SCRIPTS = nix-collect-garbage \
|
||||||
nix-pack-closure nix-unpack-closure \
|
nix-pack-closure nix-unpack-closure \
|
||||||
nix-copy-closure
|
nix-copy-closure
|
||||||
|
|
||||||
noinst_SCRIPTS = nix-profile.sh generate-patches.pl find-runtime-roots.pl nix-readrevisions.sh nix-restorerevision.sh
|
noinst_SCRIPTS = nix-profile.sh generate-patches.pl find-runtime-roots.pl
|
||||||
|
|
||||||
nix-pull nix-push: readmanifest.pm readconfig.pm download-using-manifests.pl
|
nix-pull nix-push: readmanifest.pm readconfig.pm download-using-manifests.pl
|
||||||
|
|
||||||
|
|
@ -17,8 +17,6 @@ install-exec-local: readmanifest.pm download-using-manifests.pl find-runtime-roo
|
||||||
$(INSTALL_PROGRAM) download-using-manifests.pl $(DESTDIR)$(libexecdir)/nix
|
$(INSTALL_PROGRAM) download-using-manifests.pl $(DESTDIR)$(libexecdir)/nix
|
||||||
$(INSTALL_PROGRAM) find-runtime-roots.pl $(DESTDIR)$(libexecdir)/nix
|
$(INSTALL_PROGRAM) find-runtime-roots.pl $(DESTDIR)$(libexecdir)/nix
|
||||||
$(INSTALL_PROGRAM) generate-patches.pl $(DESTDIR)$(libexecdir)/nix
|
$(INSTALL_PROGRAM) generate-patches.pl $(DESTDIR)$(libexecdir)/nix
|
||||||
$(INSTALL_PROGRAM) nix-readrevisions.sh $(DESTDIR)$(libexecdir)/nix
|
|
||||||
$(INSTALL_PROGRAM) nix-restorerevision.sh $(DESTDIR)$(libexecdir)/nix
|
|
||||||
$(INSTALL) -d $(DESTDIR)$(sysconfdir)/nix
|
$(INSTALL) -d $(DESTDIR)$(sysconfdir)/nix
|
||||||
|
|
||||||
include ../substitute.mk
|
include ../substitute.mk
|
||||||
|
|
@ -34,6 +32,4 @@ EXTRA_DIST = nix-collect-garbage.in \
|
||||||
generate-patches.pl.in \
|
generate-patches.pl.in \
|
||||||
nix-pack-closure.in nix-unpack-closure.in \
|
nix-pack-closure.in nix-unpack-closure.in \
|
||||||
nix-copy-closure.in \
|
nix-copy-closure.in \
|
||||||
find-runtime-roots.pl.in \
|
find-runtime-roots.pl.in
|
||||||
nix-readrevisions.sh.in \
|
|
||||||
nix-restorerevision.sh.in
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
#! /bin/sh -e
|
|
||||||
|
|
||||||
svnbin=$1
|
|
||||||
repos=$2
|
|
||||||
|
|
||||||
if [ "$#" != 2 ] ; then
|
|
||||||
echo "Incorrect number of arguments"
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
$svnbin info $repos | sed -n '/^Revision: /p' | sed 's/Revision: //'
|
|
||||||
|
|
||||||
# | tr -d "\12"
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
#! /bin/sh -e
|
|
||||||
|
|
||||||
svnbin=$1
|
|
||||||
repos=$2
|
|
||||||
|
|
||||||
if [ "$#" != 2 ] ; then
|
|
||||||
echo "Incorrect number of arguments"
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
$svnbin info $repos | sed -n '/^Revision: /p' | sed 's/Revision: //'
|
|
||||||
|
|
||||||
# | tr -d "\12"
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
#! /bin/sh -e
|
|
||||||
|
|
||||||
svnbin=$1
|
|
||||||
torevision=$2
|
|
||||||
repos=$3
|
|
||||||
statepath=$4
|
|
||||||
|
|
||||||
if [ "$#" != 4 ] ; then
|
|
||||||
echo "Incorrect number of arguments"
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
$svnbin merge -r HEAD:$torevision $repos $statepath
|
|
||||||
|
|
@ -1,13 +0,0 @@
|
||||||
#! /bin/sh -e
|
|
||||||
|
|
||||||
svnbin=$1
|
|
||||||
torevision=$2
|
|
||||||
repos=$3
|
|
||||||
statepath=$4
|
|
||||||
|
|
||||||
if [ "$#" != 4 ] ; then
|
|
||||||
echo "Incorrect number of arguments"
|
|
||||||
exit 1;
|
|
||||||
fi
|
|
||||||
|
|
||||||
$svnbin merge -r HEAD:$torevision $repos $statepath
|
|
||||||
|
|
@ -35,6 +35,30 @@ string DrvInfo::queryOutPath(EvalState & state) const
|
||||||
return outPath;
|
return outPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string DrvInfo::queryStateIdentifier(EvalState & state) const
|
||||||
|
{
|
||||||
|
if (stateIdentifier == "") {
|
||||||
|
ATermMap attrs2 = *attrs;
|
||||||
|
|
||||||
|
for (ATermMap::const_iterator i = attrs2.begin(); i != attrs2.end(); ++i) {
|
||||||
|
|
||||||
|
string key = (string)aterm2String(i->key); //cast because aterm2String returns a char*
|
||||||
|
//printMsg(lvlError, format("ATTR2: '%1%'") % key);
|
||||||
|
if(key == "stateIdentifier"){
|
||||||
|
PathSet context;
|
||||||
|
string value = coerceToString(state, i->value, context);
|
||||||
|
(string &) stateIdentifier = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//If still empty
|
||||||
|
if (trim(stateIdentifier) == "")
|
||||||
|
(string &) stateIdentifier = "__NOSTATE__";
|
||||||
|
}
|
||||||
|
|
||||||
|
return stateIdentifier;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
MetaInfo DrvInfo::queryMetaInfo(EvalState & state) const
|
MetaInfo DrvInfo::queryMetaInfo(EvalState & state) const
|
||||||
{
|
{
|
||||||
|
|
@ -95,18 +119,21 @@ static bool getDerivation(EvalState & state, Expr e,
|
||||||
queryAllAttrs(e, *attrs, false);
|
queryAllAttrs(e, *attrs, false);
|
||||||
|
|
||||||
Expr a = attrs->get(toATerm("type"));
|
Expr a = attrs->get(toATerm("type"));
|
||||||
if (!a || evalStringNoCtx(state, a) != "derivation") return true;
|
if (!a || evalStringNoCtx(state, a) != "derivation")
|
||||||
|
return true;
|
||||||
|
|
||||||
/* Remove spurious duplicates (e.g., an attribute set like
|
/* Remove spurious duplicates (e.g., an attribute set like
|
||||||
`rec { x = derivation {...}; y = x;}'. */
|
`rec { x = derivation {...}; y = x;}'. */
|
||||||
if (doneExprs.find(e) != doneExprs.end()) return false;
|
if (doneExprs.find(e) != doneExprs.end())
|
||||||
|
return false;
|
||||||
doneExprs.insert(e);
|
doneExprs.insert(e);
|
||||||
|
|
||||||
DrvInfo drv;
|
DrvInfo drv;
|
||||||
|
|
||||||
a = attrs->get(toATerm("name"));
|
a = attrs->get(toATerm("name"));
|
||||||
/* !!! We really would like to have a decent back trace here. */
|
/* !!! We really would like to have a decent back trace here. */
|
||||||
if (!a) throw TypeError("derivation name missing");
|
if (!a)
|
||||||
|
throw TypeError("derivation name missing");
|
||||||
drv.name = evalStringNoCtx(state, a);
|
drv.name = evalStringNoCtx(state, a);
|
||||||
|
|
||||||
a = attrs->get(toATerm("system"));
|
a = attrs->get(toATerm("system"));
|
||||||
|
|
@ -133,7 +160,8 @@ bool getDerivation(EvalState & state, Expr e, DrvInfo & drv)
|
||||||
Exprs doneExprs;
|
Exprs doneExprs;
|
||||||
DrvInfos drvs;
|
DrvInfos drvs;
|
||||||
getDerivation(state, e, "", drvs, doneExprs);
|
getDerivation(state, e, "", drvs, doneExprs);
|
||||||
if (drvs.size() != 1) return false;
|
if (drvs.size() != 1)
|
||||||
|
return false;
|
||||||
drv = drvs.front();
|
drv = drvs.front();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ struct DrvInfo
|
||||||
private:
|
private:
|
||||||
string drvPath;
|
string drvPath;
|
||||||
string outPath;
|
string outPath;
|
||||||
|
string stateIdentifier;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
string name;
|
string name;
|
||||||
|
|
@ -33,6 +34,7 @@ public:
|
||||||
|
|
||||||
string queryDrvPath(EvalState & state) const;
|
string queryDrvPath(EvalState & state) const;
|
||||||
string queryOutPath(EvalState & state) const;
|
string queryOutPath(EvalState & state) const;
|
||||||
|
string queryStateIdentifier(EvalState & state) const;
|
||||||
MetaInfo queryMetaInfo(EvalState & state) const;
|
MetaInfo queryMetaInfo(EvalState & state) const;
|
||||||
|
|
||||||
void setDrvPath(const string & s)
|
void setDrvPath(const string & s)
|
||||||
|
|
@ -45,6 +47,11 @@ public:
|
||||||
outPath = s;
|
outPath = s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setStateIdentifier(const string & s)
|
||||||
|
{
|
||||||
|
stateIdentifier = s;
|
||||||
|
}
|
||||||
|
|
||||||
void setMetaInfo(const MetaInfo & meta);
|
void setMetaInfo(const MetaInfo & meta);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2587,6 +2587,9 @@ void LocalStore::buildDerivations(const PathSet & drvPaths)
|
||||||
Worker worker;
|
Worker worker;
|
||||||
Goals goals;
|
Goals goals;
|
||||||
for (PathSet::const_iterator i = drvPaths.begin(); i != drvPaths.end(); ++i){
|
for (PathSet::const_iterator i = drvPaths.begin(); i != drvPaths.end(); ++i){
|
||||||
|
|
||||||
|
printMsg(lvlError, format("BUILD: '%1%'") % *i);
|
||||||
|
|
||||||
goals.insert(worker.makeDerivationGoal(*i));
|
goals.insert(worker.makeDerivationGoal(*i));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,8 @@ struct DerivationStateOutput
|
||||||
throw Error(format("synchronization '%1%' is not a correct type") % synchronization);
|
throw Error(format("synchronization '%1%' is not a correct type") % synchronization);
|
||||||
if(username == "")
|
if(username == "")
|
||||||
throw Error(format("Username cannot be empty"));
|
throw Error(format("Username cannot be empty"));
|
||||||
|
if(stateIdentifier == "__EMTPY__" || stateIdentifier == "__NOSTATE__")
|
||||||
|
throw Error(format("the stateIdenfier cannot be this value '%1%'") % stateIdentifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
|
|
|
||||||
|
|
@ -768,19 +768,19 @@ void addStateDeriver(const Transaction & txn, const Path & storePath, const Path
|
||||||
* Returns true or false wheter a store-component has a state component (e.g. has a state dir) or not.
|
* Returns true or false wheter a store-component has a state component (e.g. has a state dir) or not.
|
||||||
* Do NOT confuse this function with isValidStatePath
|
* Do NOT confuse this function with isValidStatePath
|
||||||
*/
|
*/
|
||||||
bool isStateComponentTxn(const Transaction & txn, const Path & statePath)
|
bool isStateComponentTxn(const Transaction & txn, const Path & storePath)
|
||||||
{
|
{
|
||||||
isValidPathTxn(txn, statePath);
|
isValidPathTxn(txn, storePath);
|
||||||
|
|
||||||
string data;
|
string data;
|
||||||
bool nonempty = nixDB.queryString(txn, dbStateInfo, statePath, data);
|
bool nonempty = nixDB.queryString(txn, dbStateInfo, storePath, data);
|
||||||
|
|
||||||
return nonempty;
|
return nonempty;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool LocalStore::isStateComponent(const Path & statePath)
|
bool LocalStore::isStateComponent(const Path & storePath)
|
||||||
{
|
{
|
||||||
return nix::isStateComponentTxn(noTxn, statePath);
|
return nix::isStateComponentTxn(noTxn, storePath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,7 +92,7 @@ public:
|
||||||
|
|
||||||
vector<int> getStatePathsInterval(const PathSet & statePaths);
|
vector<int> getStatePathsInterval(const PathSet & statePaths);
|
||||||
|
|
||||||
bool isStateComponent(const Path & path);
|
bool isStateComponent(const Path & storePath);
|
||||||
|
|
||||||
bool isStateDrvPath(const Path & drvpath);
|
bool isStateDrvPath(const Path & drvpath);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -371,6 +371,7 @@ void writeStringToFile(const Path & path, const string & s)
|
||||||
|
|
||||||
LogType logType = ltPretty;
|
LogType logType = ltPretty;
|
||||||
Verbosity verbosity = lvlInfo;
|
Verbosity verbosity = lvlInfo;
|
||||||
|
//Verbosity verbosity = lvlDebug;
|
||||||
|
|
||||||
static int nestingLevel = 0;
|
static int nestingLevel = 0;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,8 +146,7 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
|
||||||
i != elems.end(); ++i)
|
i != elems.end(); ++i)
|
||||||
/* Call to `isDerivation' is for compatibility with Nix <= 0.7
|
/* Call to `isDerivation' is for compatibility with Nix <= 0.7
|
||||||
user environments. */
|
user environments. */
|
||||||
if (i->queryDrvPath(state) != "" &&
|
if (i->queryDrvPath(state) != "" && isDerivation(i->queryDrvPath(state)))
|
||||||
isDerivation(i->queryDrvPath(state)))
|
|
||||||
drvsToBuild.insert(i->queryDrvPath(state));
|
drvsToBuild.insert(i->queryDrvPath(state));
|
||||||
|
|
||||||
debug(format("building user environment dependencies"));
|
debug(format("building user environment dependencies"));
|
||||||
|
|
@ -161,6 +160,7 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
|
||||||
PathSet references;
|
PathSet references;
|
||||||
ATermList manifest = ATempty;
|
ATermList manifest = ATempty;
|
||||||
ATermList inputs = ATempty;
|
ATermList inputs = ATempty;
|
||||||
|
ATermList stateIdentifiers = ATempty;
|
||||||
for (DrvInfos::const_iterator i = elems.begin();
|
for (DrvInfos::const_iterator i = elems.begin();
|
||||||
i != elems.end(); ++i)
|
i != elems.end(); ++i)
|
||||||
{
|
{
|
||||||
|
|
@ -169,7 +169,7 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
|
||||||
the meta attributes. */
|
the meta attributes. */
|
||||||
Path drvPath = keepDerivations ? i->queryDrvPath(state) : "";
|
Path drvPath = keepDerivations ? i->queryDrvPath(state) : "";
|
||||||
|
|
||||||
ATermList as = ATmakeList4(
|
ATermList as = ATmakeList5(
|
||||||
makeBind(toATerm("type"),
|
makeBind(toATerm("type"),
|
||||||
makeStr("derivation"), makeNoPos()),
|
makeStr("derivation"), makeNoPos()),
|
||||||
makeBind(toATerm("name"),
|
makeBind(toATerm("name"),
|
||||||
|
|
@ -177,18 +177,26 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
|
||||||
makeBind(toATerm("system"),
|
makeBind(toATerm("system"),
|
||||||
makeStr(i->system), makeNoPos()),
|
makeStr(i->system), makeNoPos()),
|
||||||
makeBind(toATerm("outPath"),
|
makeBind(toATerm("outPath"),
|
||||||
makeStr(i->queryOutPath(state)), makeNoPos()));
|
makeStr(i->queryOutPath(state)), makeNoPos()),
|
||||||
|
makeBind(toATerm("stateIdentifier"),
|
||||||
|
makeStr(i->queryStateIdentifier(state)), makeNoPos()) );
|
||||||
|
|
||||||
if (drvPath != "") as = ATinsert(as,
|
if (drvPath != "")
|
||||||
makeBind(toATerm("drvPath"),
|
as = ATinsert(as, makeBind(toATerm("drvPath"), makeStr(drvPath), makeNoPos()));
|
||||||
makeStr(drvPath), makeNoPos()));
|
|
||||||
|
|
||||||
if (i->attrs->get(toATerm("meta"))) as = ATinsert(as,
|
if (i->attrs->get(toATerm("meta")))
|
||||||
makeBind(toATerm("meta"),
|
as = ATinsert(as, makeBind(toATerm("meta"),
|
||||||
strictEvalExpr(state, i->attrs->get(toATerm("meta"))),
|
strictEvalExpr(state, i->attrs->get(toATerm("meta"))), makeNoPos()));
|
||||||
makeNoPos()));
|
|
||||||
|
|
||||||
manifest = ATinsert(manifest, makeAttrs(as));
|
manifest = ATinsert(manifest, makeAttrs(as)); //All DrvInfo's are inserted here
|
||||||
|
|
||||||
|
/*ATermList ass = ATmakeList1(
|
||||||
|
makeBind(toATerm("stateIdentifier"), makeStr(i->queryStateIdentifier(state)), makeNoPos())
|
||||||
|
);*/
|
||||||
|
|
||||||
|
stateIdentifiers = ATinsert(stateIdentifiers, makeStr(i->queryStateIdentifier(state)));
|
||||||
|
|
||||||
|
//printMsg(lvlError, format("TEST2 '%1%'") % makeAttrs(as));
|
||||||
|
|
||||||
inputs = ATinsert(inputs, makeStr(i->queryOutPath(state)));
|
inputs = ATinsert(inputs, makeStr(i->queryOutPath(state)));
|
||||||
|
|
||||||
|
|
@ -197,31 +205,52 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
|
||||||
store->addTempRoot(i->queryOutPath(state));
|
store->addTempRoot(i->queryOutPath(state));
|
||||||
store->ensurePath(i->queryOutPath(state));
|
store->ensurePath(i->queryOutPath(state));
|
||||||
references.insert(i->queryOutPath(state));
|
references.insert(i->queryOutPath(state));
|
||||||
if (drvPath != "") references.insert(drvPath);
|
|
||||||
|
if (drvPath != "")
|
||||||
|
references.insert(drvPath);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//printMsg(lvlError, format("TEST '%1%'") % atPrint(canonicaliseExpr(makeList(ATreverse(manifest)))) );
|
||||||
|
//printMsg(lvlError, format("TEST2 '%1%'") % makeList(ATreverse(manifest)) );
|
||||||
|
//printMsg(lvlError, format("TEST2 '%1%'") % makeBind(toATerm("stateIdentifiers"), makeList(ATreverse(manifest)), makeNoPos()) );
|
||||||
|
printMsg(lvlError, format("TEST '%1%'") % atPrint(canonicaliseExpr(makeList(ATreverse(stateIdentifiers)))) );
|
||||||
|
|
||||||
|
/* Extract ... */
|
||||||
|
|
||||||
|
|
||||||
/* Also write a copy of the list of inputs to the store; we need
|
/* Also write a copy of the list of inputs to the store; we need
|
||||||
it for future modifications of the environment. */
|
it for future modifications of the environment. */
|
||||||
Path manifestFile = store->addTextToStore("env-manifest", atPrint(canonicaliseExpr(makeList(ATreverse(manifest)))), references);
|
Path manifestFile = store->addTextToStore("env-manifest", atPrint(canonicaliseExpr(makeList(ATreverse(manifest)))), references);
|
||||||
|
|
||||||
Expr topLevel = makeCall(envBuilder, makeAttrs(ATmakeList3(
|
Expr topLevel = makeCall(envBuilder, makeAttrs(ATmakeList4(
|
||||||
makeBind(toATerm("system"),
|
makeBind(toATerm("system"),
|
||||||
makeStr(thisSystem), makeNoPos()),
|
makeStr(thisSystem), makeNoPos()),
|
||||||
makeBind(toATerm("derivations"),
|
makeBind(toATerm("derivations"),
|
||||||
makeList(ATreverse(manifest)), makeNoPos()),
|
makeList(ATreverse(manifest)), makeNoPos()),
|
||||||
|
makeBind(toATerm("stateIdentifiers"),
|
||||||
|
makeList(ATreverse(stateIdentifiers)), makeNoPos()),
|
||||||
makeBind(toATerm("manifest"),
|
makeBind(toATerm("manifest"),
|
||||||
makeStr(manifestFile, singleton<PathSet>(manifestFile)), makeNoPos())
|
makeStr(manifestFile, singleton<PathSet>(manifestFile)), makeNoPos())
|
||||||
)));
|
)));
|
||||||
|
|
||||||
|
//printMsg(lvlError, format("Write manifest '%1%'") % topLevel);
|
||||||
|
|
||||||
/* Instantiate it. */
|
/* Instantiate it. */
|
||||||
debug(format("evaluating builder expression `%1%'") % topLevel);
|
debug(format("evaluating builder expression `%1%'") % topLevel);
|
||||||
DrvInfo topLevelDrv;
|
DrvInfo topLevelDrv;
|
||||||
if (!getDerivation(state, topLevel, topLevelDrv))
|
if (!getDerivation(state, topLevel, topLevelDrv))
|
||||||
abort();
|
abort();
|
||||||
|
|
||||||
|
printMsg(lvlError, format("TEST5 '%1%'") % topLevelDrv.queryStateIdentifier(state));
|
||||||
|
printMsg(lvlError, format("BUILD ENV DRV: '%1%'") % topLevelDrv.queryDrvPath(state) );
|
||||||
|
|
||||||
/* Realise the resulting store expression. */
|
/* Realise the resulting store expression. */
|
||||||
debug(format("building user environment"));
|
debug(format("building user environment"));
|
||||||
store->buildDerivations(singleton<PathSet>(topLevelDrv.queryDrvPath(state)));
|
store->buildDerivations(singleton<PathSet>(topLevelDrv.queryDrvPath(state))); //HERE IS THE DRV !!!!!!!!!!!
|
||||||
|
|
||||||
|
//switch .....
|
||||||
|
|
||||||
|
printMsg(lvlError, format("TEST6"));
|
||||||
|
|
||||||
/* Switch the current user environment to the output path. */
|
/* Switch the current user environment to the output path. */
|
||||||
debug(format("switching to new user environment"));
|
debug(format("switching to new user environment"));
|
||||||
|
|
@ -312,6 +341,11 @@ static void queryInstSources(EvalState & state,
|
||||||
DrvInfos & elems, bool newestOnly)
|
DrvInfos & elems, bool newestOnly)
|
||||||
{
|
{
|
||||||
InstallSourceType type = instSource.type;
|
InstallSourceType type = instSource.type;
|
||||||
|
|
||||||
|
for (Strings::const_iterator i = args.begin(); i != args.end(); ++i)
|
||||||
|
printMsg(lvlError, format("queryInstSources arg '%1%'") % *i);
|
||||||
|
printMsg(lvlError, format("queryInstSources TYPE '%1%'") % (type == srcUnknown));
|
||||||
|
|
||||||
if (type == srcUnknown && args.size() > 0 && args.front()[0] == '/')
|
if (type == srcUnknown && args.size() > 0 && args.front()[0] == '/')
|
||||||
type = srcStorePaths;
|
type = srcStorePaths;
|
||||||
|
|
||||||
|
|
@ -365,8 +399,12 @@ static void queryInstSources(EvalState & state,
|
||||||
for (Strings::const_iterator i = args.begin();
|
for (Strings::const_iterator i = args.begin();
|
||||||
i != args.end(); ++i)
|
i != args.end(); ++i)
|
||||||
{
|
{
|
||||||
|
printMsg(lvlError, format("AAAAA333 %1%'") % *i);
|
||||||
|
|
||||||
assertStorePath(*i);
|
assertStorePath(*i);
|
||||||
|
|
||||||
|
printMsg(lvlError, format("AAAAA444 %1%'") % *i);
|
||||||
|
|
||||||
DrvInfo elem;
|
DrvInfo elem;
|
||||||
elem.attrs = boost::shared_ptr<ATermMap>(new ATermMap(0)); /* ugh... */
|
elem.attrs = boost::shared_ptr<ATermMap>(new ATermMap(0)); /* ugh... */
|
||||||
string name = baseNameOf(*i);
|
string name = baseNameOf(*i);
|
||||||
|
|
@ -377,13 +415,18 @@ static void queryInstSources(EvalState & state,
|
||||||
if (isDerivation(*i)) {
|
if (isDerivation(*i)) {
|
||||||
elem.setDrvPath(*i);
|
elem.setDrvPath(*i);
|
||||||
elem.setOutPath(findOutput(derivationFromPath(*i), "out"));
|
elem.setOutPath(findOutput(derivationFromPath(*i), "out"));
|
||||||
//TODO !!!!!!!!!!!!!!!!!!!! setStatePath??
|
|
||||||
|
|
||||||
if (name.size() >= drvExtension.size() &&
|
if (name.size() >= drvExtension.size() &&
|
||||||
string(name, name.size() - drvExtension.size()) == drvExtension)
|
string(name, name.size() - drvExtension.size()) == drvExtension)
|
||||||
name = string(name, 0, name.size() - drvExtension.size());
|
name = string(name, 0, name.size() - drvExtension.size());
|
||||||
}
|
}
|
||||||
else elem.setOutPath(*i);
|
else
|
||||||
|
{
|
||||||
|
elem.setOutPath(*i);
|
||||||
|
|
||||||
|
//if(drv.stateOutputs.size() != 0)
|
||||||
|
// elem.setStateIdentifier(drv.stateOutputs.find("state")->second.stateIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
elem.name = name;
|
elem.name = name;
|
||||||
|
|
||||||
|
|
@ -466,6 +509,21 @@ static void installDerivations(Globals & globals,
|
||||||
one-click installs, namely those where the name used in the
|
one-click installs, namely those where the name used in the
|
||||||
path is not the one we want (e.g., `java-front' versus
|
path is not the one we want (e.g., `java-front' versus
|
||||||
`java-front-0.9pre15899'). */
|
`java-front-0.9pre15899'). */
|
||||||
|
|
||||||
|
//printMsg(lvlError, format("New component to install DRV: '%1%'") % i->queryDrvPath(globals.state));
|
||||||
|
|
||||||
|
//Set the state indentifier
|
||||||
|
if( store->isStateComponent(i->queryOutPath(globals.state)) )
|
||||||
|
{
|
||||||
|
Derivation drv = derivationFromPath(i->queryDrvPath(globals.state));
|
||||||
|
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||||
|
string stateIdentifier = stateOutputs.find("state")->second.stateIdentifier;
|
||||||
|
if(stateIdentifier == "")
|
||||||
|
i->setStateIdentifier("__EMTPY__");
|
||||||
|
else
|
||||||
|
i->setStateIdentifier(stateIdentifier);
|
||||||
|
}
|
||||||
|
|
||||||
if (globals.forceName != "")
|
if (globals.forceName != "")
|
||||||
i->name = globals.forceName;
|
i->name = globals.forceName;
|
||||||
newNames.insert(DrvName(i->name).name);
|
newNames.insert(DrvName(i->name).name);
|
||||||
|
|
@ -478,14 +536,18 @@ static void installDerivations(Globals & globals,
|
||||||
DrvInfos installedElems = queryInstalled(globals.state, profile);
|
DrvInfos installedElems = queryInstalled(globals.state, profile);
|
||||||
|
|
||||||
DrvInfos allElems(newElems);
|
DrvInfos allElems(newElems);
|
||||||
for (DrvInfos::iterator i = installedElems.begin();
|
for (DrvInfos::iterator i = installedElems.begin(); i != installedElems.end(); ++i)
|
||||||
i != installedElems.end(); ++i)
|
|
||||||
{
|
{
|
||||||
DrvName drvName(i->name);
|
DrvName drvName(i->name);
|
||||||
if (!globals.preserveInstalled &&
|
|
||||||
newNames.find(drvName.name) != newNames.end())
|
//TODO !!!!!!!!!!!!!!!!!!!!!!!! SHARE (OR COPY) STATE HERE IF NEEDED
|
||||||
printMsg(lvlInfo,
|
//if( newNames.find(drvName.name) != newNames.end() && identifier == identifier )
|
||||||
format("replacing old `%1%'") % i->name);
|
//{
|
||||||
|
|
||||||
|
//}
|
||||||
|
|
||||||
|
if (!globals.preserveInstalled && newNames.find(drvName.name) != newNames.end())
|
||||||
|
printMsg(lvlInfo, format("replacing old `%1%'") % i->name);
|
||||||
else
|
else
|
||||||
allElems.push_back(*i);
|
allElems.push_back(*i);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,8 @@ Path createGeneration(Path profile, Path outPath)
|
||||||
makeName(profile, num + 1, generation);
|
makeName(profile, num + 1, generation);
|
||||||
addPermRoot(outPath, generation, false, true);
|
addPermRoot(outPath, generation, false, true);
|
||||||
|
|
||||||
|
printMsg(lvlError, format("TEST3 '%1%' '%2%' --> '%3%'") % profile % outPath % generation);
|
||||||
|
|
||||||
return generation;
|
return generation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -115,7 +117,8 @@ void deleteGeneration(const Path & profile, unsigned int gen)
|
||||||
void switchLink(Path link, Path target)
|
void switchLink(Path link, Path target)
|
||||||
{
|
{
|
||||||
/* Hacky. */
|
/* Hacky. */
|
||||||
if (dirOf(target) == dirOf(link)) target = baseNameOf(target);
|
if (dirOf(target) == dirOf(link))
|
||||||
|
target = baseNameOf(target);
|
||||||
|
|
||||||
Path tmp = canonPath(dirOf(link) + "/.new_" + baseNameOf(link));
|
Path tmp = canonPath(dirOf(link) + "/.new_" + baseNameOf(link));
|
||||||
if (symlink(target.c_str(), tmp.c_str()) != 0)
|
if (symlink(target.c_str(), tmp.c_str()) != 0)
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ string comment;
|
||||||
int revision_arg;
|
int revision_arg;
|
||||||
bool scanforReferences = false;
|
bool scanforReferences = false;
|
||||||
bool only_commit = false;
|
bool only_commit = false;
|
||||||
|
bool revert_recursively = false;
|
||||||
|
|
||||||
|
|
||||||
/************************* Build time Functions ******************************/
|
/************************* Build time Functions ******************************/
|
||||||
|
|
@ -59,7 +60,7 @@ Derivation getDerivation(const string & fullPath, const string & program_args, s
|
||||||
if( !(store->isValidPath(componentPath) || store->isValidStatePath(componentPath)) )
|
if( !(store->isValidPath(componentPath) || store->isValidStatePath(componentPath)) )
|
||||||
throw UsageError(format("Path '%1%' is not a valid state or store path") % componentPath);
|
throw UsageError(format("Path '%1%' is not a valid state or store path") % componentPath);
|
||||||
|
|
||||||
//Check if path is statepath
|
//Check if path is store-statepath
|
||||||
isStateComponent = store->isStateComponent(componentPath);
|
isStateComponent = store->isStateComponent(componentPath);
|
||||||
|
|
||||||
//printMsg(lvlError, format("'%1%' - '%2%' - '%3%' - '%4%' - '%5%'") % componentPath % state_identifier % binary % username % program_args);
|
//printMsg(lvlError, format("'%1%' - '%2%' - '%3%' - '%4%' - '%5%'") % componentPath % state_identifier % binary % username % program_args);
|
||||||
|
|
@ -80,7 +81,8 @@ Derivation getDerivation(const string & fullPath, const string & program_args, s
|
||||||
}
|
}
|
||||||
|
|
||||||
//Retrieve the derivation, there is only 1 drvPath in derivers
|
//Retrieve the derivation, there is only 1 drvPath in derivers
|
||||||
Derivation drv = derivationFromPath(*(derivers.begin()));
|
derivationPath = *(derivers.begin());
|
||||||
|
Derivation drv = derivationFromPath(derivationPath);
|
||||||
|
|
||||||
if(isStateComponent){
|
if(isStateComponent){
|
||||||
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
DerivationStateOutputs stateOutputs = drv.stateOutputs;
|
||||||
|
|
@ -239,7 +241,7 @@ static void revertToRevision(Strings opFlags, Strings opArgs)
|
||||||
string program_args;
|
string program_args;
|
||||||
Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, binary, derivationPath, isStateComponent, program_args);
|
Derivation drv = getDerivation_andCheckArgs(opFlags, opArgs, componentPath, statePath, binary, derivationPath, isStateComponent, program_args);
|
||||||
|
|
||||||
bool recursive = true; //TODO !!!!!!!!!!!!!!!!!
|
bool recursive = revert_recursively;
|
||||||
|
|
||||||
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! add TXN here ???????????
|
//TODO !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! add TXN here ???????????
|
||||||
|
|
||||||
|
|
@ -368,7 +370,7 @@ void scanAndUpdateAllReferencesTxn(const Transaction & txn, const Path & statePa
|
||||||
PathSet allComponentPaths2; //without derivations
|
PathSet allComponentPaths2; //without derivations
|
||||||
for (PathSet::iterator i = allComponentPaths.begin(); i != allComponentPaths.end(); ++i){
|
for (PathSet::iterator i = allComponentPaths.begin(); i != allComponentPaths.end(); ++i){
|
||||||
string path = *i;
|
string path = *i;
|
||||||
if(path.substr(path.length() - 4,path.length()) != ".drv") //TODO HACK: we should have a typed table or a seperate table ....
|
if(path.substr(path.length() - 4,path.length()) != drvExtension) //TODO HACK: we should have a typed table or a seperate table .... drvExtension == ".drv"
|
||||||
allComponentPaths2.insert(path);
|
allComponentPaths2.insert(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -463,6 +465,8 @@ static void opRunComponent(Strings opFlags, Strings opArgs)
|
||||||
string root_program_args;
|
string root_program_args;
|
||||||
Derivation root_drv = getDerivation_andCheckArgs(opFlags, opArgs, root_componentPath, root_statePath, root_binary, root_derivationPath, root_isStateComponent, root_program_args);
|
Derivation root_drv = getDerivation_andCheckArgs(opFlags, opArgs, root_componentPath, root_statePath, root_binary, root_derivationPath, root_isStateComponent, root_program_args);
|
||||||
|
|
||||||
|
printMsg(lvlError, format("compp: '%1%'\nstatep: '%2%'\nbinary: '%3%'\ndrv:'%4%'") % root_componentPath % root_statePath % root_binary % root_derivationPath);
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
//Check for locks ... ? or put locks on the neseccary state components
|
//Check for locks ... ? or put locks on the neseccary state components
|
||||||
//WARNING: we need to watch out for deadlocks!
|
//WARNING: we need to watch out for deadlocks!
|
||||||
|
|
@ -724,6 +728,8 @@ void run(Strings args)
|
||||||
username = arg.substr(7,arg.length());
|
username = arg.substr(7,arg.length());
|
||||||
else if (arg.substr(0,10) == "--comment=")
|
else if (arg.substr(0,10) == "--comment=")
|
||||||
comment = arg.substr(10,arg.length());
|
comment = arg.substr(10,arg.length());
|
||||||
|
else if (arg.substr(0,10) == "--revert-to-revision-recursively")
|
||||||
|
revert_recursively = true;
|
||||||
else
|
else
|
||||||
opArgs.push_back(arg);
|
opArgs.push_back(arg);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue