ww: implement local vendor package semantics

This commit is contained in:
2026-08-13 19:18:00 +09:00
parent 088105413d
commit b84fb3ff25
6 changed files with 2128 additions and 295 deletions

View File

@@ -45,6 +45,7 @@ type pkgplan = struct {
identity: str,
root: str,
workdir: str,
workdircreated: bool,
buildout: str,
builderr: str,
start: i32,
@@ -726,15 +727,21 @@ fn pkgsetplanpaths(p: *pkgplan, groups: []pkggroup, root: str, index: i32,
p.root = strings.concat(root, "/plan-", num);
if (!pkgmakedir(p.root)) { return false; };
p.workdir = "";
p.workdircreated = false;
if (workroot.len != 0) {
// Canonical request-directory identity makes equivalent spellings and
// product reorderings select one command-scoped driver workdir.
p.workdir = strings.concat(workroot, "/",
pkgworkkey(p.sourceroot));
match (os.mkdirs(p.workdir, 448)) {
match (os.mkdirs(workroot, 448)) {
case void => void;
case let e: os.oserror => return false;
};
let mr: i32 = os.mkdir(p.workdir, 448i32);
if (mr == 0) { p.workdircreated = true; }
else if (mr != -17 || !pkgisdir(p.workdir)) {
return false;
};
};
p.buildout = strings.concat(p.root, "/build.stdout");
p.builderr = strings.concat(p.root, "/build.stderr");
@@ -1466,6 +1473,15 @@ export fn packagecommand(args: []str) int = {
i = 0;
for (i < plans.len) {
failed += pkgemitplan(&plans[i], groups, compileonly);
// The driver commits its tool stamp only after semantic preflight. If
// this request minted the persistent directory and rejection left it
// unstamped, reclaim it only if it is still empty. A concurrent or
// interrupted writer's contents are never recursively removed.
if (plans[i].workdircreated
&& !os.exists(strings.concat(plans[i].workdir, "/.wwtool.stamp"))) {
let rr: i32 = os.rmdir(plans[i].workdir);
if (rr != 0 && rr != -2) { failed += 1; };
};
i += 1;
};
if (!pkgremoveall(tmproot)) {