buninu-linux 0.8.56 → 0.10.56
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/LICENSES/MIT-ZilchOS-bootstrap-from-tcc.txt +21 -0
- package/NOTICE.md +34 -0
- package/README.md +3 -0
- package/initramfs/bin/tar +34 -46
- package/initramfs/buninu/apps/bunmsh/CHANGELOG.md +103 -0
- package/initramfs/buninu/apps/bunmsh/PORTING.md +133 -15
- package/initramfs/buninu/apps/bunmsh/help/awk.md +38 -0
- package/initramfs/buninu/apps/bunmsh/help/break.md +21 -0
- package/initramfs/buninu/apps/bunmsh/help/chmod.md +8 -2
- package/initramfs/buninu/apps/bunmsh/help/cmp.md +29 -0
- package/initramfs/buninu/apps/bunmsh/help/continue.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/cp.md +4 -0
- package/initramfs/buninu/apps/bunmsh/help/diff.md +30 -0
- package/initramfs/buninu/apps/bunmsh/help/egrep.md +26 -0
- package/initramfs/buninu/apps/bunmsh/help/export.md +2 -2
- package/initramfs/buninu/apps/bunmsh/help/expr.md +30 -0
- package/initramfs/buninu/apps/bunmsh/help/fgrep.md +25 -0
- package/initramfs/buninu/apps/bunmsh/help/grep.md +4 -0
- package/initramfs/buninu/apps/bunmsh/help/ls.md +4 -2
- package/initramfs/buninu/apps/bunmsh/help/mkdir.md +1 -1
- package/initramfs/buninu/apps/bunmsh/help/print.md +3 -0
- package/initramfs/buninu/apps/bunmsh/help/return.md +23 -0
- package/initramfs/buninu/apps/bunmsh/help/sed.md +8 -3
- package/initramfs/buninu/apps/bunmsh/help/set.md +12 -3
- package/initramfs/buninu/apps/bunmsh/help/tr.md +4 -0
- package/initramfs/buninu/apps/bunmsh/help/trap.md +22 -0
- package/initramfs/buninu/apps/bunmsh/help/uniq.md +27 -0
- package/initramfs/buninu/apps/bunmsh/package.json +1 -1
- package/initramfs/buninu/apps/bunmsh/src/awk.js +203 -0
- package/initramfs/buninu/apps/bunmsh/src/diff.js +222 -0
- package/initramfs/buninu/apps/bunmsh/src/fancy-ls.js +15 -4
- package/initramfs/buninu/apps/bunmsh/src/main.js +21 -5
- package/initramfs/buninu/apps/bunmsh/src/sed.js +159 -0
- package/initramfs/buninu/apps/bunmsh/src/shell.js +1283 -540
- package/initramfs/buninu/apps/bunmsh/test/awk-reference.test.js +35 -0
- package/initramfs/buninu/apps/bunmsh/test/awk.test.js +62 -0
- package/initramfs/buninu/apps/bunmsh/test/posix-bootstrap.test.js +595 -0
- package/initramfs/buninu/apps/bunmsh/test/utility-reference-cases.mjs +98 -0
- package/initramfs/buninu/apps/bunmsh/test/utility-reference.test.js +23 -0
- package/initramfs/buninu/apps/jsgotty/client-kitty.mjs +61 -0
- package/initramfs/buninu/apps/jsgotty/client.mjs +16 -0
- package/initramfs/buninu/apps/jsgotty/package-lock.json +2 -2
- package/initramfs/buninu/apps/jsgotty/package.json +1 -1
- package/initramfs/buninu/apps/jsgotty/tests/client-kitty.test.mjs +43 -0
- package/initramfs/etc/resolv.conf +2 -1
- package/initramfs/usr/lib/bootstrap/1.prepare-rootfs.js +106 -0
- package/initramfs/usr/lib/bootstrap/10.build-m4.js +40 -0
- package/initramfs/usr/lib/bootstrap/11.build-flex.js +50 -0
- package/initramfs/usr/lib/bootstrap/12.build-gcc.js +261 -0
- package/initramfs/usr/lib/bootstrap/2.enter-rootfs.js +49 -0
- package/initramfs/usr/lib/bootstrap/3.gen-musl-dev.js +141 -0
- package/initramfs/usr/lib/bootstrap/4.build-tcc.js +61 -0
- package/initramfs/usr/lib/bootstrap/5.build-make.js +58 -0
- package/initramfs/usr/lib/bootstrap/6.build-binutils.js +77 -0
- package/initramfs/usr/lib/bootstrap/7.build-gmp.js +68 -0
- package/initramfs/usr/lib/bootstrap/8.build-mpfr.js +59 -0
- package/initramfs/usr/lib/bootstrap/9.build-mpc.js +55 -0
- package/initramfs/usr/lib/bootstrap/LICENSE +21 -0
- package/initramfs/usr/lib/bootstrap/LICENSES/MIT-ZilchOS-bootstrap-from-tcc.txt +21 -0
- package/initramfs/usr/lib/bootstrap/NOTICE.md +65 -0
- package/initramfs/usr/lib/bootstrap/README.md +204 -0
- package/initramfs/usr/lib/bootstrap/downloads.md +49 -0
- package/initramfs/usr/lib/bootstrap/lib/build.js +155 -0
- package/initramfs/usr/lib/bootstrap/lib/common.js +134 -0
- package/initramfs/usr/lib/bootstrap/lib/compile-object.c +14 -0
- package/initramfs/usr/lib/bootstrap/lib/musl-headers.js +59 -0
- package/initramfs/usr/lib/bootstrap/lib/seed.js +148 -0
- package/initramfs/usr/lib/bootstrap/lib/startup-check.c +14 -0
- package/initramfs/usr/lib/bootstrap/lib/tcc-build.js +53 -0
- package/initramfs/usr/lib/bootstrap/sources/musl-1.2.6.tar.gz +0 -0
- package/initramfs/usr/lib/bootstrap/sources/tinycc-05f0faf-upstream.tar.gz +0 -0
- package/initramfs/usr/lib/bootstrap/sources/tinycc-local-bootstrap-files.tar.gz +0 -0
- package/initramfs/usr/share/doc/buninu-linux/tar.md +11 -0
- package/package.json +1 -1
- package/scripts/fetch.js +2 -0
- package/test/bootstrap.test.js +65 -0
- package/test/tar-strip.test.js +36 -0
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Run with Bun inside bunproot or the Buninu Linux VM.
|
|
2
|
+
import { afterAll, expect, test } from "bun:test";
|
|
3
|
+
import { mkdtempSync, mkdirSync, readFileSync, rmSync, symlinkSync, writeFileSync } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import { join, resolve } from "node:path";
|
|
6
|
+
import {
|
|
7
|
+
assertAbsent, bootstrap, download, hasBuninuId, normalizeArch, options,
|
|
8
|
+
} from "../initramfs/usr/lib/bootstrap/lib/common.js";
|
|
9
|
+
|
|
10
|
+
const work = mkdtempSync(join(tmpdir(), "bootstrap-test-"));
|
|
11
|
+
afterAll(() => rmSync(work, { recursive: true, force: true }));
|
|
12
|
+
|
|
13
|
+
test("architecture aliases and optional destination", () => {
|
|
14
|
+
for (const alias of ["a", "arm64", "aarch64"]) {
|
|
15
|
+
expect(options([alias])).toEqual({ arch: "aarch64", rootfs: resolve("roota") });
|
|
16
|
+
}
|
|
17
|
+
for (const alias of ["x", "x64", "x86_64", "x86-64"]) {
|
|
18
|
+
expect(options([alias])).toEqual({ arch: "x86_64", rootfs: resolve("rootx") });
|
|
19
|
+
}
|
|
20
|
+
const arch = normalizeArch(process.arch);
|
|
21
|
+
expect(options([])).toEqual({ arch, rootfs: resolve(arch === "aarch64" ? "roota" : "rootx") });
|
|
22
|
+
expect(options(["./a path's root"])).toEqual({ arch, rootfs: resolve("./a path's root") });
|
|
23
|
+
expect(options(["x", "./custom"])).toEqual({ arch: "x86_64", rootfs: resolve("custom") });
|
|
24
|
+
expect(() => options(["--arch", "x"])).toThrow();
|
|
25
|
+
expect(() => options(["x", "one", "two"])).toThrow();
|
|
26
|
+
expect(() => normalizeArch("riscv64")).toThrow();
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("local mode requires the exact ID, never NAME or a substring", () => {
|
|
30
|
+
for (const value of ["buninu-linux", '"buninu-linux"', "'buninu-linux'"]) {
|
|
31
|
+
expect(hasBuninuId(`NAME="Buninu Linux"\nID=${value}\n`)).toBe(true);
|
|
32
|
+
}
|
|
33
|
+
for (const text of [
|
|
34
|
+
'NAME="Buninu Linux"\nID=alpine\n',
|
|
35
|
+
'ID_LIKE=buninu-linux\n', '# ID=buninu-linux\n',
|
|
36
|
+
'ID=buninu-linux-other\n', 'ID=buninu-linux\nID=alpine\n',
|
|
37
|
+
'ID="$(echo buninu-linux)"\n',
|
|
38
|
+
]) expect(hasBuninuId(text)).toBe(false);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test("existing destinations, including dangling links, are refused", () => {
|
|
42
|
+
const file = join(work, "file"), link = join(work, "link");
|
|
43
|
+
writeFileSync(file, "keep me");
|
|
44
|
+
symlinkSync("missing", link);
|
|
45
|
+
expect(() => assertAbsent(file)).toThrow("Refusing existing destination");
|
|
46
|
+
expect(() => assertAbsent(link)).toThrow("Refusing existing destination");
|
|
47
|
+
expect(() => assertAbsent(join(work, "new"))).not.toThrow();
|
|
48
|
+
expect(readFileSync(file, "utf8")).toBe("keep me");
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
test("a corrupt cached tarball is rejected before extraction or refetch", async () => {
|
|
52
|
+
const old = process.env.XDG_CACHE_HOME;
|
|
53
|
+
process.env.XDG_CACHE_HOME = work;
|
|
54
|
+
try {
|
|
55
|
+
const [url, pin] = Bun.YAML.parse(readFileSync(join(bootstrap, "downloads.md"), "utf8"))["buninu-linux@0.9.56"];
|
|
56
|
+
const cache = join(work, "buninu-bootstrap");
|
|
57
|
+
mkdirSync(cache);
|
|
58
|
+
writeFileSync(join(cache, pin.slice(7) + "-" + new URL(url).pathname.split("/").at(-1)), "corrupt");
|
|
59
|
+
await expect(download("buninu-linux@0.9.56")).rejects.toThrow("Cached file hash mismatch");
|
|
60
|
+
await expect(download("unlisted@version")).rejects.toThrow("Missing or invalid download pin");
|
|
61
|
+
} finally {
|
|
62
|
+
if (old === undefined) delete process.env.XDG_CACHE_HOME;
|
|
63
|
+
else process.env.XDG_CACHE_HOME = old;
|
|
64
|
+
}
|
|
65
|
+
});
|
package/test/tar-strip.test.js
CHANGED
|
@@ -216,3 +216,39 @@ test("does not follow a pre-existing symlink parent or an archive symlink parent
|
|
|
216
216
|
expect(result.status).toBe(2);
|
|
217
217
|
expect(existsSync(join(outside, "nested"))).toBe(false);
|
|
218
218
|
});
|
|
219
|
+
|
|
220
|
+
test("APK concatenated gzip/tar streams list and extract every section", () => {
|
|
221
|
+
const signature = tar([{ name: ".SIGN.test", data: "signature" }]);
|
|
222
|
+
const control = tar([{ name: ".PKGINFO", data: "pkgname = sample\n" }]);
|
|
223
|
+
const data = tar([
|
|
224
|
+
{ name: "usr/include/stdio.h", data: "header\n" },
|
|
225
|
+
{ name: "usr/lib/crt1.o", data: "object\n" },
|
|
226
|
+
{ name: "usr/lib/link", type: "2", target: "crt1.o" },
|
|
227
|
+
]);
|
|
228
|
+
// APK signature/control streams can omit end markers; also cover complete
|
|
229
|
+
// concatenated tar archives, and a single gzip stream containing them all.
|
|
230
|
+
for (const raw of [false, true]) {
|
|
231
|
+
const parts = [raw ? signature.subarray(0, -1024) : signature,
|
|
232
|
+
raw ? control.subarray(0, -1024) : control, data];
|
|
233
|
+
for (const bytes of [Buffer.concat(parts.map(p => Bun.gzipSync(p))), Bun.gzipSync(Buffer.concat(parts))]) {
|
|
234
|
+
const result = extract(bytes, [], true);
|
|
235
|
+
expect(result.status).toBe(0);
|
|
236
|
+
expect(readFileSync(join(result.dir, ".PKGINFO"), "utf8")).toBe("pkgname = sample\n");
|
|
237
|
+
expect(readFileSync(join(result.dir, "usr/include/stdio.h"), "utf8")).toBe("header\n");
|
|
238
|
+
expect(readlinkSync(join(result.dir, "usr/lib/link"))).toBe("crt1.o");
|
|
239
|
+
const listed = run(["-tf", "-"], bytes);
|
|
240
|
+
expect(listed.status).toBe(0);
|
|
241
|
+
expect(listed.stdout.trim().split("\n")).toEqual([
|
|
242
|
+
".SIGN.test", ".PKGINFO", "usr/include/stdio.h", "usr/lib/crt1.o", "usr/lib/link",
|
|
243
|
+
]);
|
|
244
|
+
const selected = extract(bytes, ["usr/include"], true);
|
|
245
|
+
expect(selected.status).toBe(0);
|
|
246
|
+
expect(existsSync(join(selected.dir, ".PKGINFO"))).toBe(false);
|
|
247
|
+
expect(readFileSync(join(selected.dir, "usr/include/stdio.h"), "utf8")).toBe("header\n");
|
|
248
|
+
const stripped = extract(bytes, ["--strip-components=2", "--exclude=usr/lib", "usr"], true);
|
|
249
|
+
expect(stripped.status).toBe(0);
|
|
250
|
+
expect(readFileSync(join(stripped.dir, "stdio.h"), "utf8")).toBe("header\n");
|
|
251
|
+
expect(existsSync(join(stripped.dir, "crt1.o"))).toBe(false);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
});
|