From ef85c2809cb0063cae077f729806ca6f5b5d1090 Mon Sep 17 00:00:00 2001 From: diviocity Date: Sun, 29 Nov 2026 23:14:43 +0100 Subject: [PATCH] Bootstrap a signed SDK and inventory release package origins --- README.md | 64 ++++++++++++++++++++++++++---------- tools/release-closure.v | 73 +++++++++++++++++++++++++++++++++++++++++ tools/vinix-cc.v | 25 ++++++++++++++ 3 files changed, 145 insertions(+), 17 deletions(-) create mode 100644 tools/release-closure.v create mode 100644 tools/vinix-cc.v diff --git a/README.md b/README.md index 4adda70..227dbc5 100644 --- a/README.md +++ b/README.md @@ -1,32 +1,62 @@ # Vinix ports -Each port contains a native vpac recipe and its local build inputs. The first -port, `busybox/`, builds BusyBox 1.38.0 from upstream source for x86-64. Its -static musl executable provides the shell, init, and basic commands in the -bootstrap root. The package owns the applet symlinks. +Each port contains a native vpac recipe and its local build inputs. The +bootstrap packages build Vinix's patched musl and a static BusyBox. BusyBox +owns the shell, init and applet symlinks. See [the release profiles](PROFILES.md) +for the Alpine components that need Vinix equivalents on each architecture. -## Build BusyBox +To reproduce the v3.21 input inventory for either release, compile the +inventory tool against the same `alpinecore` module used by the image builder. +Supply the unpacked main and community APKINDEX files for that architecture: + +```sh +v -path "$vinix_checkout/build-support|@vlib|@vmodules" -o /tmp/release-closure tools/release-closure.v +/tmp/release-closure x86_64 profiles.tsv "$main_index" "$community_index" > "$state/release-closure.tsv" +``` + +The output identifies the source origin for each split binary package and +the profiles that require it. The pinned older graphics stack is listed in +`PROFILES.md`. The native recipes declare additional build-time dependencies. + +## Bootstrap a build root Use an ordinary user on x86-64 Linux with vpac's native Vile builder. The tested vpac revision is `e7147c7fac0dc130fe03c7accf07c75a88188d3d`. -The builder needs GNU Make, a host C compiler, musl-gcc with static libc, -Linux userspace headers, binutils, coreutils, sed, curl and bsdtar with -bzip2 and zstd support. BusyBox's upstream Makefiles also use the host shell. +The first stages need GNU Make, GCC, binutils, patch, coreutils, sed, curl and +bsdtar with bzip2 and zstd support. BusyBox's upstream Makefiles use the host +shell and its bootstrap configuration uses Linux userspace headers. The test +feed utility uses V, GnuPG, repo-add and unprivileged Linux user namespaces. -From the root of this checkout, build in a scratch directory: +From the root of this checkout, build musl, install it into an empty SDK +through vpac and compile BusyBox against that SDK: ```sh work=$(mktemp -d) -cp -R busybox "$work/" -MAKEFLAGS=-j1 vpac --native-build "$work/busybox/PKGBUILD.vile" "$work/archives.txt" -cat "$work/archives.txt" +cp -R musl busybox "$work/" +export MAKEFLAGS=-j1 +v -o "$work/feed" tests/feed.v +v -o "$work/vinix-cc" tools/vinix-cc.v +export PATH="$work:$PATH" +vpac --native-build "$work/musl/PKGBUILD.vile" "$work/musl.txt" +"$work/feed" keys "$work/test-keys" +"$work/feed" publish "$work/test-keys" "$work/first-repo" x86_64 "$(cat "$work/musl.txt")" +"$work/feed" install "$work/test-keys" "$work/first-repo" x86_64 "$work/sdk" musl +export VPAC_MAKEPKG_ROOT="$work/sdk/root" +export VPAC_MAKEPKG_DB="$work/sdk/db" +export VINIX_SYSROOT="$VPAC_MAKEPKG_ROOT" +vpac --native-build "$work/busybox/PKGBUILD.vile" "$work/busybox.txt" ``` -The manifest contains the path to the completed `.pkg.tar.zst` archive. The -builder verifies both source checksums, executes the recipe, and packages -the files as owned by root. The command leaves the host package database alone. -To sign during the build, select the builder's signing keyring with -`GNUPGHOME` and append `--sign`. +The manifests contain the paths to the completed archives. Musl includes its +headers, startup objects, shared loader and static library. The BusyBox recipe +checks the final linker map and header dependencies against the installed SDK. +To install both packages by name into a new root, publish a new test feed: + +```sh +"$work/feed" publish "$work/test-keys" "$work/repo" x86_64 "$(cat "$work/musl.txt")" "$(cat "$work/busybox.txt")" +"$work/feed" install "$work/test-keys" "$work/repo" x86_64 "$work/client" musl busybox +installed_root="$work/client/root" +``` ## Verify on Vinix diff --git a/tools/release-closure.v b/tools/release-closure.v new file mode 100644 index 0000000..b997e90 --- /dev/null +++ b/tools/release-closure.v @@ -0,0 +1,73 @@ +module main + +import alpinecore +import os + +// Resolve exactly as the Vinix release builder does, including its provider +// preferences. APK's origin field identifies split packages built from a +// single source. Source build dependencies come from the native recipes. +fn release_inputs(arch string, profile_file string, indexes []string) ! { + if arch !in ['x86_64', 'aarch64'] { + return error('unknown Vinix release architecture: ${arch}') + } + mut profiles := map[string][]string{} + for line in os.read_lines(profile_file)! { + if line == 'arch\tprofile\troot' || line.trim_space() == '' { + continue + } + fields := line.split('\t') + if fields.len != 3 || fields[0] !in ['both', 'x86_64', 'aarch64'] { + return error('invalid profile row: ${line}') + } + if fields[0] in ['both', arch] { + profiles[fields[1]] << fields[2] + } + } + mut packages := []alpinecore.Package{} + mut origins := map[string]string{} + for i, path in indexes { + body := os.read_file(path)! + repository := ['main', 'community'][i] + packages << alpinecore.parse_text(body, repository)! + for record in body.split('\n\n') { + mut name := '' + mut origin := '' + for field in record.split_into_lines() { + if field.starts_with('P:') { + name = field[2..] + } else if field.starts_with('o:') { + origin = field[2..] + } + } + if name != '' && name !in origins { + origins[name] = if origin == '' { name } else { origin } + } + } + } + mut names := profiles.keys() + names.sort() + mut applies := map[string][]string{} + mut roots := []string{} + for profile in names { + roots << profiles[profile] + for pkg in alpinecore.resolve(packages, profiles[profile])! { + applies[pkg.name] << profile + } + } + println('arch\tbinary\tversion\tsource\trepository\tprofiles') + for pkg in alpinecore.resolve(packages, roots)! { + println([arch, pkg.name, pkg.version, origins[pkg.name], pkg.repository, + applies[pkg.name].join(',')].join('\t')) + } +} + +fn main() { + if os.args.len != 5 { + eprintln('usage: release-closure ARCH PROFILES.tsv MAIN-APKINDEX COMMUNITY-APKINDEX') + exit(2) + } + release_inputs(os.args[1], os.args[2], os.args[3..]) or { + eprintln(err) + exit(1) + } +} diff --git a/tools/vinix-cc.v b/tools/vinix-cc.v new file mode 100644 index 0000000..1081bfd --- /dev/null +++ b/tools/vinix-cc.v @@ -0,0 +1,25 @@ +// A single compiler name for build systems such as libtool that independently +// expand CC and its arguments. Repeating musl's specs option makes GCC fail. +module main + +import os + +fn main() { + root := os.getenv('VPAC_MAKEPKG_ROOT') + if !os.is_abs_path(root) { + eprintln('vinix-cc requires an absolute VPAC_MAKEPKG_ROOT') + exit(1) + } + specs := os.join_path(root, 'usr/lib/musl-gcc-sysroot.specs') + if !os.is_file(specs) { + eprintln('vinix-cc: missing installed musl specs at ${specs}') + exit(1) + } + compiler := os.getenv_opt('VINIX_REAL_CC') or { 'gcc' } + mut args := ['--sysroot=${root}', '-specs=${specs}'] + args << os.args[1..] + os.execvp(compiler, args) or { + eprintln('vinix-cc: ${compiler}: ${err}') + exit(1) + } +} -- 2.56.1