@0perator/operator 0.1.360-next.0 → 0.1.360-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/toolchain.js +14 -1
- package/dist/toolchain/toolchain.py +20 -3
- package/dist/update.js +9 -5
- package/package.json +1 -1
package/dist/config/toolchain.js
CHANGED
|
@@ -57,6 +57,19 @@ const realOrUndefined = (b, p) => { try {
|
|
|
57
57
|
catch {
|
|
58
58
|
return undefined;
|
|
59
59
|
} };
|
|
60
|
+
// The consumer link is the one another process flips (rename(2) over it). On macOS 26 a readlink racing that rename can
|
|
61
|
+
// fail with EINVAL for an instant; that one error is retried, every other error still fails closed.
|
|
62
|
+
const linkTarget = (b, p) => {
|
|
63
|
+
for (let i = 0;; i++) {
|
|
64
|
+
try {
|
|
65
|
+
return b.fs.realpathSync(p);
|
|
66
|
+
}
|
|
67
|
+
catch (e) {
|
|
68
|
+
if (e.code !== "EINVAL" || i >= 4)
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
};
|
|
60
73
|
const allowed = (b, p, mode) => { try {
|
|
61
74
|
b.fs.accessSync(p, mode);
|
|
62
75
|
return true;
|
|
@@ -84,7 +97,7 @@ export function resolveToolchainBin(bin, opts) {
|
|
|
84
97
|
if (!store)
|
|
85
98
|
throw new ToolchainError(`no store at ${b.path.join(home, "store")}`);
|
|
86
99
|
const consumer = b.path.join(home, "consumers", opts.consumer);
|
|
87
|
-
const gen =
|
|
100
|
+
const gen = linkTarget(b, consumer);
|
|
88
101
|
if (!gen)
|
|
89
102
|
throw new ToolchainError(`consumer ${opts.consumer} is not activated (${consumer} is missing or dangling)`);
|
|
90
103
|
const n = b.path.basename(gen);
|
|
@@ -27,7 +27,7 @@ One stdlib file for /usr/bin/python3 -I (3.9.6 on both boxes): -I drops the scri
|
|
|
27
27
|
"""
|
|
28
28
|
from __future__ import annotations
|
|
29
29
|
|
|
30
|
-
import argparse, contextlib, datetime as dt, fcntl, hashlib, http.client, json, os, pathlib, platform, plistlib, pwd, re, shutil, signal, socket, stat, struct, subprocess, sys, tarfile, tempfile, time, urllib.error, urllib.parse, urllib.request, zipfile
|
|
30
|
+
import argparse, contextlib, datetime as dt, errno, fcntl, hashlib, http.client, json, os, pathlib, platform, plistlib, pwd, re, shutil, signal, socket, stat, struct, subprocess, sys, tarfile, tempfile, time, urllib.error, urllib.parse, urllib.request, zipfile
|
|
31
31
|
|
|
32
32
|
HERE = pathlib.Path(__file__).resolve().parent
|
|
33
33
|
SCHEMA = "operator.toolchain/1"
|
|
@@ -1727,14 +1727,31 @@ def cmd_rollback(args) -> int:
|
|
|
1727
1727
|
return EX_OK
|
|
1728
1728
|
|
|
1729
1729
|
|
|
1730
|
+
def link_target(p):
|
|
1731
|
+
"""realpath of the consumer link, which another process flips (rename(2) over it). On macOS 26 a readlink racing
|
|
1732
|
+
that rename can fail with EINVAL for an instant, and realpath then returns the link itself; that case is retried,
|
|
1733
|
+
every other failure fails closed (None)."""
|
|
1734
|
+
for _ in range(5):
|
|
1735
|
+
try:
|
|
1736
|
+
os.stat(p)
|
|
1737
|
+
except OSError as e:
|
|
1738
|
+
if e.errno != errno.EINVAL:
|
|
1739
|
+
return None
|
|
1740
|
+
continue
|
|
1741
|
+
real = os.path.realpath(p)
|
|
1742
|
+
if not os.path.islink(real):
|
|
1743
|
+
return real
|
|
1744
|
+
return None
|
|
1745
|
+
|
|
1746
|
+
|
|
1730
1747
|
def resolve_bin(root: pathlib.Path, consumer: str, binary: str) -> tuple:
|
|
1731
1748
|
for n in (consumer, binary):
|
|
1732
1749
|
if not re.fullmatch(r"[A-Za-z0-9][A-Za-z0-9._-]*", n):
|
|
1733
1750
|
raise Refused(f"invalid name {n!r}")
|
|
1734
1751
|
link, cdir = root / "consumers" / consumer / "bin" / binary, root / "consumers" / consumer
|
|
1735
|
-
|
|
1752
|
+
gen = link_target(cdir)
|
|
1753
|
+
if gen is None:
|
|
1736
1754
|
raise Refused(f"consumer {consumer} is not activated in {root} ({cdir} is missing or dangling)")
|
|
1737
|
-
gen = os.path.realpath(cdir)
|
|
1738
1755
|
if not re.fullmatch(r"\d+", os.path.basename(gen)) or os.path.dirname(gen) != os.path.realpath(root / "generations"):
|
|
1739
1756
|
raise Refused(f"{cdir} points at {gen}, not a generation")
|
|
1740
1757
|
# through the generation just resolved, as the gateway and engine do: back through the consumer link, a flip in between would pair generation N with another build
|
package/dist/update.js
CHANGED
|
@@ -16,12 +16,16 @@ const PKG = "@0perator/operator"; // published (private) scope/name — keep in
|
|
|
16
16
|
const DIST_BASE = "https://0perator.co/dl"; // latest.txt, next.txt, SHA256SUMS, operator-<version>.tgz (docs/INSTALL-CURL.md)
|
|
17
17
|
// An install made by install.sh: <root>/releases/<version>/node_modules/@0perator/operator, linked into a bin folder.
|
|
18
18
|
const RELEASE_PKG = /^(.*)\/releases\/[^/]+\/node_modules\/@0perator\/operator\/package\.json$/;
|
|
19
|
-
/** `--next` or `--latest
|
|
20
|
-
|
|
19
|
+
/** `--next` or `--latest`; `explicit` says a flag picked it. Both flags is a usage error. With no flag an install stays
|
|
20
|
+
* on the channel its own version came from: a bare `operator update` on a next build must not install an older
|
|
21
|
+
* release (11/25: it replaced 0.1.360 with 0.1.359). Unknown version → latest. */
|
|
22
|
+
export function updateChannel(args, current) {
|
|
21
23
|
const next = args.includes("--next"), latest = args.includes("--latest");
|
|
22
24
|
if (next && latest)
|
|
23
25
|
return { error: "operator update: --next and --latest are two channels — pass one.\n" };
|
|
24
|
-
|
|
26
|
+
if (next || latest)
|
|
27
|
+
return { channel: next ? "next" : "latest", explicit: true };
|
|
28
|
+
return { channel: current ? channelOf(current) : "latest", explicit: false };
|
|
25
29
|
}
|
|
26
30
|
// A next build is a 0.1.N-next.K prerelease; a release is a plain 0.1.N.
|
|
27
31
|
const channelOf = (version) => (/-next\.\d+$/.test(version) ? "next" : "latest");
|
|
@@ -172,8 +176,8 @@ export async function installFromDist(channel, pkgJson = fileURLToPath(new URL("
|
|
|
172
176
|
process.stderr.write(`operator update: done — now v${now} (${channel}).\n`);
|
|
173
177
|
return 0;
|
|
174
178
|
}
|
|
175
|
-
export async function runUpdate(args = []) {
|
|
176
|
-
const pick = updateChannel(args);
|
|
179
|
+
export async function runUpdate(args = [], pkgJson = fileURLToPath(new URL("../package.json", import.meta.url))) {
|
|
180
|
+
const pick = updateChannel(args, versionAt(pkgJson));
|
|
177
181
|
if ("error" in pick) {
|
|
178
182
|
process.stderr.write(pick.error);
|
|
179
183
|
return 2;
|