Skip to content

Commit d2e72d0

Browse files
authored
Merge branch 'master' into master
2 parents 20a898a + 10188a5 commit d2e72d0

File tree

7 files changed

+223
-102
lines changed

7 files changed

+223
-102
lines changed

default.nix

Lines changed: 0 additions & 44 deletions
This file was deleted.

file-cache.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public:
140140
throw Error("NAR index for ‘%s’ has an unsupported version", storePath);
141141

142142
recurse("", ls.at("root"));
143-
} catch (std::invalid_argument & e) {
143+
} catch (json::parse_error & e) {
144144
// FIXME: some filenames have non-UTF8 characters in them,
145145
// which is not supported by nlohmann::json. So we have to
146146
// skip the entire package.

flake.lock

Lines changed: 59 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
{
2+
edition = 201909;
3+
4+
description = "Script for generating Nixpkgs/NixOS channels";
5+
6+
inputs.nixpkgs.url = "nixpkgs/release-19.09";
7+
8+
outputs = { self, nixpkgs, nix }:
9+
10+
{
11+
12+
overlay = final: prev: {
13+
14+
nixos-channel-scripts = with final; stdenv.mkDerivation {
15+
name = "nixos-channel-scripts";
16+
17+
buildInputs = with final.perlPackages;
18+
[ pkgconfig
19+
final.nix
20+
sqlite
21+
makeWrapper
22+
perl
23+
FileSlurp
24+
LWP
25+
LWPProtocolHttps
26+
ListMoreUtils
27+
DBDSQLite
28+
NetAmazonS3
29+
boehmgc
30+
nlohmann_json
31+
boost
32+
];
33+
34+
buildCommand = ''
35+
mkdir -p $out/bin
36+
37+
cp ${./file-cache.hh} file-cache.hh
38+
39+
g++ -Os -g ${./generate-programs-index.cc} -Wall -std=c++14 -o $out/bin/generate-programs-index -I . \
40+
$(pkg-config --cflags nix-main) \
41+
$(pkg-config --libs nix-main) \
42+
$(pkg-config --libs nix-expr) \
43+
$(pkg-config --libs nix-store) \
44+
-lsqlite3 -lgc -lnixrust
45+
46+
g++ -Os -g ${./index-debuginfo.cc} -Wall -std=c++14 -o $out/bin/index-debuginfo -I . \
47+
$(pkg-config --cflags nix-main) \
48+
$(pkg-config --libs nix-main) \
49+
$(pkg-config --libs nix-store) \
50+
-lsqlite3 -lnixrust
51+
52+
cp ${./mirror-nixos-branch.pl} $out/bin/mirror-nixos-branch
53+
wrapProgram $out/bin/mirror-nixos-branch --set PERL5LIB $PERL5LIB --prefix PATH : ${wget}/bin:${git}/bin:${final.nix}/bin:${gnutar}/bin:${xz}/bin:${rsync}/bin:${openssh}/bin:$out/bin
54+
55+
patchShebangs $out/bin
56+
'';
57+
};
58+
59+
};
60+
61+
defaultPackage.x86_64-linux = (import nixpkgs {
62+
system = "x86_64-linux";
63+
overlays = [ nix.overlay self.overlay ];
64+
}).nixos-channel-scripts;
65+
66+
};
67+
}

generate-programs-index.cc

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ void mainWrapped(int argc, char * * argv)
4949
auto binaryCache = openStore(binaryCacheUri).cast<BinaryCacheStore>();
5050

5151
/* Get the allowed store paths to be included in the database. */
52-
auto allowedPaths = tokenizeString<PathSet>(readFile(storePathsFile, true));
52+
auto allowedPaths = binaryCache->parseStorePathSet(tokenizeString<PathSet>(readFile(storePathsFile, true)));
5353

54-
PathSet allowedPathsClosure;
54+
StorePathSet allowedPathsClosure;
5555
binaryCache->computeFSClosure(allowedPaths, allowedPathsClosure);
5656

57-
printMsg(lvlInfo, format("%d top-level paths, %d paths in closure")
58-
% allowedPaths.size() % allowedPathsClosure.size());
57+
printMsg(lvlInfo, "%d top-level paths, %d paths in closure",
58+
allowedPaths.size(), allowedPathsClosure.size());
5959

6060
FileCache fileCache(cacheDbPath);
6161

@@ -104,24 +104,25 @@ void mainWrapped(int argc, char * * argv)
104104

105105
/* For each store path, figure out the package with the shortest
106106
attribute name. E.g. "nix" is preferred over "nixStable". */
107-
std::map<Path, DrvInfo *> packagesByPath;
107+
std::map<StorePath, DrvInfo *> packagesByPath;
108108

109109
for (auto & package : packages)
110110
try {
111111
auto outputs = package.queryOutputs(true);
112112

113113
for (auto & output : outputs) {
114-
if (!allowedPathsClosure.count(output.second)) continue;
115-
auto i = packagesByPath.find(output.second);
114+
auto storePath = binaryCache->parseStorePath(output.second);
115+
if (!allowedPathsClosure.count(storePath)) continue;
116+
auto i = packagesByPath.find(storePath);
116117
if (i != packagesByPath.end() &&
117118
(i->second->attrPath.size() < package.attrPath.size() ||
118-
(i->second->attrPath.size() == package.attrPath.size() && i->second->attrPath < package.attrPath)))
119+
(i->second->attrPath.size() == package.attrPath.size() && i->second->attrPath < package.attrPath)))
119120
continue;
120-
packagesByPath[output.second] = &package;
121+
packagesByPath.emplace(std::move(storePath), &package);
121122
}
122123
} catch (AssertionError & e) {
123124
} catch (Error & e) {
124-
e.addPrefix(format("in package ‘%s’: ") % package.attrPath);
125+
e.addPrefix(fmt("in package ‘%s’: ", package.attrPath));
125126
throw;
126127
}
127128

@@ -203,7 +204,7 @@ void mainWrapped(int argc, char * * argv)
203204
ThreadPool threadPool(16);
204205

205206
for (auto & i : packagesByPath)
206-
threadPool.enqueue(std::bind(doPath, i.first, i.second));
207+
threadPool.enqueue(std::bind(doPath, binaryCache->printStorePath(i.first), i.second));
207208

208209
threadPool.process();
209210

index-debuginfo.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ void mainWrapped(int argc, char * * argv)
2929
if (hasSuffix(binaryCacheUri, "/")) binaryCacheUri.pop_back();
3030
auto binaryCache = openStore(binaryCacheUri).cast<S3BinaryCacheStore>();
3131

32-
auto storePaths = tokenizeString<PathSet>(readFile(storePathsFile, true));
32+
auto storePaths = binaryCache->parseStorePathSet(tokenizeString<PathSet>(readFile(storePathsFile, true)));
3333

3434
std::regex debugFileRegex("^lib/debug/\\.build-id/[0-9a-f]{2}/[0-9a-f]{38}\\.debug$");
3535

@@ -68,7 +68,7 @@ void mainWrapped(int argc, char * * argv)
6868
std::string(file.first, prefix.size(), 2) +
6969
std::string(file.first, prefix.size() + 3, 38);
7070

71-
auto info = binaryCache->queryPathInfo(storePath).cast<const NarInfo>();
71+
auto info = binaryCache->queryPathInfo(binaryCache->parseStorePath(storePath)).cast<const NarInfo>();
7272

7373
assert(hasPrefix(info->url, "nar/"));
7474

@@ -84,8 +84,8 @@ void mainWrapped(int argc, char * * argv)
8484
};
8585

8686
for (auto & storePath : storePaths)
87-
if (hasSuffix(storePath, "-debug"))
88-
threadPool.enqueue(std::bind(doPath, storePath));
87+
if (hasSuffix(storePath.name(), "-debug"))
88+
threadPool.enqueue(std::bind(doPath, binaryCache->printStorePath(storePath)));
8989

9090
threadPool.process();
9191
}

0 commit comments

Comments
 (0)