The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
Avoid copying matching Broadcom archives during OS installation (#777)
Deeb140e30da52c
diff --git a/.github/workflows/os.yml b/.github/workflows/os.ymlindex f0cc7a9ca..bd0bba91d 100644--- a/.github/workflows/os.yml+++ b/.github/workflows/os.yml@@ -267,7 +267,7 @@ jobs:run: |args=(--iso os/dist/*.iso)if [[ -n "$REUSED_IMAGE" ]]; then- args+=(--candidate-hardware os/hardware.py)+ args+=(--candidate-hardware os/hardware.py --candidate-installer os/installer.py)fipython3 os/tests/hardware_install_vm.py "${args[@]}"- name: Retain hardware installation and rebuild evidencediff --git a/os/DEVELOPMENT.md b/os/DEVELOPMENT.mdindex 82383ae1d..7c477cce7 100644--- a/os/DEVELOPMENT.md+++ b/os/DEVELOPMENT.md@@ -640,7 +640,12 @@ blacklist is overridden so it cannot disable those other drivers.The live driver is about 2 MB. A separate signed package cache is kept on theUSB for offline installation; its compiler, DKMS and matching LTS headers areinstalled only when the radio needs them. The cache is removed from every-installed system. The standard package hooks then rebuild wl on kernel updates.+installed system. When the USB cache matches the selected image, the installer+omits its archives from extraction and selected radios use a read-only bind mount.+The image's manifest and module are retained for comparison; full archive hashes+and package signatures are checked before use. An explicit image override with+different or unavailable live files retains its own cache during installation.+The standard package hooks then rebuild wl on kernel updates.The driver bundle is built in a disposable root using the same complete Archsnapshot as the image; none of its build packages enter the normal image base.This selection happens during a fresh installation. Updating an older installeddiff --git a/os/hardware.py b/os/hardware.pyindex 5efbb6915..52c26cb54 100644--- a/os/hardware.py+++ b/os/hardware.py@@ -242,7 +242,7 @@ def activate(address, sysfs=Path('/sys'), bundle=BUNDLE):raise-def configure_install(target, devices=None):+def configure_install(target, devices=None, bundle=BUNDLE):target = target.resolve()# Only the offline installer's mounted, still-marked image may use this path.# It must never install a compiler into the running live overlay by mistake.@@ -253,7 +253,13 @@ def configure_install(target, devices=None):folder = target / BUNDLE.relative_to('/')result = {'drivers': [], 'devices': [d['id'] for d in selected]}if selected:- manifest = bundle_manifest(folder, all_files=True)+ manifest = bundle_manifest(folder)+ cache = folder+ if not (folder / 'packages').exists():+ if bundle_manifest(bundle) != manifest:+ raise ValueError('Live Wi-Fi cache and installation image differ.')+ cache = bundle+ manifest = bundle_manifest(cache, all_files=True)lock = json.loads((target / 'usr/share/harness-os/lock.json').read_text())if manifest['arch_snapshot'] != lock['arch_snapshot']:raise ValueError('Wi-Fi bundle and installed package snapshot differ.')@@ -270,11 +276,19 @@ def configure_install(target, devices=None):# No repositories: this operation either succeeds from signed local# packages or fails. It cannot quietly turn into an online installation.with tempfile.TemporaryDirectory(prefix='harness-driver-', dir=target / 'var/tmp') as temporary:+ packages = Path(temporary) / 'packages'+ packages.mkdir()config = Path(temporary) / 'pacman.conf'config.write_text('[options]\nArchitecture = auto\nCheckSpace\nSigLevel = Required\nLocalFileSigLevel = Required\n')config.chmod(0o600)- run('arch-chroot', target, 'pacman', '--config', '/' + str(config.relative_to(target)),- '-U', '--needed', '--noconfirm', *[str(BUNDLE / 'packages' / name) for name in names], timeout=600)+ run('mount', '--bind', cache / 'packages', packages)+ try:+ run('mount', '-o', 'remount,bind,ro', packages)+ prefix = '/' + str(packages.relative_to(target))+ run('arch-chroot', target, 'pacman', '--config', '/' + str(config.relative_to(target)),+ '-U', '--needed', '--noconfirm', *[prefix + '/' + name for name in names], timeout=600)+ finally:+ run('umount', packages)run('arch-chroot', target, 'modinfo', '-k', manifest['kernel'], 'wl', capture=True)result.update(drivers=['broadcom-wl-dkms'], kernel=manifest['kernel'], packages=manifest['packages'])# The USB keeps the offline cache; the installed computer does not. Unrelateddiff --git a/os/installer.py b/os/installer.pyindex 8b8e4587d..aa6e7245c 100644--- a/os/installer.py+++ b/os/installer.py@@ -280,11 +280,38 @@ def preserve_trial(trial, target, home):return {key: value for key, value in receipt.items() if key != 'entries'}-def copy_image(source, target):- # Bound extraction memory and skip the optional GPU archive cache entirely.- # Selected hardware reads its signed packages directly from the live USB.- run('unsquashfs', '-mem', '64M', '-f', '-no-progress', '-excludes', '-d', target, source,- 'usr/share/harness-os/hardware/nvidia')+def shared_broadcom_cache(source, bundle):+ """Use the live cache only when it belongs to this exact selected payload."""+ try:+ manifest = json.loads((bundle / 'manifest.json').read_text())+ embedded = json.loads(run('unsquashfs', '-cat', source,+ 'usr/share/harness-os/hardware/broadcom/manifest.json', capture=True))+ if (not isinstance(manifest, dict) or manifest != embedded or not manifest.get('packages') or+ not isinstance(manifest.get('files'), dict) or not manifest['files'] or+ not (bundle / 'packages').is_dir()):+ return False+ # Avoid reading the entire archive cache on generic machines. Selected+ # radios still verify every hash and signature before pacman sees it.+ for name, expected in manifest['files'].items():+ path = bundle / name+ if (Path(name).is_absolute() or '..' in Path(name).parts or+ path.is_symlink() or not path.resolve().is_relative_to(bundle.resolve()) or+ not path.is_file() or path.stat().st_size != expected['bytes']):+ return False+ return True+ except (OSError, ValueError, KeyError, TypeError, subprocess.SubprocessError):+ # An explicit --source can differ from the running USB. Keep its own+ # cache instead of requiring matching live files for that installation.+ return False+++def copy_image(source, target, broadcom=Path('/usr/share/harness-os/hardware/broadcom')):+ # Bound extraction memory. Keep the Wi-Fi module/manifest from the selected+ # image; selected radios can read its matching signed archives from the USB.+ excluded = ['usr/share/harness-os/hardware/nvidia']+ if shared_broadcom_cache(source, broadcom):+ excluded.append('usr/share/harness-os/hardware/broadcom/packages')+ run('unsquashfs', '-mem', '64M', '-f', '-no-progress', '-excludes', '-d', target, source, *excluded)def install(config, source, target, progress=None):diff --git a/os/tests/hardware_install_guest.py b/os/tests/hardware_install_guest.pyindex f71a0978e..1dac0bce7 100644--- a/os/tests/hardware_install_guest.py+++ b/os/tests/hardware_install_guest.py@@ -27,7 +27,7 @@ def apply_candidate(source, destination, expected):data = source.read_bytes()actual = hashlib.sha256(data).hexdigest()if actual != expected:- raise ValueError('Candidate hardware policy checksum mismatch.')+ raise ValueError('Candidate OS file checksum mismatch.')destination.write_bytes(data)destination.chmod(0o755)return actual@@ -71,21 +71,63 @@ def assigned_devices(hardware, sysfs):return devices+def check_cache_extraction(installer, hardware):+ """Compare actual SquashFS extraction, without extrapolating timing savings."""+ with tempfile.TemporaryDirectory(prefix='harness-cache-', dir='/run') as directory:+ root = Path(directory)+ source = root / 'source'+ bundle = source / hardware.BUNDLE.relative_to('/')+ (bundle / 'packages').mkdir(parents=True)+ archive = bundle / 'packages/fixture.pkg.tar.zst'+ archive.write_bytes(bytes(range(256)) * 256)+ module = bundle / 'wl.ko'+ module.write_bytes(b'preserved module')+ manifest = {'packages': {archive.name: {}}, 'files': {+ str(path.relative_to(bundle)): {'bytes': path.stat().st_size, 'sha256': hardware.digest(path)}+ for path in [archive, module]}}+ (bundle / 'manifest.json').write_text(json.dumps(manifest))+ (bundle.parent / 'preserved').write_text('other hardware')+ (source / 'ordinary').write_text('ordinary file')+ image = root / 'fixture.sfs'+ hardware.run('mksquashfs', source, image, '-noappend', '-no-progress', '-processors', '1')+ baseline, candidate = root / 'baseline', root / 'candidate'+ installer.copy_image(image, baseline, broadcom=root / 'unavailable-cache')+ installer.copy_image(image, candidate, broadcom=bundle)+ for path in [module, bundle / 'manifest.json', bundle.parent / 'preserved', source / 'ordinary']:+ assert (baseline / path.relative_to(source)).read_bytes() == path.read_bytes()+ assert (candidate / path.relative_to(source)).read_bytes() == path.read_bytes()+ assert (baseline / archive.relative_to(source)).read_bytes() == archive.read_bytes()+ assert not (candidate / bundle.relative_to(source) / 'packages').exists()+ size = lambda folder: sum(path.stat().st_size for path in folder.rglob('*') if path.is_file())+ before, after = size(baseline), size(candidate)+ assert before - after == archive.stat().st_size+ return {'baseline_extracted_bytes': before, 'candidate_extracted_bytes': after,+ 'archive_bytes_omitted': before - after, 'adjacent_files_preserved': True}++def main():parser = argparse.ArgumentParser(description=__doc__)parser.add_argument('--candidate-hardware', type=Path)parser.add_argument('--candidate-sha256')+ parser.add_argument('--candidate-installer', type=Path)+ parser.add_argument('--installer-sha256')options = parser.parse_args()if bool(options.candidate_hardware) != bool(options.candidate_sha256):parser.error('The candidate and its checksum must be supplied together.')+ if bool(options.candidate_installer) != bool(options.installer_sha256):+ parser.error('The installer candidate and its checksum must be supplied together.')assert os.geteuid() == 0 and Path('/etc/harness-live').is_file(), 'Disposable live guest only'assert subprocess.check_output(['lsblk', '-ndo', 'SERIAL', '/dev/vda'], text=True).strip() == 'HN_OS_TEST'hardware_path = Path('/usr/lib/harness-os/hardware.py')+ installer_path = Path('/usr/lib/harness-os/install.py')original_hash = hashlib.sha256(hardware_path.read_bytes()).hexdigest()+ original_installer_hash = hashlib.sha256(installer_path.read_bytes()).hexdigest()if options.candidate_hardware:apply_candidate(options.candidate_hardware, hardware_path, options.candidate_sha256)+ if options.candidate_installer:+ apply_candidate(options.candidate_installer, installer_path, options.installer_sha256)hardware = load('hardware', '/usr/lib/harness-os/hardware.py')- installer = load('installer', '/usr/lib/harness-os/install.py')+ installer = load('installer', installer_path)assert subprocess.check_output(['nmcli', 'networking'], text=True).strip() == 'disabled'bundle = hardware.bundle_manifest(hardware.BUNDLE, all_files=True)baseline = subprocess.check_output(['pacman', '-Q'], text=True)@@ -104,7 +146,10 @@ def main():**{'class': '028000'}, driver=None, interfaces=[])]original_run = installer.runhardware_hash = hashlib.sha256(hardware_path.read_bytes()).hexdigest()- evidence = {'image_hardware_sha256': original_hash, 'hardware_sha256': hardware_hash}+ installer_hash = hardware.digest(installer_path)+ evidence = {'image_hardware_sha256': original_hash, 'hardware_sha256': hardware_hash,+ 'image_installer_sha256': original_installer_hash, 'installer_sha256': installer_hash,+ 'cache_extraction': check_cache_extraction(installer, hardware)}def hardware_selection(*args, **kwargs):if args[:3] != ('/usr/bin/python3', '/usr/lib/harness-os/hardware.py', 'configure-install'):@@ -117,9 +162,21 @@ def main():if options.candidate_hardware:apply_candidate(hardware_path, installed_hardware, hardware_hash)assert hashlib.sha256(installed_hardware.read_bytes()).hexdigest() == hardware_hash+ installed_installer = target / installer_path.relative_to('/')+ if options.candidate_installer:+ apply_candidate(installer_path, installed_installer, installer_hash)+ assert hardware.digest(installed_installer) == installer_hashmodule = target / hardware.BUNDLE.relative_to('/') / bundle['module']+ assert not (module.parent / 'packages').exists(), 'The live package cache was copied to the installed disk'+ evidence['payload_archive_bytes_omitted'] = sum(row['bytes'] for name, row in bundle['files'].items()+ if name.startswith('packages/'))original_module = module.read_bytes()before = hardware.run('arch-chroot', target, 'pacman', '-Q', capture=True)+ assert hardware.configure_install(target, []) == {'drivers': [], 'devices': []}+ assert hardware.run('arch-chroot', target, 'pacman', '-Q', capture=True) == before+ assert not module.parent.exists()+ evidence['generic_packages_unchanged'] = True+ shutil.copytree(hardware.BUNDLE, module.parent, ignore=shutil.ignore_patterns('packages'))with tempfile.TemporaryDirectory(prefix='harness-pci-', dir='/run') as directory:reserved = assigned_devices(hardware, Path(directory))result = hardware.configure_install(target, reserved)@@ -128,9 +185,8 @@ def main():assert not module.parent.exists()evidence['explicit_assignments'] = {'devices': reserved, 'packages_unchanged': True,'activation_unchanged': True, 'optional_cache_removed': True}- # The negative installation pruned only this target's optional cache.- # Restore it from the untouched USB for the positive offline transaction.- shutil.copytree(hardware.BUNDLE, module.parent)+ # Restore only its small image metadata/module for the positive row.+ shutil.copytree(hardware.BUNDLE, module.parent, ignore=shutil.ignore_patterns('packages'))# Corruption must fail before a package transaction or binding change.module.write_bytes(b'corrupt-module')try:@@ -142,6 +198,40 @@ def main():finally:module.write_bytes(original_module)assert hardware.run('arch-chroot', target, 'pacman', '-Q', capture=True) == before+ small = min((hardware.BUNDLE / 'packages').glob('*.pkg.tar.zst'), key=lambda path: path.stat().st_size)+ original = small.read_bytes()+ small.write_bytes(b'corrupted-archive')+ try:+ hardware.configure_install(target, devices)+ except ValueError as error:+ assert 'checksum' in str(error), error+ else:+ raise AssertionError('The installer accepted a damaged live Wi-Fi archive')+ finally:+ small.write_bytes(original)+ # Hash agreement does not replace pacman's signature verification.+ manifest_path = hardware.BUNDLE / 'manifest.json'+ original_manifest = manifest_path.read_bytes()+ signature = small.with_name(small.name + '.sig')+ original_signature = signature.read_bytes()+ signature.write_bytes(b'invalid-pgp-signature')+ changed = json.loads(original_manifest)+ changed['files'][str(signature.relative_to(hardware.BUNDLE))] = {+ 'bytes': signature.stat().st_size, 'sha256': hardware.digest(signature)}+ manifest_path.write_text(json.dumps(changed))+ (module.parent / 'manifest.json').write_text(json.dumps(changed))+ try:+ hardware.configure_install(target, devices)+ except subprocess.CalledProcessError as error:+ assert 'pacman' in error.cmd and '-U' in error.cmd, error+ else:+ raise AssertionError('Pacman accepted an invalid Wi-Fi package signature')+ finally:+ signature.write_bytes(original_signature)+ manifest_path.write_bytes(original_manifest)+ (module.parent / 'manifest.json').write_bytes(original_manifest)+ assert not list((target / 'var/tmp').glob('harness-driver-*')), 'Failed transaction leaked a package mount'+ assert hardware.run('arch-chroot', target, 'pacman', '-Q', capture=True) == beforestarted = time.monotonic()result = hardware.configure_install(target, devices)after = hardware.run('arch-chroot', target, 'pacman', '-Q', capture=True)@@ -159,6 +249,7 @@ def main():assert 'blacklist wl' in overrides.splitlines()evidence.update(optional_packages=added, offline_prepare_seconds=round(time.monotonic() - started, 3),corrupted_bundle_rejected=True, cache_removed=True, base_packages_unchanged=True,+ corrupted_live_archive_rejected=True, invalid_signature_rejected=True,native_drivers_preserved=True, hardware_state=result)return Nonediff --git a/os/tests/hardware_install_vm.py b/os/tests/hardware_install_vm.pyindex 37f0db877..7896b4f5d 100644--- a/os/tests/hardware_install_vm.py+++ b/os/tests/hardware_install_vm.py@@ -41,6 +41,8 @@ def main():parser.add_argument('--output', type=Path, default=Path('os/test-results/hardware-install'))parser.add_argument('--candidate-hardware', type=Path,help='Test a committed hardware.py over the verified image; retain its hash and source separately')+ parser.add_argument('--candidate-installer', type=Path,+ help='Test a committed installer.py over the verified image; retain its hash and source separately')args = parser.parse_args()if not os.access('/dev/kvm', os.R_OK | os.W_OK):parser.error('Native x86 KVM is required')@@ -58,6 +60,8 @@ def main():limitations=['Synthetic PCI selection; physical Wi-Fi association and Mac sleep/wake remain unverified.'])if args.candidate_hardware:receipt['candidate_hardware'] = candidate_record(args.candidate_hardware)+ if args.candidate_installer:+ receipt['candidate_installer'] = candidate_record(args.candidate_installer)vm = VM(folder, iso, 'uefi', 1024, 'usb')try:vm.start(live=True)@@ -74,6 +78,11 @@ def main():copy_file(vm, args.candidate_hardware.read_bytes(), '/run/hardware-candidate.py')command += ['--candidate-hardware', '/run/hardware-candidate.py','--candidate-sha256', candidate['sha256']]+ if args.candidate_installer:+ candidate = receipt['candidate_installer']+ copy_file(vm, args.candidate_installer.read_bytes(), '/run/installer-candidate.py')+ command += ['--candidate-installer', '/run/installer-candidate.py',+ '--installer-sha256', candidate['sha256']]receipt['guest_fixture_sha256'] = digest(script)output, _ = vm.command(shlex.join(command), timeout=1200)(folder / 'installation.log').write_text(output)@@ -82,7 +91,9 @@ def main():receipt['installation'] = json.loads(match.group(1))assert receipt['installation']['status'] == 'passed'if args.candidate_hardware:- assert receipt['installation']['hardware_sha256'] == candidate['sha256']+ assert receipt['installation']['hardware_sha256'] == receipt['candidate_hardware']['sha256']+ if args.candidate_installer:+ assert receipt['installation']['installer_sha256'] == receipt['candidate_installer']['sha256']vm.screenshot('01-live-install-complete')vm.command('sync')vm.stop()@@ -94,6 +105,9 @@ def main():installed_hardware = vm.read_file('/usr/lib/harness-os/hardware.py')receipt['installed_hardware_sha256'] = hashlib.sha256(installed_hardware).hexdigest()assert receipt['installed_hardware_sha256'] == receipt['installation']['hardware_sha256'], 'Installed hardware policy differs'+ installed_installer = vm.read_file('/usr/lib/harness-os/install.py')+ receipt['installed_installer_sha256'] = hashlib.sha256(installed_installer).hexdigest()+ assert receipt['installed_installer_sha256'] == receipt['installation']['installer_sha256'], 'Installed installer differs'vm.command('test ! -e /usr/share/harness-os/hardware/broadcom && test ! -e /etc/harness-live')output, _ = vm.command('pacman -Q broadcom-wl-dkms dkms gcc linux-lts-headers; dkms status; harness hardware')(folder / 'installed-hardware.txt').write_text(output)diff --git a/os/tests/test_hardware.py b/os/tests/test_hardware.pyindex 25eefa313..8fdec9b21 100644--- a/os/tests/test_hardware.py+++ b/os/tests/test_hardware.py@@ -16,7 +16,7 @@ class HardwarePolicy(unittest.TestCase):def setUp(self):self.temp = tempfile.TemporaryDirectory()self.addCleanup(self.temp.cleanup)- self.root = Path(self.temp.name)+ self.root = Path(self.temp.name).resolve()self.sysfs = self.root / 'sys'def device(self, address='0000:03:00.0', device='43a0', driver=None, wireless=False, kind='028000', override='(null)'):@@ -44,10 +44,17 @@ class HardwarePolicy(unittest.TestCase):folder.mkdir(parents=True)module = folder / 'wl.ko'module.write_bytes(b'kernel-module-fixture')+ (folder / 'packages').mkdir()+ package = folder / 'packages/broadcom-wl-dkms-1-1-any.pkg.tar.zst'+ package.write_bytes(b'package-fixture')+ signature = package.with_name(package.name + '.sig')+ signature.write_bytes(b'signature-fixture')manifest = {'schema': 1, 'driver': 'broadcom-wl', 'architecture': 'x86_64','kernel': hardware.os.uname().release, 'module': 'wl.ko','arch_snapshot': '2026/10/01', 'base_packages': {'linux-lts': '6.18.54-1'},- 'files': {'wl.ko': {'bytes': module.stat().st_size, 'sha256': hardware.digest(module)}}}+ 'packages': {package.name: {'name': 'broadcom-wl-dkms', 'version': '1-1'}},+ 'files': {str(path.relative_to(folder)): {'bytes': path.stat().st_size, 'sha256': hardware.digest(path)}+ for path in [module, package, signature]}}(folder / 'manifest.json').write_text(json.dumps(manifest))return folder@@ -178,6 +185,78 @@ class HardwarePolicy(unittest.TestCase):self.assertEqual(run.call_count, 1)self.assertIn('-Q', run.call_args.args)+ def installation(self, shared=True):+ import shutil+ target = self.root / 'target'+ (target / 'etc').mkdir(parents=True)+ (target / 'etc/harness-live').touch()+ (target / 'var/tmp').mkdir(parents=True)+ live = self.bundle()+ folder = target / hardware.BUNDLE.relative_to('/')+ shutil.copytree(live, folder)+ if shared:+ shutil.rmtree(folder / 'packages')+ (target / 'usr/share/harness-os/lock.json').write_text('{"arch_snapshot":"2026/10/01"}')+ self.device()+ return target, folder, live++ def test_shared_cache_requires_matching_manifest_and_verified_archives(self):+ target, folder, live = self.installation()+ manifest = live / 'manifest.json'+ original = manifest.read_text()+ changed = json.loads(original)+ changed['arch_snapshot'] = '2026/09/01'+ manifest.write_text(json.dumps(changed))+ with patch.object(hardware.Path, 'is_mount', return_value=True), patch.object(hardware, 'run') as run:+ with self.assertRaisesRegex(ValueError, 'image differ'):+ hardware.configure_install(target, hardware.pci_devices(self.sysfs), live)+ run.assert_not_called()+ manifest.write_text(original)+ next((live / 'packages').glob('*.pkg.tar.zst')).write_bytes(b'damaged-package')+ with self.assertRaisesRegex(ValueError, 'checksum'):+ hardware.configure_install(target, hardware.pci_devices(self.sysfs), live)+ run.assert_not_called()+ self.assertTrue(folder.exists())++ def test_read_only_package_mount_is_removed_after_failed_transaction(self):+ target, folder, live = self.installation()+ calls = []++ def operation(*args, **kwargs):+ calls.append(args)+ if '-Q' in args:+ return 'linux-lts 6.18.54-1'+ if '-U' in args:+ config = target / args[args.index('--config') + 1].lstrip('/')+ self.assertIn('LocalFileSigLevel = Required', config.read_text())+ self.assertNotIn('[core]', config.read_text())+ raise subprocess.CalledProcessError(1, args)++ with patch.object(hardware.Path, 'is_mount', return_value=True), \+ patch.object(hardware, 'run', side_effect=operation), self.assertRaises(subprocess.CalledProcessError):+ hardware.configure_install(target, hardware.pci_devices(self.sysfs), live)+ self.assertEqual(calls[1][:3], ('mount', '--bind', live / 'packages'))+ self.assertEqual(calls[2][:3], ('mount', '-o', 'remount,bind,ro'))+ self.assertEqual(calls[-1], ('umount', calls[1][3]))+ self.assertFalse(list((target / 'var/tmp').iterdir()))+ self.assertTrue(folder.exists())+ hardware.bundle_manifest(live, all_files=True)++ def test_copied_cache_remains_the_source_for_override_images(self):+ target, folder, live = self.installation(shared=False)+ calls = []++ def operation(*args, **kwargs):+ calls.append(args)+ return 'linux-lts 6.18.54-1' if '-Q' in args else ''++ with patch.object(hardware.Path, 'is_mount', return_value=True), patch.object(hardware, 'run', side_effect=operation):+ result = hardware.configure_install(target, hardware.pci_devices(self.sysfs), self.root / 'missing-live-cache')+ self.assertEqual(calls[1][:3], ('mount', '--bind', folder / 'packages'))+ self.assertEqual(result['drivers'], ['broadcom-wl-dkms'])+ self.assertFalse(folder.exists())+ hardware.bundle_manifest(live, all_files=True)+def test_report_does_not_collect_serials_network_addresses_or_ssids(self):self.device()dmi = self.sysfs / 'class/dmi/id'diff --git a/os/tests/test_installer.py b/os/tests/test_installer.pyindex 2feef9c4b..e2a1fc94c 100644--- a/os/tests/test_installer.py+++ b/os/tests/test_installer.py@@ -114,6 +114,45 @@ class LivePayload(unittest.TestCase):explicit.touch()self.assertEqual(installer.live_payload(explicit), explicit)+ def test_only_matching_available_live_packages_are_excluded(self):+ with tempfile.TemporaryDirectory() as temp:+ root = Path(temp)+ bundle = root / 'bundle'+ (bundle / 'packages').mkdir(parents=True)+ package = bundle / 'packages/package.pkg.tar.zst'+ package.write_bytes(b'archive')+ manifest = {'packages': {package.name: {}}, 'files': {+ str(package.relative_to(bundle)): {'bytes': 7, 'sha256': hashlib.sha256(b'archive').hexdigest()}}}+ manifest_path = bundle / 'manifest.json'+ manifest_path.write_text(json.dumps(manifest))+ excluded = 'usr/share/harness-os/hardware/broadcom/packages'+ with patch.object(installer, 'run', return_value=json.dumps(manifest)) as run:+ installer.copy_image(root / 'image.sfs', root / 'target', bundle)+ self.assertIn(excluded, run.call_args.args)+ for changed in ['missing', 'wrong-size', 'symlink', 'different-manifest']:+ with self.subTest(changed=changed):+ package.unlink(missing_ok=True)+ manifest_path.write_text(json.dumps(manifest))+ if changed == 'wrong-size':+ package.write_bytes(b'bad')+ elif changed == 'symlink':+ (root / 'outside').write_bytes(b'archive')+ package.symlink_to(root / 'outside')+ elif changed == 'different-manifest':+ package.write_bytes(b'archive')+ manifest_path.write_text(json.dumps(dict(manifest, source='another-image')))+ installer.copy_image(root / 'image.sfs', root / 'target', bundle)+ self.assertNotIn(excluded, run.call_args.args)++ def test_unreadable_live_manifest_retains_embedded_packages(self):+ with tempfile.TemporaryDirectory() as temp:+ root = Path(temp)+ (root / 'manifest.json').write_text('not-json')+ with patch.object(installer, 'run') as run:+ installer.copy_image(root / 'image.sfs', root / 'target', root)+ self.assertEqual(run.call_count, 1)+ self.assertNotIn('usr/share/harness-os/hardware/broadcom/packages', run.call_args.args)+class EncryptionMemory(unittest.TestCase):def budget(self, total_mib, available_mib, swap_mib=0):