Build each split package recipe once per target
@@ -93,6 +93,8 @@ Each port gets a fresh, signed SDK containing its transitive prerequisites. The
9393
9494An empty queue reused the existing AArch64 musl and musl-fts archives with the compiler path set to a nonexistent executable. Both archives passed the page audit. The worker also rejected a changed recipe with the same package version and an archive with a mismatched checksum. See `foundation/queue-shared-reuse-01`, receipt SHA-256 `bcab78e7e9fd1d0b86800c32870ceea84abcd5ce54781ddb42d1c46e5970d213`.
9595
96+Source plans record the recipe directory for each output package. The queue invokes a split recipe once, validates its complete output list and records each archive separately. The AArch64 fixture requested two split packages, built them in one invocation and reused both in an empty queue with the compiler disabled. See `foundation/queue-split-reuse-01`, receipt SHA-256 `437ce9d0bea7bd7e8409877584c082c32804530217a7b5bb65879b624caba2bc`.
97+
9698The published x86_64 Vinix kernel booted 32 signed network packages. It refreshed the trust store with a local CA, established loopback HTTPS, rejected the wrong hostname, committed and read a Git file, signed and verified that file with the installed SSH tools, then installed and queried a local XBPS package. The fixture and logs are `tests/userland/network.sh` and `foundation/network-guest-03`, receipt SHA-256 `4e9afac33947b999911a4ff35f218b49f3356b345e47e7b90e7ffce644d0c7b4`.
9799
98100An eight-package x86_64 guest tested the BusyBox wget applet and its separately packaged TLS helper. It rejected an unknown certificate, retrieved the expected bytes after installing the local CA, and rejected the same certificate for a different hostname. The guest fixture is `tests/userland/wget.sh`. The worker keeps the install, audit and serial hashes in `foundation/wget-guest-x86_64-01/receipts.sha256`, SHA-256 `5872d1467ee2594b9305bed5fa1ceb084c8c3fde4ebccb0539db25d02b3849f9`.
@@ -72,6 +72,7 @@ def recipe_records(args):
7272 release, = info["pkgrel"]
7373 epoch, = info.get("epoch", ["0"])
7474 info["pkgver"] = [(epoch + ":" if epoch != "0" else "") + version + "-" + release]
75+ info["source_recipe"] = [recipe.parent.name]
7576 for name in info["pkgname"]:
7677 yield name, info
7778
@@ -125,10 +126,12 @@ def plan(args):
125126 table.writerows(sorted(edges))
126127 with (args.output / "order.tsv").open("x") as stream:
127128 table = csv.writer(stream, delimiter="\t", lineterminator="\n")
128- table.writerow(["stage", "package", "version", "depends_on", "unresolved_packages"])
129+ columns = ["stage", "package", "version", "depends_on", "unresolved_packages"]
130+ table.writerow(columns + (["source_recipe"] if args.recipes else []))
129131 for name in sorted(packages, key=lambda n: (stages.get(n, level), n)):
130- table.writerow([stages.get(name, "pending"), name, packages[name]["pkgver"][0],
131- ",".join(sorted(needs[name])), ",".join(sorted(needs[name] & remaining))])
132+ fields = [stages.get(name, "pending"), name, packages[name]["pkgver"][0],
133+ ",".join(sorted(needs[name])), ",".join(sorted(needs[name] & remaining))]
134+ table.writerow(fields + (packages[name]["source_recipe"] if args.recipes else []))
132135 print(f"{args.arch}: ordered {len(stages)} of {len(packages)} packages in {level} stages")
133136 if remaining:
134137 raise SystemExit(f"unresolved providers or cycles: {', '.join(sorted(remaining))}; see edges.tsv")
@@ -81,8 +81,8 @@ def record_archive(artifacts, name, filename, checksum):
8181 receipt.with_suffix(".new").replace(receipt)
8282
8383
84-def reuse_archive(args, artifacts, logs, name, version):
85- recipe = args.recipes / name / "PKGBUILD.vile"
84+def reuse_archive(args, artifacts, logs, name, version, recipe_name):
85+ recipe = args.recipes / recipe_name / "PKGBUILD.vile"
8686 if not recipe.is_file():
8787 return
8888 filename = f"{name}-{version}"
@@ -127,17 +127,17 @@ def reuse_archive(args, artifacts, logs, name, version):
127127 print(f"Reused {name} {version} from {archive.parent}", flush=True)
128128
129129
130-def build(args, name, version, receipts, logs, artifacts):
130+def build(args, recipe_name, outputs, receipts, logs, artifacts):
131131 # Each package gets its own SDK and source directory. Keep the small
132132 # evidence files and signed input hashes after recycling the scratch space.
133133 scripts = Path(__file__).resolve().parents[1] / "tests"
134- with tempfile.TemporaryDirectory(prefix=name + "-", dir=args.work / "scratch") as tmp:
134+ with tempfile.TemporaryDirectory(prefix=recipe_name + "-", dir=args.work / "scratch") as tmp:
135135 area = Path(tmp)
136136 (area / SCRATCH_MARKER).touch()
137137 sdk = area / "sdk"
138138 recipe = area / "port"
139- shutil.copytree(args.recipes / name, recipe)
140- with (logs / (name + "-recipe.sha256")).open("w") as source:
139+ shutil.copytree(args.recipes / recipe_name, recipe)
140+ with (logs / (recipe_name + "-recipe.sha256")).open("w") as source:
141141 for file in sorted(recipe.rglob("*")):
142142 if file.is_file():
143143 source.write(f"{digest(file)} {file.relative_to(recipe)}\n")
@@ -146,7 +146,7 @@ def build(args, name, version, receipts, logs, artifacts):
146146 VPAC_MAKEPKG_DB=str(sdk / "client/db"), VINIX_SYSROOT=str(sdk / "client/root"))
147147 env["PKG_CONFIG_SYSROOT_DIR"] = env["VINIX_SYSROOT"]
148148 env["PKG_CONFIG_LIBDIR"] = ":".join(env["VINIX_SYSROOT"] + d for d in ("/usr/lib/pkgconfig", "/usr/share/pkgconfig"))
149- with (logs / (name + "-build.log")).open("w") as log:
149+ with (logs / (recipe_name + "-build.log")).open("w") as log:
150150 def run(cmd, **kwargs):
151151 subprocess.run(cmd, stdout=log, stderr=subprocess.STDOUT, check=True, **kwargs)
152152 try:
@@ -154,23 +154,34 @@ def build(args, name, version, receipts, logs, artifacts):
154154 finally:
155155 for filename in ("selection.tsv", "audit.log", "install.log", "publish.log"):
156156 if (sdk / filename).is_file():
157- shutil.copyfile(sdk / filename, logs / (name + "-sdk-" + filename))
157+ shutil.copyfile(sdk / filename, logs / (recipe_name + "-sdk-" + filename))
158158 command = [args.vpac, "--native-build", recipe / "PKGBUILD.vile", manifest]
159159 if args.arch != os.uname().machine:
160160 command.append("--target=" + args.arch)
161161 run(["flock", args.lock, *command], env=env)
162- archive, = [Path(p) for p in manifest.read_text().splitlines() if p]
163- check_archive(archive, name, version, args.arch)
164- with (logs / (name + "-pages.tsv")).open("w") as report:
165- subprocess.run([sys.executable, scripts / "archive-pages.py", args.arch, archive],
166- check=True, stdout=report, stderr=log)
167- output = artifacts / archive.name
168- checksum = digest(archive)
169- if output.exists() and digest(output) != checksum:
170- raise ValueError(f"{name}: conflicting archive for version {version}")
171- if not output.exists():
172- os.replace(archive, output)
173- record_archive(artifacts, name, output.name, checksum)
162+ archives = {}
163+ for path in manifest.read_text().splitlines():
164+ archive = Path(path)
165+ name = archive_fields(archive, ".PKGINFO")["pkgname"]
166+ if name not in outputs or name in archives:
167+ raise ValueError(f"{recipe_name}: unexpected build output {name}")
168+ version = outputs[name]
169+ check_archive(archive, name, version, args.arch)
170+ with (logs / (name + "-pages.tsv")).open("w") as report:
171+ subprocess.run([sys.executable, scripts / "archive-pages.py", args.arch, archive],
172+ check=True, stdout=report, stderr=log)
173+ checksum = digest(archive)
174+ output = artifacts / archive.name
175+ if output.exists() and digest(output) != checksum:
176+ raise ValueError(f"{name}: conflicting archive for version {version}")
177+ archives[name] = (archive, output, checksum)
178+ if archives.keys() != outputs.keys():
179+ raise ValueError(f"{recipe_name}: missing build outputs {sorted(outputs.keys() - archives.keys())}")
180+ for archive, output, _ in archives.values():
181+ if not output.exists():
182+ os.replace(archive, output)
183+ for name, (_, output, checksum) in archives.items():
184+ record_archive(artifacts, name, output.name, checksum)
174185
175186
176187def run_queue(args):
@@ -185,16 +196,27 @@ def run_queue(args):
185196 shutil.rmtree(old)
186197 pending = list(dict.fromkeys(args.packages))
187198 dependencies = {name: prerequisites(name, graph) for name in pending}
199+ recipes = {}
200+ recipe_names = {}
201+ for name, row in graph.items():
202+ recipe = row.get("source_recipe") or name
203+ if Path(recipe).name != recipe or recipe in ("", ".", ".."):
204+ raise ValueError(f"{name}: invalid source recipe directory {recipe!r}")
205+ recipe_names[name] = recipe
206+ recipes.setdefault(recipe, {})[name] = row["version"]
188207 reusable = set(pending)
189208 for deps in dependencies.values():
190209 reusable.update(deps)
191210 for name in sorted(reusable):
192211 if args.reuse and not (artifacts / (name + ".sha256")).exists():
193- reuse_archive(args, artifacts, logs, name, graph[name]["version"])
194- failed = []
212+ reuse_archive(args, artifacts, logs, name, graph[name]["version"], recipe_names[name])
213+ failed = set()
195214 while pending:
196215 progress = False
197216 for name in pending.copy():
217+ if name in failed:
218+ pending.remove(name)
219+ continue
198220 receipt = artifacts / (name + ".sha256")
199221 if receipt.exists():
200222 archive, expected = archive_from_receipt(artifacts, name, graph[name]["version"], args.arch)
@@ -211,15 +233,16 @@ def run_queue(args):
211233 archive_from_receipt(artifacts, dep, graph[dep]["version"], args.arch)
212234 if shutil.disk_usage(args.work).free < args.reserve_mib * 1024**2:
213235 raise RuntimeError("build volume reached its configured free-space reserve")
214- print(f"Building {name} {graph[name]['version']}", flush=True)
215- record_limits(logs / (name + "-cgroup-before"))
236+ recipe = recipe_names[name]
237+ print(f"Building {recipe} {graph[name]['version']}", flush=True)
238+ record_limits(logs / (recipe + "-cgroup-before"))
216239 try:
217- build(args, name, graph[name]["version"], receipts, logs, artifacts)
240+ build(args, recipe, recipes[recipe], receipts, logs, artifacts)
218241 except (subprocess.CalledProcessError, ValueError, OSError) as error:
219- failed.append(name)
220- print(f"Failed {name}: {error}. See {logs / (name + '-build.log')}", file=sys.stderr, flush=True)
242+ failed.update(recipes[recipe])
243+ print(f"Failed {recipe}: {error}. See {logs / (recipe + '-build.log')}", file=sys.stderr, flush=True)
221244 finally:
222- record_limits(logs / (name + "-cgroup-after"))
245+ record_limits(logs / (recipe + "-cgroup-after"))
223246 pending.remove(name)
224247 progress = True
225248 if not progress: