diff options
Diffstat (limited to 'third_party/nix/src/libstore')
-rw-r--r-- | third_party/nix/src/libstore/builtins/buildenv.cc | 9 | ||||
-rw-r--r-- | third_party/nix/src/libstore/builtins/fetchurl.cc | 5 | ||||
-rw-r--r-- | third_party/nix/src/libstore/derivations.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/libstore/download.cc | 7 | ||||
-rw-r--r-- | third_party/nix/src/libstore/gc.cc | 3 | ||||
-rw-r--r-- | third_party/nix/src/libstore/local-binary-cache-store.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/libstore/machines.cc | 8 | ||||
-rw-r--r-- | third_party/nix/src/libstore/s3-binary-cache-store.cc | 9 | ||||
-rw-r--r-- | third_party/nix/src/libstore/ssh.cc | 4 | ||||
-rw-r--r-- | third_party/nix/src/libstore/store-api.cc | 9 |
10 files changed, 38 insertions, 24 deletions
diff --git a/third_party/nix/src/libstore/builtins/buildenv.cc b/third_party/nix/src/libstore/builtins/buildenv.cc index d14474a93d7e..92cf2f8c1eec 100644 --- a/third_party/nix/src/libstore/builtins/buildenv.cc +++ b/third_party/nix/src/libstore/builtins/buildenv.cc @@ -1,5 +1,6 @@ #include <algorithm> +#include <absl/strings/match.h> #include <fcntl.h> #include <glog/logging.h> #include <sys/stat.h> @@ -56,10 +57,10 @@ static void createLinks(const Path& srcDir, const Path& dstDir, int priority) { * Python package brings its own * `$out/lib/pythonX.Y/site-packages/easy-install.pth'.) */ - if (hasSuffix(srcFile, "/propagated-build-inputs") || - hasSuffix(srcFile, "/nix-support") || - hasSuffix(srcFile, "/perllocal.pod") || - hasSuffix(srcFile, "/info/dir") || hasSuffix(srcFile, "/log")) + if (absl::EndsWith(srcFile, "/propagated-build-inputs") || + absl::EndsWith(srcFile, "/nix-support") || + absl::EndsWith(srcFile, "/perllocal.pod") || + absl::EndsWith(srcFile, "/info/dir") || absl::EndsWith(srcFile, "/log")) continue; else if (S_ISDIR(srcSt.st_mode)) { diff --git a/third_party/nix/src/libstore/builtins/fetchurl.cc b/third_party/nix/src/libstore/builtins/fetchurl.cc index 97260d2e5229..90814f6d7f0b 100644 --- a/third_party/nix/src/libstore/builtins/fetchurl.cc +++ b/third_party/nix/src/libstore/builtins/fetchurl.cc @@ -1,3 +1,4 @@ +#include <absl/strings/match.h> #include <glog/logging.h> #include "archive.hh" @@ -41,7 +42,7 @@ void builtinFetchurl(const BasicDerivation& drv, const std::string& netrcData) { request.decompress = false; auto decompressor = makeDecompressionSink( - unpack && hasSuffix(mainUrl, ".xz") ? "xz" : "none", sink); + unpack && absl::EndsWith(mainUrl, ".xz") ? "xz" : "none", sink); downloader->download(std::move(request), *decompressor); decompressor->finish(); }); @@ -61,7 +62,7 @@ void builtinFetchurl(const BasicDerivation& drv, const std::string& netrcData) { /* Try the hashed mirrors first. */ if (getAttr("outputHashMode") == "flat") for (auto hashedMirror : settings.hashedMirrors.get()) try { - if (!hasSuffix(hashedMirror, "/")) { + if (!absl::EndsWith(hashedMirror, "/")) { hashedMirror += '/'; } auto ht = parseHashType(getAttr("outputHashAlgo")); diff --git a/third_party/nix/src/libstore/derivations.cc b/third_party/nix/src/libstore/derivations.cc index f8770327bf9e..9f2aa5ea924f 100644 --- a/third_party/nix/src/libstore/derivations.cc +++ b/third_party/nix/src/libstore/derivations.cc @@ -1,5 +1,7 @@ #include "derivations.hh" +#include <absl/strings/match.h> + #include "fs-accessor.hh" #include "globals.hh" #include "istringstream_nocopy.hh" @@ -299,7 +301,7 @@ std::string Derivation::unparse() const { } bool isDerivation(const std::string& fileName) { - return hasSuffix(fileName, drvExtension); + return absl::EndsWith(fileName, drvExtension); } bool BasicDerivation::isFixedOutput() const { diff --git a/third_party/nix/src/libstore/download.cc b/third_party/nix/src/libstore/download.cc index bebe0d1bf848..8b36063dabc5 100644 --- a/third_party/nix/src/libstore/download.cc +++ b/third_party/nix/src/libstore/download.cc @@ -1,6 +1,7 @@ #include "download.hh" #include <absl/strings/ascii.h> +#include <absl/strings/match.h> #include <absl/strings/numbers.h> #include "archive.hh" @@ -653,8 +654,8 @@ struct CurlDownloader : public Downloader { } void enqueueItem(const std::shared_ptr<DownloadItem>& item) { - if (item->request.data && !hasPrefix(item->request.uri, "http://") && - !hasPrefix(item->request.uri, "https://")) { + if (item->request.data && !absl::StartsWith(item->request.uri, "http://") && + !absl::StartsWith(item->request.uri, "https://")) { throw nix::Error("uploading to '%s' is not supported", item->request.uri); } @@ -690,7 +691,7 @@ struct CurlDownloader : public Downloader { void enqueueDownload(const DownloadRequest& request, Callback<DownloadResult> callback) override { /* Ugly hack to support s3:// URIs. */ - if (hasPrefix(request.uri, "s3://")) { + if (absl::StartsWith(request.uri, "s3://")) { // FIXME: do this on a worker thread try { #ifdef ENABLE_S3 diff --git a/third_party/nix/src/libstore/gc.cc b/third_party/nix/src/libstore/gc.cc index 1b2364c25383..262f17df0338 100644 --- a/third_party/nix/src/libstore/gc.cc +++ b/third_party/nix/src/libstore/gc.cc @@ -6,6 +6,7 @@ #include <random> #include <regex> +#include <absl/strings/match.h> #include <fcntl.h> #include <sys/stat.h> #include <sys/statvfs.h> @@ -512,7 +513,7 @@ struct LocalStore::GCState { bool LocalStore::isActiveTempFile(const GCState& state, const Path& path, const std::string& suffix) { - return hasSuffix(path, suffix) && + return absl::EndsWith(path, suffix) && state.tempRoots.find(std::string( path, 0, path.size() - suffix.size())) != state.tempRoots.end(); } diff --git a/third_party/nix/src/libstore/local-binary-cache-store.cc b/third_party/nix/src/libstore/local-binary-cache-store.cc index 00bb21eb24fe..88dd19a32069 100644 --- a/third_party/nix/src/libstore/local-binary-cache-store.cc +++ b/third_party/nix/src/libstore/local-binary-cache-store.cc @@ -1,5 +1,7 @@ #include <utility> +#include <absl/strings/match.h> + #include "binary-cache-store.hh" #include "globals.hh" #include "nar-info-disk-cache.hh" @@ -39,7 +41,7 @@ class LocalBinaryCacheStore : public BinaryCacheStore { PathSet paths; for (auto& entry : readDirectory(binaryCacheDir)) { - if (entry.name.size() != 40 || !hasSuffix(entry.name, ".narinfo")) { + if (entry.name.size() != 40 || !absl::EndsWith(entry.name, ".narinfo")) { continue; } paths.insert(storeDir + "/" + diff --git a/third_party/nix/src/libstore/machines.cc b/third_party/nix/src/libstore/machines.cc index 6472e037d14c..bbb84784c4f0 100644 --- a/third_party/nix/src/libstore/machines.cc +++ b/third_party/nix/src/libstore/machines.cc @@ -3,6 +3,7 @@ #include <algorithm> #include <absl/strings/ascii.h> +#include <absl/strings/match.h> #include <absl/strings/string_view.h> #include <glog/logging.h> @@ -21,9 +22,10 @@ Machine::Machine(decltype(storeUri)& storeUri, // Backwards compatibility: if the URI is a hostname, // prepend ssh://. storeUri.find("://") != std::string::npos || - hasPrefix(storeUri, "local") || - hasPrefix(storeUri, "remote") || - hasPrefix(storeUri, "auto") || hasPrefix(storeUri, "/") + absl::StartsWith(storeUri, "local") || + absl::StartsWith(storeUri, "remote") || + absl::StartsWith(storeUri, "auto") || + absl::StartsWith(storeUri, "/") ? storeUri : "ssh://" + storeUri), systemTypes(systemTypes), diff --git a/third_party/nix/src/libstore/s3-binary-cache-store.cc b/third_party/nix/src/libstore/s3-binary-cache-store.cc index 2b25fd874437..d713c5ce0151 100644 --- a/third_party/nix/src/libstore/s3-binary-cache-store.cc +++ b/third_party/nix/src/libstore/s3-binary-cache-store.cc @@ -3,6 +3,7 @@ #include "s3-binary-cache-store.hh" #include <absl/strings/ascii.h> +#include <absl/strings/match.h> #include <aws/core/Aws.h> #include <aws/core/VersionConfig.h> #include <aws/core/auth/AWSCredentialsProvider.h> @@ -347,12 +348,12 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore { void upsertFile(const std::string& path, const std::string& data, const std::string& mimeType) override { - if (narinfoCompression != "" && hasSuffix(path, ".narinfo")) + if (narinfoCompression != "" && absl::EndsWith(path, ".narinfo")) uploadFile(path, *compress(narinfoCompression, data), mimeType, narinfoCompression); - else if (lsCompression != "" && hasSuffix(path, ".ls")) + else if (lsCompression != "" && absl::EndsWith(path, ".ls")) uploadFile(path, *compress(lsCompression, data), mimeType, lsCompression); - else if (logCompression != "" && hasPrefix(path, "log/")) + else if (logCompression != "" && absl::StartsWith(path, "log/")) uploadFile(path, *compress(logCompression, data), mimeType, logCompression); else @@ -400,7 +401,7 @@ struct S3BinaryCacheStoreImpl : public S3BinaryCacheStore { for (auto object : contents) { auto& key = object.GetKey(); - if (key.size() != 40 || !hasSuffix(key, ".narinfo")) { + if (key.size() != 40 || !absl::EndsWith(key, ".narinfo")) { continue; } paths.insert(storeDir + "/" + key.substr(0, key.size() - 8)); diff --git a/third_party/nix/src/libstore/ssh.cc b/third_party/nix/src/libstore/ssh.cc index 06aaf285f1b5..76c78b2fcd77 100644 --- a/third_party/nix/src/libstore/ssh.cc +++ b/third_party/nix/src/libstore/ssh.cc @@ -2,6 +2,8 @@ #include <utility> +#include <absl/strings/match.h> + namespace nix { SSHMaster::SSHMaster(const std::string& host, std::string keyFile, @@ -12,7 +14,7 @@ SSHMaster::SSHMaster(const std::string& host, std::string keyFile, useMaster(useMaster && !fakeSSH), compress(compress), logFD(logFD) { - if (host.empty() || hasPrefix(host, "-")) { + if (host.empty() || absl::StartsWith(host, "-")) { throw Error("invalid SSH host name '%s'", host); } } diff --git a/third_party/nix/src/libstore/store-api.cc b/third_party/nix/src/libstore/store-api.cc index 54214e6f4e94..9440d78d5f12 100644 --- a/third_party/nix/src/libstore/store-api.cc +++ b/third_party/nix/src/libstore/store-api.cc @@ -3,6 +3,7 @@ #include <future> #include <utility> +#include <absl/strings/match.h> #include <absl/strings/numbers.h> #include <glog/logging.h> @@ -771,7 +772,7 @@ bool ValidPathInfo::isContentAddressed(const Store& store) const { << "' claims to be content-addressed but isn't"; }; - if (hasPrefix(ca, "text:")) { + if (absl::StartsWith(ca, "text:")) { Hash hash(std::string(ca, 5)); if (store.makeTextPath(storePathToName(path), hash, references) == path) { return true; @@ -780,7 +781,7 @@ bool ValidPathInfo::isContentAddressed(const Store& store) const { } - else if (hasPrefix(ca, "fixed:")) { + else if (absl::StartsWith(ca, "fixed:")) { bool recursive = ca.compare(6, 2, "r:") == 0; Hash hash(std::string(ca, recursive ? 8 : 6)); if (references.empty() && @@ -906,7 +907,7 @@ StoreType getStoreType(const std::string& uri, const std::string& stateDir) { if (uri == "daemon") { return tDaemon; } - if (uri == "local" || hasPrefix(uri, "/")) { + if (uri == "local" || absl::StartsWith(uri, "/")) { return tLocal; } else if (uri.empty() || uri == "auto") { if (access(stateDir.c_str(), R_OK | W_OK) == 0) { @@ -930,7 +931,7 @@ static RegisterStoreImplementation regStore([](const std::string& uri, return std::shared_ptr<Store>(std::make_shared<UDSRemoteStore>(params)); case tLocal: { Store::Params params2 = params; - if (hasPrefix(uri, "/")) { + if (absl::StartsWith(uri, "/")) { params2["root"] = uri; } return std::shared_ptr<Store>(std::make_shared<LocalStore>(params2)); |