me

/

vinix-ports Public
382 commits 0 issues 0 pull requests 1 contributor Discussions Projects Snippets LOC history Platform CI

Bootstrap a signed SDK and inventory release package origins

diviocity committed 6 days ago · ef85c2809cb0063cae077f729806ca6f5b5d1090 View patch
Unverified signature 3 files changed +145 -17
README.md +47 -17

@@ -1,32 +1,62 @@

11# Vinix ports

22

3-Each port contains a native vpac recipe and its local build inputs. The first

4-port, `busybox/`, builds BusyBox 1.38.0 from upstream source for x86-64. Its

5-static musl executable provides the shell, init, and basic commands in the

6-bootstrap root. The package owns the applet symlinks.

3+Each port contains a native vpac recipe and its local build inputs. The

4+bootstrap packages build Vinix's patched musl and a static BusyBox. BusyBox

5+owns the shell, init and applet symlinks. See [the release profiles](PROFILES.md)

6+for the Alpine components that need Vinix equivalents on each architecture.

77

8-## Build BusyBox

8+To reproduce the v3.21 input inventory for either release, compile the

9+inventory tool against the same `alpinecore` module used by the image builder.

10+Supply the unpacked main and community APKINDEX files for that architecture:

11+

12+```sh

13+v -path "$vinix_checkout/build-support|@vlib|@vmodules" -o /tmp/release-closure tools/release-closure.v

14+/tmp/release-closure x86_64 profiles.tsv "$main_index" "$community_index" > "$state/release-closure.tsv"

15+```

16+

17+The output identifies the source origin for each split binary package and

18+the profiles that require it. The pinned older graphics stack is listed in

19+`PROFILES.md`. The native recipes declare additional build-time dependencies.

20+

21+## Bootstrap a build root

922

1023Use an ordinary user on x86-64 Linux with vpac's native Vile builder. The

1124tested vpac revision is `e7147c7fac0dc130fe03c7accf07c75a88188d3d`.

12-The builder needs GNU Make, a host C compiler, musl-gcc with static libc,

13-Linux userspace headers, binutils, coreutils, sed, curl and bsdtar with

14-bzip2 and zstd support. BusyBox's upstream Makefiles also use the host shell.

25+The first stages need GNU Make, GCC, binutils, patch, coreutils, sed, curl and

26+bsdtar with bzip2 and zstd support. BusyBox's upstream Makefiles use the host

27+shell and its bootstrap configuration uses Linux userspace headers. The test

28+feed utility uses V, GnuPG, repo-add and unprivileged Linux user namespaces.

1529

16-From the root of this checkout, build in a scratch directory:

30+From the root of this checkout, build musl, install it into an empty SDK

31+through vpac and compile BusyBox against that SDK:

1732

1833```sh

1934work=$(mktemp -d)

20-cp -R busybox "$work/"

21-MAKEFLAGS=-j1 vpac --native-build "$work/busybox/PKGBUILD.vile" "$work/archives.txt"

22-cat "$work/archives.txt"

35+cp -R musl busybox "$work/"

36+export MAKEFLAGS=-j1

37+v -o "$work/feed" tests/feed.v

38+v -o "$work/vinix-cc" tools/vinix-cc.v

39+export PATH="$work:$PATH"

40+vpac --native-build "$work/musl/PKGBUILD.vile" "$work/musl.txt"

41+"$work/feed" keys "$work/test-keys"

42+"$work/feed" publish "$work/test-keys" "$work/first-repo" x86_64 "$(cat "$work/musl.txt")"

43+"$work/feed" install "$work/test-keys" "$work/first-repo" x86_64 "$work/sdk" musl

44+export VPAC_MAKEPKG_ROOT="$work/sdk/root"

45+export VPAC_MAKEPKG_DB="$work/sdk/db"

46+export VINIX_SYSROOT="$VPAC_MAKEPKG_ROOT"

47+vpac --native-build "$work/busybox/PKGBUILD.vile" "$work/busybox.txt"

2348```

2449

25-The manifest contains the path to the completed `.pkg.tar.zst` archive. The

26-builder verifies both source checksums, executes the recipe, and packages

27-the files as owned by root. The command leaves the host package database alone.

28-To sign during the build, select the builder's signing keyring with

29-`GNUPGHOME` and append `--sign`.

50+The manifests contain the paths to the completed archives. Musl includes its

51+headers, startup objects, shared loader and static library. The BusyBox recipe

52+checks the final linker map and header dependencies against the installed SDK.

53+To install both packages by name into a new root, publish a new test feed:

54+

55+```sh

56+"$work/feed" publish "$work/test-keys" "$work/repo" x86_64 "$(cat "$work/musl.txt")" "$(cat "$work/busybox.txt")"

57+"$work/feed" install "$work/test-keys" "$work/repo" x86_64 "$work/client" musl busybox

58+installed_root="$work/client/root"

59+```

3060

3161## Verify on Vinix

3262

tools/release-closure.v new file +73 -0

@@ -0,0 +1,73 @@

1+module main

2+

3+import alpinecore

4+import os

5+

6+// Resolve exactly as the Vinix release builder does, including its provider

7+// preferences. APK's origin field identifies split packages built from a

8+// single source. Source build dependencies come from the native recipes.

9+fn release_inputs(arch string, profile_file string, indexes []string) ! {

10+ if arch !in ['x86_64', 'aarch64'] {

11+ return error('unknown Vinix release architecture: ${arch}')

12+ }

13+ mut profiles := map[string][]string{}

14+ for line in os.read_lines(profile_file)! {

15+ if line == 'arch\tprofile\troot' || line.trim_space() == '' {

16+ continue

17+ }

18+ fields := line.split('\t')

19+ if fields.len != 3 || fields[0] !in ['both', 'x86_64', 'aarch64'] {

20+ return error('invalid profile row: ${line}')

21+ }

22+ if fields[0] in ['both', arch] {

23+ profiles[fields[1]] << fields[2]

24+ }

25+ }

26+ mut packages := []alpinecore.Package{}

27+ mut origins := map[string]string{}

28+ for i, path in indexes {

29+ body := os.read_file(path)!

30+ repository := ['main', 'community'][i]

31+ packages << alpinecore.parse_text(body, repository)!

32+ for record in body.split('\n\n') {

33+ mut name := ''

34+ mut origin := ''

35+ for field in record.split_into_lines() {

36+ if field.starts_with('P:') {

37+ name = field[2..]

38+ } else if field.starts_with('o:') {

39+ origin = field[2..]

40+ }

41+ }

42+ if name != '' && name !in origins {

43+ origins[name] = if origin == '' { name } else { origin }

44+ }

45+ }

46+ }

47+ mut names := profiles.keys()

48+ names.sort()

49+ mut applies := map[string][]string{}

50+ mut roots := []string{}

51+ for profile in names {

52+ roots << profiles[profile]

53+ for pkg in alpinecore.resolve(packages, profiles[profile])! {

54+ applies[pkg.name] << profile

55+ }

56+ }

57+ println('arch\tbinary\tversion\tsource\trepository\tprofiles')

58+ for pkg in alpinecore.resolve(packages, roots)! {

59+ println([arch, pkg.name, pkg.version, origins[pkg.name], pkg.repository,

60+ applies[pkg.name].join(',')].join('\t'))

61+ }

62+}

63+

64+fn main() {

65+ if os.args.len != 5 {

66+ eprintln('usage: release-closure ARCH PROFILES.tsv MAIN-APKINDEX COMMUNITY-APKINDEX')

67+ exit(2)

68+ }

69+ release_inputs(os.args[1], os.args[2], os.args[3..]) or {

70+ eprintln(err)

71+ exit(1)

72+ }

73+}

tools/vinix-cc.v new file +25 -0

@@ -0,0 +1,25 @@

1+// A single compiler name for build systems such as libtool that independently

2+// expand CC and its arguments. Repeating musl's specs option makes GCC fail.

3+module main

4+

5+import os

6+

7+fn main() {

8+ root := os.getenv('VPAC_MAKEPKG_ROOT')

9+ if !os.is_abs_path(root) {

10+ eprintln('vinix-cc requires an absolute VPAC_MAKEPKG_ROOT')

11+ exit(1)

12+ }

13+ specs := os.join_path(root, 'usr/lib/musl-gcc-sysroot.specs')

14+ if !os.is_file(specs) {

15+ eprintln('vinix-cc: missing installed musl specs at ${specs}')

16+ exit(1)

17+ }

18+ compiler := os.getenv_opt('VINIX_REAL_CC') or { 'gcc' }

19+ mut args := ['--sysroot=${root}', '-specs=${specs}']

20+ args << os.args[1..]

21+ os.execvp(compiler, args) or {

22+ eprintln('vinix-cc: ${compiler}: ${err}')

23+ exit(1)

24+ }

25+}