mirror of
https://github.com/NixOS/nix.git
synced 2025-11-26 04:00:59 +01:00
Merged R8636
This commit is contained in:
parent
8e9c7d9338
commit
854e155b2c
8 changed files with 97 additions and 33 deletions
|
|
@ -139,6 +139,7 @@ fi
|
||||||
AC_MSG_RESULT(yes)
|
AC_MSG_RESULT(yes)
|
||||||
|
|
||||||
NEED_PROG(cat, cat)
|
NEED_PROG(cat, cat)
|
||||||
|
NEED_PROG(tr, tr)
|
||||||
AC_ARG_WITH(coreutils-bin, AC_HELP_STRING([--with-coreutils-bin=PATH],
|
AC_ARG_WITH(coreutils-bin, AC_HELP_STRING([--with-coreutils-bin=PATH],
|
||||||
[path of cat, mkdir, etc.]),
|
[path of cat, mkdir, etc.]),
|
||||||
coreutils=$withval, coreutils=$(dirname $cat))
|
coreutils=$withval, coreutils=$(dirname $cat))
|
||||||
|
|
|
||||||
|
|
@ -5,18 +5,29 @@
|
||||||
cd $out/tmp
|
cd $out/tmp
|
||||||
|
|
||||||
expr=$out/default.nix
|
expr=$out/default.nix
|
||||||
echo '[' > $expr
|
echo '{' > $expr
|
||||||
|
|
||||||
nr=0
|
inputs=($inputs)
|
||||||
for i in $inputs; do
|
for ((n = 0; n < ${#inputs[*]}; n += 2)); do
|
||||||
echo "unpacking $i"
|
channelName=${inputs[n]}
|
||||||
@bunzip2@ < $i | @tar@ xf -
|
channelTarball=${inputs[n+1]}
|
||||||
@coreutils@/mv * ../$nr # !!! hacky
|
echo "unpacking channel $channelName"
|
||||||
echo "(import ./$nr)" >> $expr
|
@bunzip2@ < $channelTarball | @tar@ xf -
|
||||||
nr=$(($nr + 1))
|
|
||||||
|
nr=1
|
||||||
|
dirName=$channelName
|
||||||
|
while test -e ../$dirName; do
|
||||||
|
nr=$((nr+1))
|
||||||
|
dirName=$channelName-$nr
|
||||||
|
done
|
||||||
|
|
||||||
|
@coreutils@/mv * ../$dirName # !!! hacky
|
||||||
|
|
||||||
|
attrName=$(echo $dirName | @tr@ -- '- ' '__')
|
||||||
|
echo "$attrName = import ./$dirName {};" >> $expr
|
||||||
done
|
done
|
||||||
|
|
||||||
echo ']' >> $expr
|
echo '} // {_combineChannels = true;}' >> $expr
|
||||||
|
|
||||||
cd ..
|
cd ..
|
||||||
@coreutils@/rmdir tmp
|
@coreutils@/rmdir tmp
|
||||||
|
|
|
||||||
|
|
@ -70,10 +70,16 @@
|
||||||
info about installed packages in user environments. <option>-q
|
info about installed packages in user environments. <option>-q
|
||||||
--xml --meta</option> to show all meta info.</para></listitem>
|
--xml --meta</option> to show all meta info.</para></listitem>
|
||||||
|
|
||||||
|
|
||||||
<listitem><para>TODO: <command>nix-env</command>
|
<listitem><para>TODO: <command>nix-env</command>
|
||||||
<option>--set-flag</option>. Specific flags:
|
<option>--set-flag</option>. Specific flags:
|
||||||
<literal>active</literal>, <literal>priority</literal>,
|
<literal>active</literal>, <literal>priority</literal>,
|
||||||
<literal>keep</literal>.</para></listitem>
|
<literal>keep</literal>.</para></listitem>
|
||||||
|
|
||||||
|
|
||||||
|
<listitem><para>TODO: <command>nix-env</command> <option>-i</option>
|
||||||
|
/ <option>-u</option> take package priorities into
|
||||||
|
account.</para></listitem>
|
||||||
|
|
||||||
|
|
||||||
<listitem><para><command>nix-env -q</command> now has a flag
|
<listitem><para><command>nix-env -q</command> now has a flag
|
||||||
|
|
|
||||||
|
|
@ -89,21 +89,22 @@ sub update {
|
||||||
# Create a Nix expression that fetches and unpacks the channel Nix
|
# Create a Nix expression that fetches and unpacks the channel Nix
|
||||||
# expressions.
|
# expressions.
|
||||||
|
|
||||||
my $nixExpr = "[";
|
my $inputs = "[";
|
||||||
foreach my $url (@channels) {
|
foreach my $url (@channels) {
|
||||||
|
$url =~ /\/([^\/]+)\/?$/;
|
||||||
|
my $channelName = $1;
|
||||||
|
$channelName = "unnamed" unless defined $channelName;
|
||||||
|
print "$channelName\n";
|
||||||
|
|
||||||
my $fullURL = "$url/nixexprs.tar.bz2";
|
my $fullURL = "$url/nixexprs.tar.bz2";
|
||||||
print "downloading Nix expressions from `$fullURL'...\n";
|
print "downloading Nix expressions from `$fullURL'...\n";
|
||||||
$ENV{"PRINT_PATH"} = 1;
|
$ENV{"PRINT_PATH"} = 1;
|
||||||
my ($hash, $path) = `@bindir@/nix-prefetch-url '$fullURL' 2> /dev/null`;
|
my ($hash, $path) = `@bindir@/nix-prefetch-url '$fullURL' 2> /dev/null`;
|
||||||
die "cannot fetch `$fullURL'" if $? != 0;
|
die "cannot fetch `$fullURL'" if $? != 0;
|
||||||
chomp $path;
|
chomp $path;
|
||||||
$nixExpr .= $path . " ";
|
$inputs .= '"' . $channelName . '"' . " " . $path . " ";
|
||||||
}
|
}
|
||||||
$nixExpr .= "]";
|
$inputs .= "]";
|
||||||
|
|
||||||
$nixExpr =
|
|
||||||
"(import @datadir@/nix/corepkgs/channels/unpack.nix) " .
|
|
||||||
"{inputs = $nixExpr; system = \"@system@\";}";
|
|
||||||
|
|
||||||
# Figure out a name for the GC root.
|
# Figure out a name for the GC root.
|
||||||
my $userName = getpwuid($<);
|
my $userName = getpwuid($<);
|
||||||
|
|
@ -113,7 +114,7 @@ sub update {
|
||||||
|
|
||||||
# Instantiate the Nix expression.
|
# Instantiate the Nix expression.
|
||||||
print "unpacking channel Nix expressions...\n";
|
print "unpacking channel Nix expressions...\n";
|
||||||
my $storeExpr = `echo '$nixExpr' | @bindir@/nix-instantiate --add-root '$rootFile'.tmp -`
|
my $storeExpr = `@bindir@/nix-instantiate --add-root '$rootFile'.tmp @datadir@/nix/corepkgs/channels/unpack.nix --argstr system @system@ --arg inputs '$inputs'`
|
||||||
or die "cannot instantiate Nix expression";
|
or die "cannot instantiate Nix expression";
|
||||||
chomp $storeExpr;
|
chomp $storeExpr;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,15 @@ MetaInfo DrvInfo::queryMetaInfo(EvalState & state) const
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
string DrvInfo::queryMetaInfo(EvalState & state, const string & name) const
|
||||||
|
{
|
||||||
|
/* !!! evaluates all meta attributes => inefficient */
|
||||||
|
MetaInfo meta = queryMetaInfo(state);
|
||||||
|
MetaInfo::iterator i = meta.find(name);
|
||||||
|
return i == meta.end() ? "" : i->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DrvInfo::setMetaInfo(const MetaInfo & meta)
|
void DrvInfo::setMetaInfo(const MetaInfo & meta)
|
||||||
{
|
{
|
||||||
ATermMap metaAttrs;
|
ATermMap metaAttrs;
|
||||||
|
|
@ -214,12 +223,21 @@ static void getDerivations(EvalState & state, Expr e,
|
||||||
if (matchAttrs(e, es)) {
|
if (matchAttrs(e, es)) {
|
||||||
ATermMap drvMap(ATgetLength(es));
|
ATermMap drvMap(ATgetLength(es));
|
||||||
queryAllAttrs(e, drvMap);
|
queryAllAttrs(e, drvMap);
|
||||||
|
|
||||||
|
/* !!! undocumented hackery to support
|
||||||
|
corepkgs/channels/unpack.sh. */
|
||||||
|
Expr e2 = drvMap.get(toATerm("_combineChannels"));
|
||||||
|
bool combineChannels = e2 && evalBool(state, e2);
|
||||||
|
|
||||||
for (ATermMap::const_iterator i = drvMap.begin(); i != drvMap.end(); ++i) {
|
for (ATermMap::const_iterator i = drvMap.begin(); i != drvMap.end(); ++i) {
|
||||||
startNest(nest, lvlDebug,
|
startNest(nest, lvlDebug,
|
||||||
format("evaluating attribute `%1%'") % aterm2String(i->key));
|
format("evaluating attribute `%1%'") % aterm2String(i->key));
|
||||||
string pathPrefix2 = addToPath(pathPrefix, aterm2String(i->key));
|
string pathPrefix2 = addToPath(pathPrefix, aterm2String(i->key));
|
||||||
if (getDerivation(state, i->value, pathPrefix2, drvs, doneExprs)) {
|
if (combineChannels) {
|
||||||
|
if (((string) aterm2String(i->key)) != "_combineChannels")
|
||||||
|
getDerivations(state, i->value, pathPrefix2, autoArgs, drvs, doneExprs);
|
||||||
|
}
|
||||||
|
else if (getDerivation(state, i->value, pathPrefix2, drvs, doneExprs)) {
|
||||||
/* If the value of this attribute is itself an
|
/* If the value of this attribute is itself an
|
||||||
attribute set, should we recurse into it? => Only
|
attribute set, should we recurse into it? => Only
|
||||||
if it has a `recurseForDerivations = true'
|
if it has a `recurseForDerivations = true'
|
||||||
|
|
@ -229,8 +247,8 @@ static void getDerivations(EvalState & state, Expr e,
|
||||||
if (matchAttrs(e, es)) {
|
if (matchAttrs(e, es)) {
|
||||||
ATermMap attrs(ATgetLength(es));
|
ATermMap attrs(ATgetLength(es));
|
||||||
queryAllAttrs(e, attrs, false);
|
queryAllAttrs(e, attrs, false);
|
||||||
Expr e2 = attrs.get(toATerm("recurseForDerivations"));
|
if (((e2 = attrs.get(toATerm("recurseForDerivations")))
|
||||||
if (e2 && evalBool(state, e2))
|
&& evalBool(state, e2)))
|
||||||
getDerivations(state, e, pathPrefix2, autoArgs, drvs, doneExprs);
|
getDerivations(state, e, pathPrefix2, autoArgs, drvs, doneExprs);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -38,6 +38,7 @@ public:
|
||||||
string queryStateIdentifier(EvalState & state) const;
|
string queryStateIdentifier(EvalState & state) const;
|
||||||
string queryRuntimeStateArgs(EvalState & state) const;
|
string queryRuntimeStateArgs(EvalState & state) const;
|
||||||
MetaInfo queryMetaInfo(EvalState & state) const;
|
MetaInfo queryMetaInfo(EvalState & state) const;
|
||||||
|
string queryMetaInfo(EvalState & state, const string & name) const;
|
||||||
|
|
||||||
void setDrvPath(const string & s)
|
void setDrvPath(const string & s)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -252,6 +252,16 @@ static void createUserEnv(EvalState & state, const DrvInfos & elems,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static int comparePriorities(EvalState & state,
|
||||||
|
const DrvInfo & drv1, const DrvInfo & drv2)
|
||||||
|
{
|
||||||
|
int prio1, prio2;
|
||||||
|
if (!string2Int(drv1.queryMetaInfo(state, "priority"), prio1)) prio1 = 0;
|
||||||
|
if (!string2Int(drv2.queryMetaInfo(state, "priority"), prio2)) prio2 = 0;
|
||||||
|
return prio2 - prio1; /* higher number = lower priority, so negate */
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static DrvInfos filterBySelector(EvalState & state,
|
static DrvInfos filterBySelector(EvalState & state,
|
||||||
const DrvInfos & allElems,
|
const DrvInfos & allElems,
|
||||||
const Strings & args, bool newestOnly)
|
const Strings & args, bool newestOnly)
|
||||||
|
|
@ -278,8 +288,10 @@ static DrvInfos filterBySelector(EvalState & state,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If `newestOnly', if a selector matches multiple derivations
|
/* If `newestOnly', if a selector matches multiple derivations
|
||||||
with the same name, pick the one with the highest version.
|
with the same name, pick the one with the highest priority.
|
||||||
If there are multiple derivations with the same name *and*
|
If there are multiple derivations with the same priority,
|
||||||
|
pick the one with the highest version. If there are
|
||||||
|
multiple derivations with the same priority and name and
|
||||||
version, then pick the first one. */
|
version, then pick the first one. */
|
||||||
if (newestOnly) {
|
if (newestOnly) {
|
||||||
|
|
||||||
|
|
@ -290,13 +302,22 @@ static DrvInfos filterBySelector(EvalState & state,
|
||||||
|
|
||||||
for (Matches::iterator j = matches.begin(); j != matches.end(); ++j) {
|
for (Matches::iterator j = matches.begin(); j != matches.end(); ++j) {
|
||||||
DrvName drvName(j->first.name);
|
DrvName drvName(j->first.name);
|
||||||
|
int d = 1;
|
||||||
|
|
||||||
Newest::iterator k = newest.find(drvName.name);
|
Newest::iterator k = newest.find(drvName.name);
|
||||||
|
|
||||||
if (k != newest.end()) {
|
if (k != newest.end()) {
|
||||||
int d = compareVersions(drvName.version, DrvName(k->second.first.name).version);
|
d = comparePriorities(state, j->first, k->second.first);
|
||||||
if (d > 0) newest[drvName.name] = *j;
|
if (d == 0)
|
||||||
else if (d == 0) multiple.insert(j->first.name);
|
d = compareVersions(drvName.version, DrvName(k->second.first.name).version);
|
||||||
} else
|
}
|
||||||
|
|
||||||
|
if (d > 0) {
|
||||||
newest[drvName.name] = *j;
|
newest[drvName.name] = *j;
|
||||||
|
multiple.erase(j->first.name);
|
||||||
|
} else if (d == 0) {
|
||||||
|
multiple.insert(j->first.name);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
matches.clear();
|
matches.clear();
|
||||||
|
|
@ -712,9 +733,10 @@ static void upgradeDerivations(Globals & globals,
|
||||||
if (meta["keep"] == "true") continue;
|
if (meta["keep"] == "true") continue;
|
||||||
|
|
||||||
/* Find the derivation in the input Nix expression with the
|
/* Find the derivation in the input Nix expression with the
|
||||||
same name and satisfying the version constraints specified
|
same name that satisfies the version constraints specified
|
||||||
by upgradeType. If there are multiple matches, take the
|
by upgradeType. If there are multiple matches, take the
|
||||||
one with highest version. */
|
one with the highest priority. If there are still multiple
|
||||||
|
matches, take the one with the highest version. */
|
||||||
DrvInfos::iterator bestElem = availElems.end();
|
DrvInfos::iterator bestElem = availElems.end();
|
||||||
DrvName bestName;
|
DrvName bestName;
|
||||||
for (DrvInfos::iterator j = availElems.begin();
|
for (DrvInfos::iterator j = availElems.begin();
|
||||||
|
|
@ -722,16 +744,19 @@ static void upgradeDerivations(Globals & globals,
|
||||||
{
|
{
|
||||||
DrvName newName(j->name);
|
DrvName newName(j->name);
|
||||||
if (newName.name == drvName.name) {
|
if (newName.name == drvName.name) {
|
||||||
int d = compareVersions(drvName.version, newName.version);
|
int d = comparePriorities(globals.state, *i, *j);
|
||||||
|
if (d == 0) d = compareVersions(drvName.version, newName.version);
|
||||||
if (upgradeType == utLt && d < 0 ||
|
if (upgradeType == utLt && d < 0 ||
|
||||||
upgradeType == utLeq && d <= 0 ||
|
upgradeType == utLeq && d <= 0 ||
|
||||||
upgradeType == utEq && d == 0 ||
|
upgradeType == utEq && d == 0 ||
|
||||||
upgradeType == utAlways)
|
upgradeType == utAlways)
|
||||||
{
|
{
|
||||||
if ((bestElem == availElems.end() ||
|
int d2 = -1;
|
||||||
compareVersions(
|
if (bestElem != availElems.end()) {
|
||||||
bestName.version, newName.version) < 0))
|
d2 = comparePriorities(globals.state, *bestElem, *j);
|
||||||
{
|
if (d2 == 0) d2 = compareVersions(bestName.version, newName.version);
|
||||||
|
}
|
||||||
|
if (d2 < 0) {
|
||||||
bestElem = j;
|
bestElem = j;
|
||||||
bestName = newName;
|
bestName = newName;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@
|
||||||
-e "s^@perl\@^$(perl)^g" \
|
-e "s^@perl\@^$(perl)^g" \
|
||||||
-e "s^@coreutils\@^$(coreutils)^g" \
|
-e "s^@coreutils\@^$(coreutils)^g" \
|
||||||
-e "s^@tar\@^$(tar)^g" \
|
-e "s^@tar\@^$(tar)^g" \
|
||||||
|
-e "s^@tr\@^$(tr)^g" \
|
||||||
-e "s^@dot\@^$(dot)^g" \
|
-e "s^@dot\@^$(dot)^g" \
|
||||||
-e "s^@xmllint\@^$(xmllint)^g" \
|
-e "s^@xmllint\@^$(xmllint)^g" \
|
||||||
-e "s^@xmlflags\@^$(xmlflags)^g" \
|
-e "s^@xmlflags\@^$(xmlflags)^g" \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue