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, installed 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] { if installed != '' && fields[1] == 'minirootfs' { continue } 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])! { // X11 explicitly fetches the named payloads. Its transitive APK // requirements are candidates for a source build and ELF audit. if installed != '' && profile == 'x11-sidecar' && pkg.name !in profiles[profile] { applies[pkg.name] << 'x11-index-dependency' } else { 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')) } if installed == '' { return } // The release unpacks a checksum-pinned tarball before overlaying packages // from the live branch. Preserve both versions when an overlay updates a file. mut seen := map[string]bool{} for record in os.read_file(installed)!.trim_space().split('\n\n') { mut fields := map[string]string{} for line in record.split_into_lines() { if line.len > 2 && line[1] == `:` && line[0] in [`P`, `V`, `A`, `o`] { fields[line[..1]] = line[2..] } } name := fields['P'] if name == '' || fields['V'] == '' || name in seen || fields['A'] !in [arch, 'noarch'] { return error('invalid or duplicate installed package in ${installed}: ${name}') } seen[name] = true println([arch, name, fields['V'], fields['o'] or { name }, 'minirootfs', 'minirootfs'].join('\t')) } if 'musl' !in seen || 'busybox' !in seen { return error('missing bootstrap packages in ${installed}') } for name in ['mesa-dri-gallium', 'mesa-gl', 'mesa-glapi', 'llvm17-libs'] { llvm := name == 'llvm17-libs' version := if llvm { '17.0.6-r2' } else { '24.0.9-r1' } origin := if llvm { 'llvm17' } else { 'mesa' } println([arch, name, version, origin, 'v3.20/main', 'x11-legacy-glx'].join('\t')) } } fn main() { if os.args.len !in [5, 6] { eprintln('usage: release-closure ARCH PROFILES.tsv MAIN-APKINDEX COMMUNITY-APKINDEX [MINIROOTFS-INSTALLED]') exit(2) } installed := if os.args.len == 6 { os.args[5] } else { '' } release_inputs(os.args[1], os.args[2], os.args[3..5], installed) or { eprintln(err) exit(1) } }