From 6dca5c9099b92b6a93071197aa606a31ccd83a37 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Wed, 8 Mar 2006 16:03:58 +0000 Subject: * When obtaining derivations from Nix expressions, ignore all expressions that cause an assertion failure (like `assert system == "i686-linux"'). This allows all-packages.nix in Nixpkgs to be used on all platforms, even if some Nix expressions don't work on all platforms. Not sure if this is a good idea; it's a bit hacky. In particular, due to laziness some derivations might appear in `nix-env -qa' but disappear in `nix-env -qas' or `nix-env -i'. Commit 5000! --- src/nix-env/main.cc | 76 +++++++++++++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 35 deletions(-) (limited to 'src/nix-env/main.cc') diff --git a/src/nix-env/main.cc b/src/nix-env/main.cc index 8648e4f0f871..1266c50117e8 100644 --- a/src/nix-env/main.cc +++ b/src/nix-env/main.cc @@ -762,47 +762,53 @@ static void opQuery(Globals & globals, for (vector::iterator i = elems2.begin(); i != elems2.end(); ++i) { - Strings columns; + try { + + Strings columns; - if (printStatus) { - Substitutes subs = querySubstitutes(noTxn, i->queryOutPath(globals.state)); - columns.push_back( - (string) (installed.find(i->queryOutPath(globals.state)) - != installed.end() ? "I" : "-") - + (isValidPath(i->queryOutPath(globals.state)) ? "P" : "-") - + (subs.size() > 0 ? "S" : "-")); - } + if (printStatus) { + Substitutes subs = querySubstitutes(noTxn, i->queryOutPath(globals.state)); + columns.push_back( + (string) (installed.find(i->queryOutPath(globals.state)) + != installed.end() ? "I" : "-") + + (isValidPath(i->queryOutPath(globals.state)) ? "P" : "-") + + (subs.size() > 0 ? "S" : "-")); + } - if (printName) columns.push_back(i->name); - - if (compareVersions) { - /* Compare this element against the versions of the same - named packages in either the set of available elements, - or the set of installed elements. !!! This is O(N * - M), should be O(N * lg M). */ - string version; - VersionDiff diff = compareVersionAgainstSet(*i, otherElems, version); - char ch; - switch (diff) { - case cvLess: ch = '>'; break; - case cvEqual: ch = '='; break; - case cvGreater: ch = '<'; break; - case cvUnavail: ch = '-'; break; - default: abort(); + if (printName) columns.push_back(i->name); + + if (compareVersions) { + /* Compare this element against the versions of the + same named packages in either the set of available + elements, or the set of installed elements. !!! + This is O(N * M), should be O(N * lg M). */ + string version; + VersionDiff diff = compareVersionAgainstSet(*i, otherElems, version); + char ch; + switch (diff) { + case cvLess: ch = '>'; break; + case cvEqual: ch = '='; break; + case cvGreater: ch = '<'; break; + case cvUnavail: ch = '-'; break; + default: abort(); + } + string column = (string) "" + ch + " " + version; + if (diff == cvGreater) column = colorString(column); + columns.push_back(column); } - string column = (string) "" + ch + " " + version; - if (diff == cvGreater) column = colorString(column); - columns.push_back(column); - } - if (printSystem) columns.push_back(i->system); + if (printSystem) columns.push_back(i->system); - if (printDrvPath) columns.push_back( - i->queryDrvPath(globals.state) == "" - ? "-" : i->queryDrvPath(globals.state)); + if (printDrvPath) columns.push_back( + i->queryDrvPath(globals.state) == "" + ? "-" : i->queryDrvPath(globals.state)); - if (printOutPath) columns.push_back(i->queryOutPath(globals.state)); - table.push_back(columns); + if (printOutPath) columns.push_back(i->queryOutPath(globals.state)); + + table.push_back(columns); + } + catch (AssertionError & e) { + } } printTable(table); -- cgit 1.4.1