Package workstation tools, reuse emulator sessions, and derive build versions

This commit is contained in:
2026-09-23 03:45:48 +08:00
parent 6bfcce8070
commit f5d9f96409
79 changed files with 878 additions and 132 deletions
+5 -3
View File
@@ -12,11 +12,12 @@ import stat
import subprocess
import sys
import tomllib
from fds_version import version, validate
project = Path(__file__).resolve().parents[1]
OWNED = ('.cargo', '.gitignore', '.gitmodules', 'AGENTS.md', 'Cargo.lock',
'Cargo.toml', 'LICENSE', 'Makefile', 'README.md', 'VOID_PACKAGES_COMMIT',
'config', 'docs', 'image', 'packages', 'profiles', 'rust-toolchain.toml',
'config', 'docs', 'examples', 'image', 'packaging', 'packages', 'profiles', 'rust-toolchain.toml',
'rust', 's6', 'tests', 'tools')
@@ -119,6 +120,7 @@ def create(destination):
new_directory(destination)
for name in OWNED:
copy(project / name, destination / 'project' / name)
(destination / 'project/FDS_VERSION').write_text(version(project) + '\n')
run('git', '-C', void, 'bundle', 'create', destination / 'void.bundle', 'HEAD')
# Bundles carry commit objects, but do not retain a shallow checkout's
# boundary file. Without it, history-aware commands follow missing parents.
@@ -205,7 +207,7 @@ def create(destination):
('tar', ['tar', '--version']), ('rustup', ['rustup', '--version'])]:
host[name] = subprocess.check_output(command, text=True, stderr=subprocess.DEVNULL).splitlines()[0]
files = inventory(destination)
lock = {'format': 1, 'version': '0.1.0', 'void_commit': pin, 'source_epoch': epoch,
lock = {'format': 1, 'version': version(project), 'void_commit': pin, 'source_epoch': epoch,
'source_sha256': source_digest(files), 'rust_toolchain': toolchain_version,
'host_prerequisites': host, 'files': files}
(destination / 'lock.json').write_text(json.dumps(lock, indent=2) + '\n')
@@ -219,7 +221,7 @@ def verify(directory):
if lockfile.is_symlink() or not lockfile.is_file() or lockfile.stat().st_size > 64 * 1024 * 1024:
raise ValueError('Missing or invalid frozen input lock')
lock = json.loads(lockfile.read_text())
if lock.get('format') != 1 or lock.get('version') != '0.1.0':
if lock.get('format') != 1 or not validate(lock.get('version')):
raise ValueError('Unsupported frozen input format')
if (set(lock) != {'format', 'version', 'void_commit', 'source_epoch', 'source_sha256',
'rust_toolchain', 'host_prerequisites', 'files'}