Credit the GL renderer's and the page's upstreams, and ship their notices in THIRD-PARTY.md: in the npm package, the release assets and the page's /licenses.md

This commit is contained in:
Pooya Parsa
2026-11-23 11:06:46 +00:00
parent 7c5e67d479
commit fda0adc839
6 changed files with 223 additions and 10 deletions

View File

@@ -396,7 +396,8 @@ jobs:
# The release's assets: the npm tarball (the base bundle and no distro
# image: the SDK downloads those by the tag), unkernel.wasm, distros.json,
# the images it names (not the .ext4, .tar or .id files next to them) and
# the GL renderer for the page (virgl.mjs, virgl.wasm).
# the GL renderer for the page (virgl.mjs, virgl.wasm), and the
# third-party notices those carry (THIRD-PARTY.md).
- name: Pack
run: |
mkdir -p out
@@ -412,7 +413,7 @@ jobs:
echo "::error::the npm package is $size bytes (more than 20 MB)"
exit 1
fi
cp vendor/build/bundle/unkernel.wasm vendor/build/distro/distros.json vendor/build/gl-wasm/virgl.mjs vendor/build/gl-wasm/virgl.wasm out/
cp vendor/build/bundle/unkernel.wasm vendor/build/distro/distros.json vendor/build/gl-wasm/virgl.mjs vendor/build/gl-wasm/virgl.wasm THIRD-PARTY.md out/
for f in $(node -p 'JSON.parse(require("node:fs").readFileSync("vendor/build/distro/distros.json", "utf8")).distros.map((d) => d.file).join(" ")'); do
cp "vendor/build/distro/$f" out/
done

View File

@@ -660,8 +660,24 @@ Thanks to:
patches and the Kbuild toolchain wrapper.
- [iSH](https://github.com/ish-app/ish) and [v86](https://github.com/copy/v86),
for showing how to build a fast user-mode emulator and a wasm JIT.
- [Alpine Linux](https://alpinelinux.org/), [wterm](https://wterm.dev/) and
[Binaryen](https://github.com/WebAssembly/binaryen).
- [virglrenderer](https://gitlab.freedesktop.org/virgl/virglrenderer) and
[Mesa](https://mesa3d.org/), for guest GL: Mesa's virgl driver in the
guest, and virglrenderer compiled to wasm with
[Emscripten](https://emscripten.org/), rendering on WebGL2 in the page.
- [Alpine Linux](https://alpinelinux.org/) and
[Debian](https://www.debian.org/), the distributions it boots, packed with
[erofs-utils](https://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs-utils.git),
[LZ4](https://github.com/lz4/lz4) and [Zstandard](https://github.com/facebook/zstd).
- [wland](https://github.com/pithings/wland), the Wayland compositor that
brings the guest's windows to the page, and [wterm](https://wterm.dev/),
the page's terminals.
- [Zig](https://ziglang.org/), [LLVM](https://llvm.org/) and
[Binaryen](https://github.com/WebAssembly/binaryen), which build it;
[React](https://react.dev/), [Tailwind CSS](https://tailwindcss.com/),
[Vite](https://vite.dev/), [Nitro](https://nitro.build/) and the
[Geist](https://vercel.com/font) fonts, which make the page.
- [Wisp](https://github.com/MercuryWorkshop/wisp-protocol), the protocol
behind the guest's network in the browser.
## 📄 License
@@ -675,7 +691,11 @@ otherwise. The JavaScript SDK and page (`js/`, `web/`, SDK tests) are MIT
The npm package ships a Linux kernel (GPL-2.0) with a small base system
(Alpine's static busybox, GPL-2.0, and unkernel's own tools), so it is `MIT
AND GPL-2.0-only`. The distro images it downloads hold the distributions'
AND GPL-2.0-only`. It also ships the guest GL renderer (`virgl.wasm`:
virglrenderer and Emscripten's runtime, MIT, with unkernel's glue,
GPL-2.0-or-later). [THIRD-PARTY.md](THIRD-PARTY.md), in the package and on
the page at `/licenses.md`, lists what is not unkernel's, with the notices
its licenses ask for. The distro images it downloads hold the distributions'
packages, which keep their own licenses. The
kernel's source is Linux 7.3.4 plus
[kernel/patches/linux](kernel/patches/linux) (`arch/wasm` is based on

113
THIRD-PARTY.md Normal file
View File

@@ -0,0 +1,113 @@
<!-- SPDX-License-Identifier: GPL-2.0-or-later -->
<!-- Copyright (C) 2026 Pooya Parsa <pooya@pi0.io> -->
# Third-party software
What unkernel's build outputs carry that is not unkernel's own, under which
license, and the notices those licenses ask to travel with it. The outputs
are the npm package [`unkernel`](https://www.npmjs.com/package/unkernel),
the GitHub release's assets and the page. unkernel's own code is
GPL-2.0-or-later ([LICENSE](LICENSE)), its SDK and page MIT
([LICENSE-MIT](LICENSE-MIT)); the source of everything below, and how it is
built, is at <https://github.com/pithings/unkernel>.
## The kernel bundle (`unkernel.wasm`)
- **Linux** 7.3, GPL-2.0 ([LICENSE](LICENSE) has the text). The source is
the stable tag from kernel.org plus [kernel/patches/linux](kernel/patches/linux),
whose `arch/wasm` grew from [linux-wasm](https://github.com/joelseverin/linux-wasm)
by Joel Severin.
- **BusyBox** 1.37.0, GPL-2.0: Alpine Linux's `busybox-static` package
(pinned in [guest/base/pins.sh](guest/base/pins.sh)), in the base
initramfs. Its source is at <https://busybox.net> and in Alpine's
[aports](https://gitlab.alpinelinux.org/alpine/aports/-/tree/master/main/busybox).
## The guest GL renderer (`virgl.mjs`, `virgl.wasm`)
[virglrenderer](https://gitlab.freedesktop.org/virgl/virglrenderer) 1.3.0
with [gl/patches/virglrenderer](gl/patches/virglrenderer), compiled to wasm
by [Emscripten](https://emscripten.org/) 6.0.13 with unkernel's glue
([gl/wasm](gl/wasm), GPL-2.0-or-later). The module as a whole is
distributed under GPL-2.0-or-later; the parts below keep their own licenses.
- **virglrenderer**, MIT, much of it derived from
[Mesa](https://mesa3d.org/): Copyright Red Hat, Inc., VMware, Inc.,
Collabora Ltd., Intel Corporation, Google LLC and the other virglrenderer
and Mesa authors.
- **Emscripten**'s runtime (the JavaScript glue and its WebGL bindings),
MIT: Copyright (c) 2010-2014 Emscripten authors.
- **musl** (Emscripten's libc), MIT: Copyright © 2005-2020 Rich Felker,
et al.
- **compiler-rt** (Emscripten's runtime library), Apache-2.0 WITH
LLVM-exception: Copyright the LLVM Project contributors.
Each MIT part above is under this notice:
```
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
```
virglrenderer's scatter/gather routines (`src/vrend/iov.c`) are under this one:
```
Copyright (C) 2002 Michael Ringgaard. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the project nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.
```
## The distro images
Alpine Linux and Debian images hold those distributions' packages, which
keep their own licenses (Debian's in `/usr/share/doc/*/copyright`). The
files unkernel adds are listed, with their license, in
`/usr/share/licenses/unkernel` in the guest. The Debian image also carries
`/usr/lib/kw/wlandr`, the relay of [wland](https://github.com/pithings/wland)
(MPL-2.0 AND MIT, source in that repository).
## The page
The page's build serves this file at `/licenses.md`, followed by every
package its JavaScript and CSS bundle, with the package's license text:
among them [wland](https://github.com/pithings/wland) (MPL-2.0 AND MIT;
source in that repository and its npm package),
[wterm](https://wterm.dev/) (Apache-2.0), React (MIT) and the Geist fonts
(SIL Open Font License 1.1).

View File

@@ -41,7 +41,8 @@
"files": [
"dist",
"LICENSE",
"LICENSE-MIT"
"LICENSE-MIT",
"THIRD-PARTY.md"
],
"engines": {
"node": ">=24"

View File

@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
// Copyright (C) 2026 Pooya Parsa <pooya@pi0.io>
// About: credits and the build (vite.config.ts's __KW_BUILD__: the base
// About: credits, the licenses (/licenses.md, vite.config.ts
// unkernel:licenses) and the build (vite.config.ts's __KW_BUILD__: the base
// bundle's Linux release and where it came from; the distro image, the
// store's distro). AboutInfo is Settings' About section (Settings.tsx), which
// the top bar's mark menu (TopBar.tsx) and the prefix, a (keys.ts),
@@ -46,9 +47,15 @@ export function AboutInfo() {
<Row k="distro">{distro ? <>{distro.image || distro.name}<span className="text-faint">, {distro.url}</span></> : "none (base shell)"}</Row>
<Row k="commit">{commit ? <A href={`${REPO}/commit/${B.commit}`}>{commit}</A> : "dev"}{B.date && <span className="text-faint">, {day(B.date)}</span>}</Row>
</dl>
<p className="mt-4 text-[12px] text-muted">
Built on <A href="https://kernel.org/">Linux</A>, <A href="https://github.com/joelseverin/linux-wasm">linux-wasm</A>,{" "}
<A href="https://gitlab.freedesktop.org/virgl/virglrenderer">virglrenderer</A>, <A href="https://mesa3d.org/">Mesa</A>,{" "}
<A href="https://emscripten.org/">Emscripten</A>, <A href="https://github.com/pithings/wland">wland</A>,{" "}
<A href="https://wterm.dev/">wterm</A>, <A href="https://alpinelinux.org/">Alpine</A> and <A href="https://www.debian.org/">Debian</A>.
</p>
<p className="mt-5 border-t border-line pt-3 text-[12px] text-muted">
Made with <span className="text-fg" aria-label="love">♥</span> by <A href="https://x.com/_pi0_">Pooya Parsa</A> (<A href="https://github.com/pi0">pi0</A>){" "}
<span className="text-faint">· <A href={`${REPO}#-credits`}>full credits</A></span><br />
<span className="text-faint">· <A href={`${REPO}#-credits`}>full credits</A> · <A href="/licenses.md">licenses</A></span><br />
sponsored by <A href="https://vercel.com/open-source-program"><span className="inline-flex items-center gap-1"><Triangle size={10} />Vercel</span></A>
</p>
</div>

View File

@@ -37,10 +37,15 @@
// running dev server are left alone. Build only: a dev server still takes
// wland from node_modules.
//
// /licenses.md: the repository's THIRD-PARTY.md, then each package the
// page's bundle carries with its license text (unkernel:licenses). The dev
// server answers it with THIRD-PARTY.md alone.
//
// Runtime settings (environment variables of the built Node server):
// PORT, HOST (NITRO_PORT, NITRO_HOST) where it listens (default: port 3000, all interfaces)
import { execFileSync } from "node:child_process";
import { createReadStream, readFileSync, rmSync, writeFileSync } from "node:fs";
import { createReadStream, existsSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { createRequire } from "node:module";
import { copyFile, mkdir, readFile, rm, stat, utimes, writeFile } from "node:fs/promises";
import type { IncomingMessage, ServerResponse } from "node:http";
import path from "node:path";
@@ -51,6 +56,8 @@ import { nitro } from "nitro/vite";
import { GL_FILES, baseSplit, pageSource, rescanImages, servedName, splitBase, type PageImage } from "./scripts/kernel.ts";
import { IMMUTABLE, distroReply } from "./server/range.ts";
const require = createRequire(import.meta.url);
const git = (...args: string[]) => {
try { return execFileSync("git", args, { cwd: import.meta.dirname, encoding: "utf8", stdio: ["ignore", "pipe", "ignore"] }).trim(); }
catch { return ""; }
@@ -72,6 +79,42 @@ async function buildInfo(dev: boolean) {
};
}
/** Where Vite lists the client's bundled packages (build.license), replaced by licenses.md. */
const BUNDLED_LICENSES = ".vite/license.json";
/** A package in Vite's build.license list. */
type BundledPackage = { name: string; version: string; identifier?: string; text?: string };
/**
* Packages the page carries that Vite's list misses: it follows the JS
* module graph, and src/style.css's @import of the fonts is not in it.
*/
const CSS_PACKAGES = ["@fontsource-variable/geist", "@fontsource-variable/geist-mono"];
/**
* /licenses.md: THIRD-PARTY.md (its relative links made links into the
* repository), then `bundled` and CSS_PACKAGES, each with its license text.
*/
function licenses(bundled: BundledPackage[]): string {
const repo = "https://github.com/pithings/unkernel/blob/main/"; // src/config.ts REPO
const notice = readFileSync(path.join(import.meta.dirname, "../THIRD-PARTY.md"), "utf8")
.replace(/^<!--.*-->\n/gm, "")
.replace(/\]\((?![a-z]+:)([^)]+)\)/g, (_, p: string) => `](${repo}${p})`);
if (!bundled.length) return notice; // the dev server
const all = new Map(bundled.map((p) => [p.name, p]));
for (const name of CSS_PACKAGES) {
if (all.has(name)) continue;
const dir = path.dirname(require.resolve(`${name}/package.json`));
const pkg = JSON.parse(readFileSync(path.join(dir, "package.json"), "utf8")) as { version: string; license?: string };
const file = ["LICENSE", "LICENSE.md", "OFL.txt"].map((f) => path.join(dir, f)).find((f) => existsSync(f));
if (!file) throw new Error(`[licenses] ${name} has no license file`);
all.set(name, { name, version: pkg.version, identifier: pkg.license, text: readFileSync(file, "utf8").trim() });
}
const packages = [...all.values()].sort((a, b) => a.name.localeCompare(b.name)).map((p) =>
`### ${p.name} ${p.version}${p.identifier ? ` (${p.identifier})` : ""}\n\n${p.text ? `\`\`\`\n${p.text.replaceAll("```", "'''")}\n\`\`\`` : "No license text in the package."}\n`);
return `${notice}\n## The page's packages\n\n${packages.join("\n")}`;
}
/** The build output's directories and preset (Nitro's), known once Nitro has compiled. */
let output: { dir: string; publicDir: string; preset: string } | undefined;
@@ -130,7 +173,12 @@ export default defineConfig({
// builds the client environment from index.html alone (its renderer
// template), so they are a second client environment, which it builds
// into the same public directory.
environments: { pages: { consumer: "client", build: { rollupOptions: { input: { profile: path.join(import.meta.dirname, "profile.html"), "smp-probe": path.join(import.meta.dirname, "smp-probe.html") } } } } },
// The page's bundled packages, as JSON for unkernel:licenses (client only:
// the pages' bundles are a part of it).
environments: {
client: { build: { license: { fileName: BUNDLED_LICENSES } } },
pages: { consumer: "client", build: { rollupOptions: { input: { profile: path.join(import.meta.dirname, "profile.html"), "smp-probe": path.join(import.meta.dirname, "smp-probe.html") } } } },
},
// The SDK's worker mode (?worker=1): js/web/worker.ts starts a module worker.
worker: { format: "es" },
plugins: [
@@ -247,6 +295,29 @@ export default defineConfig({
});
},
},
{
// /licenses.md (licenses() below): the dev server's, and a build's
// in place of Vite's JSON list of the client's bundled packages.
name: "unkernel:licenses",
configureServer(server) {
server.middlewares.use((req, res, next) => {
if ((req.url ?? "").split("?")[0] !== "/licenses.md") return next();
res.setHeader("content-type", "text/markdown; charset=utf-8");
res.setHeader("cache-control", "no-cache");
res.end(licenses([]));
});
},
generateBundle: {
order: "post", // after vite:license
handler(_, bundle) {
if (this.environment.name !== "client") return;
const list = bundle[BUNDLED_LICENSES];
if (list?.type !== "asset") throw new Error(`[licenses] Vite gave no ${BUNDLED_LICENSES}`);
delete bundle[BUNDLED_LICENSES];
this.emitFile({ type: "asset", fileName: "licenses.md", source: licenses(JSON.parse(String(list.source)) as BundledPackage[]) });
},
},
},
...(wlandPkg ? [wlandPkgPlugin(wlandPkg)] : []),
react(),
tailwindcss(),