// Compare the published X11 sidecar with the exact Mesa release packages. // Keep extracted ELF files, readelf output and checksums outside the checkout. module main import os fn command(args []string) !string { result := os.exec(args) if result.exit_code != 0 { return error('${args}: ${result.output}') } return result.output } fn extract(archive string, members []string, destination string) ! { os.mkdir_all(destination)! mut args := ['tar', '--ignore-zeros', '-xf', archive, '-C', destination] args << members command(args)! } fn elf(path string, name string, receipt string) !string { head := command(['readelf', '-h', path])! dynamic := command(['readelf', '-d', path])! os.write_file(os.join_path(receipt, name + '.readelf'), head + '\n' + dynamic)! return dynamic } fn checksum(path string) !string { return command(['sha256sum', path])!.all_before(' ') } fn architecture(release string, refs string, out string, image string, arch string) ! { os.mkdir(out)! mut inventory := []string{} mut digests := []string{} for list in ['iso.files', 'initramfs.files', 'x11.files'] { file := os.join_path(release, image, list) digests << '${checksum(file)!} ${image}/${list}' paths := os.read_lines(file)! for path in paths { name := os.base(path) if name.starts_with('libgallium') || name.starts_with('libLLVM') || path.contains('vinix-x11-software') || name.contains('ld-musl') && name.ends_with('.path') { inventory << '${list}\t${path}' } if name in ['libgallium-24.2.8.so', 'libLLVM.so.19.1', 'libLLVM-19.so'] { return error('found ${name} in ${image}/${list} at ${path}; reassess this release') } } } os.write_file(os.join_path(out, 'search-path-inventory.tsv'), inventory.join('\n') + '\n')! side := os.join_path(release, 'vinix-x11-${image}.tar.gz') digests << '${checksum(side)!} ${os.file_name(side)}' content := os.join_path(out, 'sidecar') lib := 'usr/lib/' dri := lib + 'xorg/modules/dri/' extract(side, ['./' + lib + 'libEGL.so.1.0.0', './' + lib + 'libgbm.so.1.0.0', './' + dri], content)! for kind, file in {'egl': 'libEGL.so.1.0.0', 'gbm': 'libgbm.so.1.0.0'} { apk := os.join_path(refs, 'v3.21/main', arch, 'mesa-${kind}-24.2.8-r0.apk') sub := os.join_path(out, kind) extract(apk, [lib + file], sub)! published := os.join_path(content, lib, file) hash := checksum(published)! if hash != checksum(os.join_path(sub, lib, file))! { return error('${image} ${file} differs from ${os.file_name(apk)}') } digests << '${hash} sidecar/${lib}${file}' digests << '${checksum(apk)!} ${os.file_name(apk)}' if !elf(published, kind, out)!.contains('Shared library: [libgallium-24.2.8.so]') { return error('${image} ${file} lacks the expected current Gallium dependency') } } current := os.join_path(refs, 'v3.21/main', arch, 'mesa-24.2.8-r0.apk') original := os.join_path(out, 'current') extract(current, [lib + 'libgallium-24.2.8.so'], original)! current_file := os.join_path(original, lib, 'libgallium-24.2.8.so') if !elf(current_file, 'current-gallium', out)!.contains('Shared library: [libLLVM.so.19.1]') { return error('current Gallium does not request LLVM19 on ${arch}') } legacy := os.join_path(refs, 'v3.20/main', arch, 'mesa-dri-gallium-24.0.9-r1.apk') older := os.join_path(out, 'legacy') extract(legacy, [dri.trim_right('/')], older)! installed := os.join_path(content, dri, 'libgallium_dri.so') hash := checksum(installed)! if hash != checksum(os.join_path(older, dri, 'libgallium_dri.so'))! || !elf(installed, 'legacy-gallium', out)!.contains('Shared library: [libLLVM-17.so]') { return error('published Gallium differs from the LLVM17-backed DRI runtime on ${image}') } digests << '${hash} sidecar/${dri}libgallium_dri.so' digests << '${checksum(current_file)!} current/${lib}libgallium-24.2.8.so' digests << '${checksum(current)!} ${os.file_name(current)}' digests << '${checksum(legacy)!} ${os.file_name(legacy)}' os.write_file(os.join_path(out, 'SHA256SUMS'), digests.join('\n') + '\n')! println('${image}: published EGL/GBM require missing Mesa 24.2.8 Gallium + LLVM19; installed Mesa 24.0.9 DRI requires LLVM17.') } fn main() { if os.args.len != 4 { eprintln('usage: release-elf RELEASE_ASSETS_DIR REFERENCE_APK_DIR NEW_OUTPUT_DIR') exit(2) } release := os.abs_path(os.args[1]) refs := os.abs_path(os.args[2]) out := os.abs_path(os.args[3]) os.mkdir(out) or { panic(err) } for image, arch in {'amd64': 'x86_64', 'arm64': 'aarch64'} { architecture(release, refs, os.join_path(out, image), image, arch) or { panic(err) } } }