* Option --force-realise' in nix-store --query'.

This commit is contained in:
Eelco Dolstra 2004-01-09 14:18:28 +00:00
parent 30b31a8f61
commit 46a71c857c
4 changed files with 98 additions and 74 deletions

View file

@ -7,18 +7,14 @@
<refsynopsisdiv> <refsynopsisdiv>
<cmdsynopsis> <cmdsynopsis>
<command>nix-env</command> <command>nix-env</command>
<group choice='opt' rep='repeat'> <arg rep='repeat'><option>--verbose</option></arg>
<arg><option>--verbose</option></arg> <arg rep='repeat'><option>-v</option></arg>
<arg><option>-v</option></arg>
</group>
<group choice='opt'>
<arg><option>--keep-failed</option></arg> <arg><option>--keep-failed</option></arg>
<arg><option>-K</option></arg> <arg><option>-K</option></arg>
</group>
<arg> <arg>
<group choice='opt'> <group choice='req'>
<arg><option>--file</option></arg> <arg choice='plain'><option>--file</option></arg>
<arg><option>-f</option></arg> <arg choice='plain'><option>-f</option></arg>
</group> </group>
<replaceable>path</replaceable> <replaceable>path</replaceable>
</arg> </arg>
@ -76,7 +72,7 @@
&opt-verbose; &opt-verbose;
<varlistentry> <varlistentry>
<term><option>--file</option></term> <term><option>--file</option> / <option>-f</option></term>
<listitem> <listitem>
<para> <para>
Specifies the Nix expression used by the Specifies the Nix expression used by the
@ -125,8 +121,8 @@
By default, it points to By default, it points to
<filename><replaceable>prefix</replaceable>/var/nix/links/current</filename>. <filename><replaceable>prefix</replaceable>/var/nix/links/current</filename>.
The <envar>PATH</envar> environment variable should The <envar>PATH</envar> environment variable should
include <filename>~/.nix-userenv</filename> for the use include <filename>~/.nix-userenv</filename> for the user
environments to be visible to the user. environment to be visible to the user.
</para> </para>
</listitem> </listitem>
</varlistentry> </varlistentry>
@ -146,8 +142,9 @@
<title>Synopsis</title> <title>Synopsis</title>
<cmdsynopsis> <cmdsynopsis>
<command>nix-env</command> <command>nix-env</command>
<group> <group choice='req'>
<arg><option>--install</option></arg> <arg choice='plain'><option>--install</option></arg>
<arg choice='plain'><option>-i</option></arg>
</group> </group>
</cmdsynopsis> </cmdsynopsis>
</refsection> </refsection>

View file

@ -7,14 +7,10 @@
<refsynopsisdiv> <refsynopsisdiv>
<cmdsynopsis> <cmdsynopsis>
<command>nix-store</command> <command>nix-store</command>
<group choice='opt' rep='repeat'> <arg rep='repeat'><option>--verbose</option></arg>
<arg><option>--verbose</option></arg> <arg rep='repeat'><option>-v</option></arg>
<arg><option>-v</option></arg>
</group>
<group choice='opt'>
<arg><option>--keep-failed</option></arg> <arg><option>--keep-failed</option></arg>
<arg><option>-K</option></arg> <arg><option>-K</option></arg>
</group>
<arg choice='plain'><replaceable>operation</replaceable></arg> <arg choice='plain'><replaceable>operation</replaceable></arg>
<arg rep='repeat'><replaceable>options</replaceable></arg> <arg rep='repeat'><replaceable>options</replaceable></arg>
<arg rep='repeat'><replaceable>arguments</replaceable></arg> <arg rep='repeat'><replaceable>arguments</replaceable></arg>
@ -56,7 +52,7 @@
&opt-verbose; &opt-verbose;
<varlistentry> <varlistentry>
<term><option>--keep-failed</option></term> <term><option>--keep-failed</option> / <option>-K</option></term>
<listitem> <listitem>
<para> <para>
Specifies that in case of a build failure, the temporary directory Specifies that in case of a build failure, the temporary directory
@ -112,9 +108,9 @@
<title>Synopsis</title> <title>Synopsis</title>
<cmdsynopsis> <cmdsynopsis>
<command>nix-store</command> <command>nix-store</command>
<group> <group choice='req'>
<arg><option>--realise</option></arg> <arg choice='plain'><option>--realise</option></arg>
<arg><option>-r</option></arg> <arg choice='plain'><option>-r</option></arg>
</group> </group>
<arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg> <arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
@ -160,9 +156,9 @@
<title>Synopsis</title> <title>Synopsis</title>
<cmdsynopsis> <cmdsynopsis>
<command>nix-store</command> <command>nix-store</command>
<group> <group choice='req'>
<arg><option>--delete</option></arg> <arg choice='plain'><option>--delete</option></arg>
<arg><option>-d</option></arg> <arg choice='plain'><option>-d</option></arg>
</group> </group>
<arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg> <arg choice='plain' rep='repeat'><replaceable>paths</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
@ -203,22 +199,22 @@
<title>Synopsis</title> <title>Synopsis</title>
<cmdsynopsis> <cmdsynopsis>
<command>nix-store</command> <command>nix-store</command>
<group> <group choice='req'>
<arg><option>--query</option></arg> <arg choice='plain'><option>--query</option></arg>
<arg><option>-q</option></arg> <arg choice='plain'><option>-q</option></arg>
</group> </group>
<group> <group choice='req'>
<group> <arg choice='plain'><option>--list</option></arg>
<arg><option>--list</option></arg> <arg choice='plain'><option>-l</option></arg>
<arg><option>-l</option></arg> <arg choice='plain'><option>--requisites</option></arg>
</group> <arg choice='plain'><option>-R</option></arg>
<group> <arg choice='plain'><option>--predecessors</option></arg>
<arg><option>--requisites</option></arg> <arg choice='plain'><option>--graph</option></arg>
<arg><option>-R</option></arg>
</group>
<arg><option>--predecessors</option></arg>
<arg><option>--graph</option></arg>
</group> </group>
<arg><option>--normalise</option></arg>
<arg><option>-n</option></arg>
<arg><option>--force-realise</option></arg>
<arg><option>-f</option></arg>
<arg choice='plain' rep='repeat'><replaceable>args</replaceable></arg> <arg choice='plain' rep='repeat'><replaceable>args</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
</refsection> </refsection>
@ -235,13 +231,55 @@
</refsection> </refsection>
<refsection>
<title>Common query options</title>
<variablelist>
<varlistentry>
<term><option>--normalise</option> / <option>-n</option></term>
<listitem>
<para>
For those queries that take a Nix store expression, this
option causes those expressions to be normalised first.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--force-realise</option> / <option>-f</option></term>
<listitem>
<para>
For those queries that take a Nix store expression, this
option causes those expressions to be realised first.
This is just a short-cut for the common idiom
</para>
<screen>
nix-store --realise /nix/store/bla.store
x=`nix-store --query --normalise /nix/store/bla.store
<emphasis>(do something with the path $x</emphasis></screen>
<para>
which using this flag can be written as
</para>
<screen>
x=`nix-store --query --normalise --force-realise /nix/store/bla.store
<emphasis>(do something with the path $x</emphasis></screen>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection id='nixref-queries'> <refsection id='nixref-queries'>
<title>Queries</title> <title>Queries</title>
<variablelist> <variablelist>
<varlistentry> <varlistentry>
<term><option>--list</option></term> <term><option>--list</option> / <option>-l</option></term>
<listitem> <listitem>
<para> <para>
Prints out the <emphasis>output paths</emphasis> of the Prints out the <emphasis>output paths</emphasis> of the
@ -257,7 +295,7 @@
</varlistentry> </varlistentry>
<varlistentry> <varlistentry>
<term><option>--requisites</option></term> <term><option>--requisites</option> / <option>-R</option></term>
<listitem> <listitem>
<para> <para>
Prints out the requisite paths of the store expressions Prints out the requisite paths of the store expressions
@ -304,18 +342,6 @@
<variablelist> <variablelist>
<varlistentry>
<term><option>--normalise</option></term>
<listitem>
<para>
Causes the requisite paths of the
<emphasis>successor</emphasis> of the given store
expressions to be printed, rather than the
requisite paths of the expressions themselves.
</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><option>--exclude-exprs</option></term> <term><option>--exclude-exprs</option></term>
<listitem> <listitem>
@ -398,9 +424,7 @@
<title>Synopsis</title> <title>Synopsis</title>
<cmdsynopsis> <cmdsynopsis>
<command>nix-store</command> <command>nix-store</command>
<group> <arg choice='req'><option>--successor</option></arg>
<arg><option>--successor</option></arg>
</group>
<arg choice='plain' <arg choice='plain'
rep='repeat'><replaceable>srcpath</replaceable> <replaceable>sucpath</replaceable></arg> rep='repeat'><replaceable>srcpath</replaceable> <replaceable>sucpath</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
@ -432,9 +456,7 @@
<title>Synopsis</title> <title>Synopsis</title>
<cmdsynopsis> <cmdsynopsis>
<command>nix-store</command> <command>nix-store</command>
<group> <arg choice='req'><option>--substitute</option></arg>
<arg><option>--substitute</option></arg>
</group>
<arg choice='plain' <arg choice='plain'
rep='repeat'><replaceable>srcpath</replaceable> <replaceable>subpath</replaceable></arg> rep='repeat'><replaceable>srcpath</replaceable> <replaceable>subpath</replaceable></arg>
</cmdsynopsis> </cmdsynopsis>
@ -466,9 +488,7 @@
<title>Synopsis</title> <title>Synopsis</title>
<cmdsynopsis> <cmdsynopsis>
<command>nix-store</command> <command>nix-store</command>
<group> <arg choice='req'><option>--verify</option></arg>
<arg><option>--verify</option></arg>
</group>
</cmdsynopsis> </cmdsynopsis>
</refsection> </refsection>

View file

@ -1,5 +1,5 @@
<varlistentry> <varlistentry>
<term><option>--verbose</option></term> <term><option>--verbose</option> / <option>-v</option></term>
<listitem> <listitem>
<para> <para>
Increases the level of verbosity of diagnostic messages printed Increases the level of verbosity of diagnostic messages printed

View file

@ -61,8 +61,13 @@ static void opAdd(Strings opFlags, Strings opArgs)
} }
Path maybeNormalise(const Path & ne, bool normalise) Path maybeNormalise(const Path & ne, bool normalise, bool realise)
{ {
if (realise) {
Path ne2 = normaliseStoreExpr(ne);
realiseClosure(ne2);
return normalise ? ne2 : ne;
} else
return normalise ? normaliseStoreExpr(ne) : ne; return normalise ? normaliseStoreExpr(ne) : ne;
} }
@ -73,6 +78,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
enum { qList, qRequisites, qPredecessors, qGraph enum { qList, qRequisites, qPredecessors, qGraph
} query = qList; } query = qList;
bool normalise = false; bool normalise = false;
bool realise = false;
bool includeExprs = true; bool includeExprs = true;
bool includeSuccessors = false; bool includeSuccessors = false;
@ -83,6 +89,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
else if (*i == "--predecessors") query = qPredecessors; else if (*i == "--predecessors") query = qPredecessors;
else if (*i == "--graph") query = qGraph; else if (*i == "--graph") query = qGraph;
else if (*i == "--normalise" || *i == "-n") normalise = true; else if (*i == "--normalise" || *i == "-n") normalise = true;
else if (*i == "--force-realise" || *i == "-f") realise = true;
else if (*i == "--exclude-exprs") includeExprs = false; else if (*i == "--exclude-exprs") includeExprs = false;
else if (*i == "--include-successors") includeSuccessors = true; else if (*i == "--include-successors") includeSuccessors = true;
else throw UsageError(format("unknown flag `%1%'") % *i); else throw UsageError(format("unknown flag `%1%'") % *i);
@ -94,7 +101,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
i != opArgs.end(); i++) i != opArgs.end(); i++)
{ {
StringSet paths = storeExprRoots( StringSet paths = storeExprRoots(
maybeNormalise(checkPath(*i), normalise)); maybeNormalise(checkPath(*i), normalise, realise));
for (StringSet::iterator j = paths.begin(); for (StringSet::iterator j = paths.begin();
j != paths.end(); j++) j != paths.end(); j++)
cout << format("%s\n") % *j; cout << format("%s\n") % *j;
@ -108,7 +115,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
i != opArgs.end(); i++) i != opArgs.end(); i++)
{ {
StringSet paths2 = storeExprRequisites( StringSet paths2 = storeExprRequisites(
maybeNormalise(checkPath(*i), normalise), maybeNormalise(checkPath(*i), normalise, realise),
includeExprs, includeSuccessors); includeExprs, includeSuccessors);
paths.insert(paths2.begin(), paths2.end()); paths.insert(paths2.begin(), paths2.end());
} }
@ -134,7 +141,7 @@ static void opQuery(Strings opFlags, Strings opArgs)
PathSet roots; PathSet roots;
for (Strings::iterator i = opArgs.begin(); for (Strings::iterator i = opArgs.begin();
i != opArgs.end(); i++) i != opArgs.end(); i++)
roots.insert(maybeNormalise(checkPath(*i), normalise)); roots.insert(maybeNormalise(checkPath(*i), normalise, realise));
printDotGraph(roots); printDotGraph(roots);
break; break;
} }