aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/build.cc19
-rw-r--r--src/libstore/daemon.cc4
-rw-r--r--src/libstore/export-import.cc2
-rw-r--r--src/libstore/globals.hh2
-rw-r--r--src/libstore/local-store.cc10
-rw-r--r--src/libstore/names.cc107
-rw-r--r--src/libstore/names.hh32
-rw-r--r--src/libstore/nar-info-disk-cache.cc4
-rw-r--r--src/libstore/nar-info.cc4
-rw-r--r--src/libstore/optimise-store.cc2
-rw-r--r--src/libstore/store-api.cc12
11 files changed, 165 insertions, 33 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc
index 04e8d2ebe..e5dc11e7d 100644
--- a/src/libstore/build.cc
+++ b/src/libstore/build.cc
@@ -1660,7 +1660,7 @@ void DerivationGoal::buildDone()
worker.store.printStorePath(drvPath),
statusToString(status));
- if (!settings.verboseBuild && !logTail.empty()) {
+ if (!logger->isVerbose() && !logTail.empty()) {
msg += (format("; last %d log lines:") % logTail.size()).str();
for (auto & line : logTail)
msg += "\n " + line;
@@ -1709,11 +1709,7 @@ void DerivationGoal::buildDone()
}
void flushLine() {
- if (settings.verboseBuild) {
- printError("post-build-hook: " + currentLine);
- } else {
- act.result(resPostBuildLogLine, currentLine);
- }
+ act.result(resPostBuildLogLine, currentLine);
currentLine.clear();
}
@@ -3743,7 +3739,7 @@ void DerivationGoal::registerOutputs()
worker.hashMismatch = true;
delayedException = std::make_exception_ptr(
BuildError("hash mismatch in fixed-output derivation '%s':\n wanted: %s\n got: %s",
- worker.store.printStorePath(dest), h.to_string(SRI), h2.to_string(SRI)));
+ worker.store.printStorePath(dest), h.to_string(SRI, true), h2.to_string(SRI, true)));
Path actualDest = worker.store.Store::toRealPath(dest);
@@ -4188,13 +4184,8 @@ void DerivationGoal::flushLine()
;
else {
- if (settings.verboseBuild &&
- (settings.printRepeatedBuilds || curRound == 1))
- printError(currentLogLine);
- else {
- logTail.push_back(currentLogLine);
- if (logTail.size() > settings.logLines) logTail.pop_front();
- }
+ logTail.push_back(currentLogLine);
+ if (logTail.size() > settings.logLines) logTail.pop_front();
act->result(resBuildLogLine, currentLogLine);
}
diff --git a/src/libstore/daemon.cc b/src/libstore/daemon.cc
index 4fb7ed5b2..2e29e3c7c 100644
--- a/src/libstore/daemon.cc
+++ b/src/libstore/daemon.cc
@@ -370,8 +370,10 @@ static void performOp(TunnelLogger * logger, ref<Store> store,
std::string s, baseName;
FileIngestionMethod method;
{
- bool fixed, recursive;
+ bool fixed; uint8_t recursive;
from >> baseName >> fixed /* obsolete */ >> recursive >> s;
+ if (recursive > (uint8_t) FileIngestionMethod::Recursive)
+ throw Error("unsupported FileIngestionMethod with value of %i; you may need to upgrade nix-daemon", recursive);
method = FileIngestionMethod { recursive };
/* Compatibility hack. */
if (!fixed) {
diff --git a/src/libstore/export-import.cc b/src/libstore/export-import.cc
index f0d01a240..54471d4a3 100644
--- a/src/libstore/export-import.cc
+++ b/src/libstore/export-import.cc
@@ -57,7 +57,7 @@ void Store::exportPath(const StorePath & path, Sink & sink)
Hash hash = hashAndWriteSink.currentHash();
if (hash != info->narHash && info->narHash != Hash(info->narHash.type))
throw Error("hash of path '%s' has changed from '%s' to '%s'!",
- printStorePath(path), info->narHash.to_string(), hash.to_string());
+ printStorePath(path), info->narHash.to_string(Base32, true), hash.to_string(Base32, true));
hashAndWriteSink
<< exportMagic
diff --git a/src/libstore/globals.hh b/src/libstore/globals.hh
index da95fd3ae..2fbcafff8 100644
--- a/src/libstore/globals.hh
+++ b/src/libstore/globals.hh
@@ -271,7 +271,7 @@ public:
"listed in 'trusted-public-keys'."};
Setting<StringSet> extraPlatforms{this,
- std::string{SYSTEM} == "x86_64-linux" ? StringSet{"i686-linux"} : StringSet{},
+ std::string{SYSTEM} == "x86_64-linux" && !isWSL1() ? StringSet{"i686-linux"} : StringSet{},
"extra-platforms",
"Additional platforms that can be built on the local system. "
"These may be supported natively (e.g. armv7 on some aarch64 CPUs "
diff --git a/src/libstore/local-store.cc b/src/libstore/local-store.cc
index 53fb4ce68..c5c82d448 100644
--- a/src/libstore/local-store.cc
+++ b/src/libstore/local-store.cc
@@ -584,7 +584,7 @@ uint64_t LocalStore::addValidPath(State & state,
state.stmtRegisterValidPath.use()
(printStorePath(info.path))
- (info.narHash.to_string(Base16))
+ (info.narHash.to_string(Base16, true))
(info.registrationTime == 0 ? time(0) : info.registrationTime)
(info.deriver ? printStorePath(*info.deriver) : "", (bool) info.deriver)
(info.narSize, info.narSize != 0)
@@ -684,7 +684,7 @@ void LocalStore::updatePathInfo(State & state, const ValidPathInfo & info)
{
state.stmtUpdatePathInfo.use()
(info.narSize, info.narSize != 0)
- (info.narHash.to_string(Base16))
+ (info.narHash.to_string(Base16, true))
(info.ultimate ? 1 : 0, info.ultimate)
(concatStringsSep(" ", info.sigs), !info.sigs.empty())
(info.ca, !info.ca.empty())
@@ -1026,7 +1026,7 @@ void LocalStore::addToStore(const ValidPathInfo & info, Source & source,
if (hashResult.first != info.narHash)
throw Error("hash mismatch importing path '%s';\n wanted: %s\n got: %s",
- printStorePath(info.path), info.narHash.to_string(), hashResult.first.to_string());
+ printStorePath(info.path), info.narHash.to_string(Base32, true), hashResult.first.to_string(Base32, true));
if (hashResult.second != info.narSize)
throw Error("size mismatch importing path '%s';\n wanted: %s\n got: %s",
@@ -1159,7 +1159,7 @@ StorePath LocalStore::addTextToStore(const string & name, const string & s,
info.narHash = narHash;
info.narSize = sink.s->size();
info.references = cloneStorePathSet(references);
- info.ca = "text:" + hash.to_string();
+ info.ca = "text:" + hash.to_string(Base32, true);
registerValidPath(info);
}
@@ -1282,7 +1282,7 @@ bool LocalStore::verifyStore(bool checkContents, RepairFlag repair)
logError({
.name = "Invalid hash - path modified",
.hint = hintfmt("path '%s' was modified! expected hash '%s', got '%s'",
- printStorePath(i), info->narHash.to_string(), current.first.to_string())
+ printStorePath(i), info->narHash.to_string(Base32, true), current.first.to_string(Base32, true))
});
if (repair) repairPath(i); else errors = true;
} else {
diff --git a/src/libstore/names.cc b/src/libstore/names.cc
new file mode 100644
index 000000000..d1c8a6101
--- /dev/null
+++ b/src/libstore/names.cc
@@ -0,0 +1,107 @@
+#include "names.hh"
+#include "util.hh"
+
+
+namespace nix {
+
+
+DrvName::DrvName()
+{
+ name = "";
+}
+
+
+/* Parse a derivation name. The `name' part of a derivation name is
+ everything up to but not including the first dash *not* followed by
+ a letter. The `version' part is the rest (excluding the separating
+ dash). E.g., `apache-httpd-2.0.48' is parsed to (`apache-httpd',
+ '2.0.48'). */
+DrvName::DrvName(std::string_view s) : hits(0)
+{
+ name = fullName = std::string(s);
+ for (unsigned int i = 0; i < s.size(); ++i) {
+ /* !!! isalpha/isdigit are affected by the locale. */
+ if (s[i] == '-' && i + 1 < s.size() && !isalpha(s[i + 1])) {
+ name = s.substr(0, i);
+ version = s.substr(i + 1);
+ break;
+ }
+ }
+}
+
+
+bool DrvName::matches(DrvName & n)
+{
+ if (name != "*") {
+ if (!regex) regex = std::unique_ptr<std::regex>(new std::regex(name, std::regex::extended));
+ if (!std::regex_match(n.name, *regex)) return false;
+ }
+ if (version != "" && version != n.version) return false;
+ return true;
+}
+
+
+string nextComponent(string::const_iterator & p,
+ const string::const_iterator end)
+{
+ /* Skip any dots and dashes (component separators). */
+ while (p != end && (*p == '.' || *p == '-')) ++p;
+
+ if (p == end) return "";
+
+ /* If the first character is a digit, consume the longest sequence
+ of digits. Otherwise, consume the longest sequence of
+ non-digit, non-separator characters. */
+ string s;
+ if (isdigit(*p))
+ while (p != end && isdigit(*p)) s += *p++;
+ else
+ while (p != end && (!isdigit(*p) && *p != '.' && *p != '-'))
+ s += *p++;
+
+ return s;
+}
+
+
+static bool componentsLT(const string & c1, const string & c2)
+{
+ int n1, n2;
+ bool c1Num = string2Int(c1, n1), c2Num = string2Int(c2, n2);
+
+ if (c1Num && c2Num) return n1 < n2;
+ else if (c1 == "" && c2Num) return true;
+ else if (c1 == "pre" && c2 != "pre") return true;
+ else if (c2 == "pre") return false;
+ /* Assume that `2.3a' < `2.3.1'. */
+ else if (c2Num) return true;
+ else if (c1Num) return false;
+ else return c1 < c2;
+}
+
+
+int compareVersions(const string & v1, const string & v2)
+{
+ string::const_iterator p1 = v1.begin();
+ string::const_iterator p2 = v2.begin();
+
+ while (p1 != v1.end() || p2 != v2.end()) {
+ string c1 = nextComponent(p1, v1.end());
+ string c2 = nextComponent(p2, v2.end());
+ if (componentsLT(c1, c2)) return -1;
+ else if (componentsLT(c2, c1)) return 1;
+ }
+
+ return 0;
+}
+
+
+DrvNames drvNamesFromArgs(const Strings & opArgs)
+{
+ DrvNames result;
+ for (auto & i : opArgs)
+ result.push_back(DrvName(i));
+ return result;
+}
+
+
+}
diff --git a/src/libstore/names.hh b/src/libstore/names.hh
new file mode 100644
index 000000000..00e14b8c7
--- /dev/null
+++ b/src/libstore/names.hh
@@ -0,0 +1,32 @@
+#pragma once
+
+#include <memory>
+
+#include "types.hh"
+#include <regex>
+
+namespace nix {
+
+struct DrvName
+{
+ string fullName;
+ string name;
+ string version;
+ unsigned int hits;
+
+ DrvName();
+ DrvName(std::string_view s);
+ bool matches(DrvName & n);
+
+private:
+ std::unique_ptr<std::regex> regex;
+};
+
+typedef list<DrvName> DrvNames;
+
+string nextComponent(string::const_iterator & p,
+ const string::const_iterator end);
+int compareVersions(const string & v1, const string & v2);
+DrvNames drvNamesFromArgs(const Strings & opArgs);
+
+}
diff --git a/src/libstore/nar-info-disk-cache.cc b/src/libstore/nar-info-disk-cache.cc
index 442541330..e8cf1d177 100644
--- a/src/libstore/nar-info-disk-cache.cc
+++ b/src/libstore/nar-info-disk-cache.cc
@@ -230,9 +230,9 @@ public:
(std::string(info->path.name()))
(narInfo ? narInfo->url : "", narInfo != 0)
(narInfo ? narInfo->compression : "", narInfo != 0)
- (narInfo && narInfo->fileHash ? narInfo->fileHash.to_string() : "", narInfo && narInfo->fileHash)
+ (narInfo && narInfo->fileHash ? narInfo->fileHash.to_string(Base32, true) : "", narInfo && narInfo->fileHash)
(narInfo ? narInfo->fileSize : 0, narInfo != 0 && narInfo->fileSize)
- (info->narHash.to_string())
+ (info->narHash.to_string(Base32, true))
(info->narSize)
(concatStringsSep(" ", info->shortRefs()))
(info->deriver ? std::string(info->deriver->to_string()) : "", (bool) info->deriver)
diff --git a/src/libstore/nar-info.cc b/src/libstore/nar-info.cc
index fbdcd7786..232284723 100644
--- a/src/libstore/nar-info.cc
+++ b/src/libstore/nar-info.cc
@@ -87,10 +87,10 @@ std::string NarInfo::to_string(const Store & store) const
assert(compression != "");
res += "Compression: " + compression + "\n";
assert(fileHash.type == htSHA256);
- res += "FileHash: " + fileHash.to_string(Base32) + "\n";
+ res += "FileHash: " + fileHash.to_string(Base32, true) + "\n";
res += "FileSize: " + std::to_string(fileSize) + "\n";
assert(narHash.type == htSHA256);
- res += "NarHash: " + narHash.to_string(Base32) + "\n";
+ res += "NarHash: " + narHash.to_string(Base32, true) + "\n";
res += "NarSize: " + std::to_string(narSize) + "\n";
res += "References: " + concatStringsSep(" ", shortRefs()) + "\n";
diff --git a/src/libstore/optimise-store.cc b/src/libstore/optimise-store.cc
index cc0507be2..d760d110c 100644
--- a/src/libstore/optimise-store.cc
+++ b/src/libstore/optimise-store.cc
@@ -153,7 +153,7 @@ void LocalStore::optimisePath_(Activity * act, OptimiseStats & stats,
contents of the symlink (i.e. the result of readlink()), not
the contents of the target (which may not even exist). */
Hash hash = hashPath(htSHA256, path).first;
- debug(format("'%1%' has hash '%2%'") % path % hash.to_string());
+ debug(format("'%1%' has hash '%2%'") % path % hash.to_string(Base32, true));
/* Check if this is a known hash. */
Path linkPath = linksDir + "/" + hash.to_string(Base32, false);
diff --git a/src/libstore/store-api.cc b/src/libstore/store-api.cc
index 0e5e613f5..4197f8e1d 100644
--- a/src/libstore/store-api.cc
+++ b/src/libstore/store-api.cc
@@ -142,7 +142,7 @@ StorePath Store::makeStorePath(const string & type,
const Hash & hash, std::string_view name) const
{
/* e.g., "source:sha256:1abc...:/nix/store:foo.tar.gz" */
- string s = type + ":" + hash.to_string(Base16) + ":" + storeDir + ":" + std::string(name);
+ string s = type + ":" + hash.to_string(Base16, true) + ":" + storeDir + ":" + std::string(name);
auto h = compressHash(hashString(htSHA256, s), 20);
return StorePath::make(h.hash, name);
}
@@ -186,7 +186,7 @@ StorePath Store::makeFixedOutputPath(
hashString(htSHA256,
"fixed:out:"
+ (recursive == FileIngestionMethod::Recursive ? (string) "r:" : "")
- + hash.to_string(Base16) + ":"),
+ + hash.to_string(Base16, true) + ":"),
name);
}
}
@@ -461,7 +461,7 @@ void Store::pathInfoToJSON(JSONPlaceholder & jsonOut, const StorePathSet & store
auto info = queryPathInfo(storePath);
jsonPath
- .attr("narHash", info->narHash.to_string(hashBase))
+ .attr("narHash", info->narHash.to_string(hashBase, true))
.attr("narSize", info->narSize);
{
@@ -504,7 +504,7 @@ void Store::pathInfoToJSON(JSONPlaceholder & jsonOut, const StorePathSet & store
if (!narInfo->url.empty())
jsonPath.attr("url", narInfo->url);
if (narInfo->fileHash)
- jsonPath.attr("downloadHash", narInfo->fileHash.to_string());
+ jsonPath.attr("downloadHash", narInfo->fileHash.to_string(Base32, true));
if (narInfo->fileSize)
jsonPath.attr("downloadSize", narInfo->fileSize);
if (showClosureSize)
@@ -760,7 +760,7 @@ std::string ValidPathInfo::fingerprint(const Store & store) const
store.printStorePath(path));
return
"1;" + store.printStorePath(path) + ";"
- + narHash.to_string(Base32) + ";"
+ + narHash.to_string(Base32, true) + ";"
+ std::to_string(narSize) + ";"
+ concatStringsSep(",", store.printStorePathSet(references));
}
@@ -840,7 +840,7 @@ std::string makeFixedOutputCA(FileIngestionMethod recursive, const Hash & hash)
{
return "fixed:"
+ (recursive == FileIngestionMethod::Recursive ? (std::string) "r:" : "")
- + hash.to_string();
+ + hash.to_string(Base32, true);
}