Skip to content

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.

Install required session tools when updating Harness OS (#867)

Dee5ff614221207
diff --git a/os/runtime_update.py b/os/runtime_update.py
index fffde317a..649add149 100644
--- a/os/runtime_update.py
+++ b/os/runtime_update.py
@@ -238,6 +238,14 @@ def install_package(package, version, runtime, additional=()):
verify_runtime(runtime)
+def prepare_packages(package, additional=()):
+ # Resolve and verify the entire transaction while the old installation is
+ # still intact. Pacman retains signatures/dependency checks, and uses its
+ # cache when offline. Missing downloads must not create a failed checkpoint.
+ subprocess.run(['pacman', '--noconfirm', '-U', '--downloadonly',
+ *map(str, additional), str(package)], check=True)
+
+
def apply(folder, system, base, installation):
previous = latest()
if previous and previous['status'] not in ('applied', 'rolled-back'):
@@ -266,6 +274,8 @@ def apply(folder, system, base, installation):
validate_bundle(incoming, base)
kernel_change = boot.prepare_update(incoming / source_package.name, folder, incoming)
kernel = boot.module('t2_update') if kernel_change else None
+ additional = [incoming / kernel_change['candidate']['package']['filename']] if kernel_change else []
+ prepare_packages(incoming / source_package.name, additional)
checkpoint = system.checkpoint('before-harness-update')
identity = datetime.now(timezone.utc).strftime('%Y%m%dT%H%M%SZ-') + uuid.uuid4().hex[:8]
saved = STATE / identity
@@ -288,7 +298,6 @@ def apply(folder, system, base, installation):
# The fast user updater must not mix a running old session with newly
# installed OS integration. /run clears this only on a real reboot.
system.write_json(RESTART_REQUIRED, {'status': 'applying', 'package': manifest['package']['version']})
- additional = [incoming / kernel_change['candidate']['package']['filename']] if kernel_change else []
install_package(incoming / source_package.name, manifest['package']['version'], manifest['runtime'], additional)
boot.restore_firmware()
# Plymouth and other initramfs assets may change without a kernel
diff --git a/os/tests/fast_update_vm.py b/os/tests/fast_update_vm.py
index 64d9ba6a9..8e3a83cc8 100644
--- a/os/tests/fast_update_vm.py
+++ b/os/tests/fast_update_vm.py
@@ -60,10 +60,12 @@ def exercise(vm, fixture, host_url):
vm.command('test ! -e ~/.local/state/harness-os/updates/ready.json && test ! -e ~/.local/state/harness-os/updates/current')
# The radio/network can remain off: only the loopback test release is used.
vm.command('sudo nmcli networking off')
- put(vm, '/tmp/update-session-probe.py', PROBE)
+ # The lock/suspend gate may have already used session-probe in this guest.
+ # Keep its files intact and wait for this probe's own newly written PID.
+ put(vm, '/tmp/update-session-probe.py', PROBE.replace('projects/session-probe', 'projects/fast-update-probe'))
vm.command('hn new-window -n update-probe ' + shlex.quote('python3 /tmp/update-session-probe.py'))
- vm.command('for n in $(seq 1 40); do test -s ~/projects/session-probe/pid && exit 0; sleep .25; done; exit 1')
- vm.command('cp ~/projects/session-probe/pid /tmp/fast-original-pid; cat /proc/$(cat /tmp/fast-original-pid)/stat > /tmp/fast-original-stat')
+ vm.command('for n in $(seq 1 40); do test -s ~/projects/fast-update-probe/pid && exit 0; sleep .25; done; exit 1')
+ vm.command('cp ~/projects/fast-update-probe/pid /tmp/fast-original-pid; cat /proc/$(cat /tmp/fast-original-pid)/stat > /tmp/fast-original-stat')
vm.command('systemctl --user show harness-daemon -p MainPID --value > /tmp/fast-original-daemon')
vm.command('hn new-window -n live-agent opencode')
vm.command('for n in $(seq 1 80); do pgrep -u 1000 -x opencode > /tmp/fast-original-agent && exit 0; sleep .25; done; exit 1')
@@ -104,7 +106,7 @@ def exercise(vm, fixture, host_url):
import time
pid = Path('/tmp/fast-original-pid').read_text().strip()
assert Path('/proc/'+pid+'/stat').read_text().split()[21] == Path('/tmp/fast-original-stat').read_text().split()[21]
-root = Path.home() / 'projects/session-probe'
+root = Path.home() / 'projects/fast-update-probe'
before = (root/'heartbeat').stat().st_mtime_ns
time.sleep(.6)
assert (root/'heartbeat').stat().st_mtime_ns != before
@@ -140,7 +142,7 @@ Path('/tmp/fast-screen-client.json').write_text(json.dumps(dict(target=str(targe
vm.type_probe(name)
vm.keys('ret')
vm.command('for n in $(seq 1 30); do grep -Fx ' + shlex.quote(name) +
- ' ~/projects/session-probe/input && exit 0; sleep .1; done; exit 1')
+ ' ~/projects/fast-update-probe/input && exit 0; sleep .1; done; exit 1')
vm.screenshot(name + '-accepted-input')
def activate(expect_failure=False, mouse=False):
diff --git a/os/tests/session_update_vm.py b/os/tests/session_update_vm.py
new file mode 100644
index 000000000..589db5672
--- /dev/null
+++ b/os/tests/session_update_vm.py
@@ -0,0 +1,144 @@
+"""Real dependency migration and session tools on the disposable update VM."""
+import hashlib
+import io
+import json
+from pathlib import Path
+import re
+import shlex
+import struct
+import tarfile
+import time
+
+from session_vm import installed_session
+
+
+def required(bundle):
+ manifest = json.loads((bundle / 'package-manifest.json').read_text())
+ with tarfile.open(bundle / manifest['package']['name']) as archive:
+ return any(re.fullmatch(r'depend = gtklock(?:[<>=].+)?', row)
+ for row in archive.extractfile('.PKGINFO').read().decode().splitlines())
+
+
+def prepare(vm, manifest):
+ """Prove failed downloads are harmless; then cache without installing tools."""
+ bundle = '/home/me/update-bundle'
+ package = bundle + '/' + manifest['package']['name']
+ def state():
+ vm.command('(pacman -Q harness-os && sha256sum /usr/share/harness-os/runtime.json '
+ '/usr/lib/harness/harness-tui /usr/share/harness-os/labwc/rc.xml) > /tmp/session-dependency-state')
+ return vm.read_file('/tmp/session-dependency-state')
+
+ def checkpoints():
+ vm.command('sudo -n find /.snapshots -mindepth 1 -maxdepth 1 -type d | sort > /tmp/session-dependency-checkpoints')
+ return vm.read_file('/tmp/session-dependency-checkpoints')
+
+ before = state()
+ _, installed = vm.command('pacman -Q gtklock', check=False)
+ evidence = {'checks': [], 'missing_locker_exercised': installed != 0,
+ 'observer_sha256': hashlib.sha256(Path(__file__).read_bytes()).hexdigest()}
+ if installed != 0:
+ # This is a fresh published image. Neither an earlier package transaction
+ # nor a prefilled download cache may conceal the regression.
+ vm.command('test -z "$(find /var/cache/pacman/pkg -name \'gtklock-*.pkg.tar.*\' -print -quit)"')
+ original_checkpoints = checkpoints()
+ vm.command('sudo -n nmcli networking off')
+ output, status = vm.command('sudo -n python3 ' + bundle + '/apply-update.py apply ' + bundle,
+ timeout=120, check=False)
+ (vm.folder / 'session-missing-dependency.log').write_text(output)
+ assert status != 0, 'Uncached gtklock unexpectedly installed without networking'
+ assert before == state(), 'Download failure changed the installed package'
+ assert original_checkpoints == checkpoints(), 'Download failure created a recovery checkpoint'
+ vm.command('sudo -n test ! -e /var/lib/harness-os/runtime-updates/latest.json && '
+ 'test ! -e /run/harness-os-restart-required')
+ evidence['checks'].append('Missing uncached gtklock refuses offline before package files, checkpoint, update receipt or restart state change')
+ vm.command('sudo -n nmcli networking on && nm-online --quiet --timeout=30', timeout=40)
+ output, _ = vm.command('sudo -n pacman --noconfirm -U --downloadonly ' + shlex.quote(package), timeout=180)
+ (vm.folder / 'session-dependency-download.log').write_text(output)
+ assert before == state(), 'Download-only preparation installed a package'
+ if installed != 0:
+ _, status = vm.command('pacman -Q gtklock', check=False)
+ assert status != 0, 'Preparation installed gtklock instead of caching it'
+ evidence['checks'].append('Pacman downloads and verifies declared dependencies online without installing them; following update/rollback runs offline using that cache')
+ return evidence
+
+
+def screenshots(vm, result):
+ from PIL import Image
+
+ def files():
+ vm.command('find ~/Pictures/Screenshots -type f -name "*.png" '
+ '> /tmp/session-screenshots 2>/dev/null || true')
+ return set(vm.read_file('/tmp/session-screenshots').decode().splitlines())
+
+ def saved(before, name):
+ deadline = time.monotonic() + 10
+ raw = b''
+ while True:
+ added = files() - before
+ assert len(added) <= 1, added
+ if added:
+ path = next(iter(added))
+ raw = vm.read_file(path)
+ # grim creates the file before rendering/encoding it. Existence
+ # alone can return zero bytes or a partially written PNG.
+ if raw.endswith(b'\x00\x00\x00\x00IEND\xaeB`\x82'):
+ break
+ if time.monotonic() >= deadline:
+ raise TimeoutError(f'Screenshot did not finish: {name}; files={added}; bytes={len(raw)}')
+ time.sleep(.2)
+ assert raw[:8] == b'\x89PNG\r\n\x1a\n'
+ with Image.open(io.BytesIO(raw)) as capture:
+ capture.verify()
+ (vm.folder / (name + '.png')).write_bytes(raw)
+ # Read the real Wayland clipboard from a real pane, whose environment
+ # was inherited from the session; no fabricated DISPLAY value.
+ target = '/tmp/' + name + '-clipboard.png'
+ # Clipboard ownership is established after encoding; await that too,
+ # without re-triggering capture or accepting the previous selection.
+ command = ('for n in $(seq 1 50); do wl-paste --type image/png > ' + target + ' 2>/dev/null && '
+ 'cmp -s ' + shlex.quote(path) + ' ' + target + ' && touch ' + target + '.done && exit 0; '
+ 'sleep .1; done; exit 1')
+ vm.command('hn new-window -n clipboard-check ' + shlex.quote(command))
+ vm.command('for n in $(seq 1 60); do test -e ' + target + '.done && exit 0; sleep .1; done; exit 1')
+ assert vm.read_file(target) == raw, 'Clipboard differs from the saved PNG'
+ return struct.unpack('>II', raw[16:24])
+
+ before = files()
+ vm.screenshot('screenshot-full-before')
+ with Image.open(vm.folder / 'screenshot-full-before.png') as frame:
+ size = frame.size
+ vm.keys('meta_l', 'p')
+ assert saved(before, 'session-full-capture') == size
+ result['checks'].append('Super+p captures the complete real display and copies the exact saved PNG to the Wayland clipboard')
+ before = files()
+ vm.keys('meta_l', 'r')
+ vm.command('for n in $(seq 1 40); do pgrep -u 1000 -x slurp && exit 0; sleep .1; done; exit 1')
+ vm.screenshot('screenshot-region-selection')
+ with Image.open(vm.folder / 'screenshot-region-selection.png') as frame:
+ width, height = frame.size
+
+ def pointer(x, y):
+ vm.monitor('input-send-event', events=[
+ {'type': 'abs', 'data': {'axis': 'x', 'value': round(x / width * 32767)}},
+ {'type': 'abs', 'data': {'axis': 'y', 'value': round(y / height * 32767)}},
+ ])
+ time.sleep(.2)
+
+ pointer(width // 4, height // 4)
+ vm.monitor('input-send-event', events=[{'type': 'btn', 'data': {'button': 'left', 'down': True}}])
+ time.sleep(.2)
+ pointer(width // 2, height // 2)
+ vm.monitor('input-send-event', events=[{'type': 'btn', 'data': {'button': 'left', 'down': False}}])
+ region = saved(before, 'session-region-capture')
+ assert abs(region[0] - width // 4) <= 2 and abs(region[1] - height // 4) <= 2, region
+ result['checks'].append('Super+r uses the real slurp selector; pointer drag saves only the selected region and copies identical PNG bytes')
+
+
+def exercise(vm, config, result):
+ output, _ = vm.command('pacman -Q gtklock grim slurp && pacman -Dk')
+ (vm.folder / 'session-installed-dependencies.log').write_text(output)
+ result['checks'].append('Upgraded package has gtklock/grim/slurp installed and pacman verifies dependency consistency')
+ # Existing observer proves wrong-password refusal, isolation of lock input,
+ # manual/idle lock and actual suspend/wake with the same terminal alive.
+ installed_session(vm, config, result)
+ screenshots(vm, result)
diff --git a/os/tests/t2_update_vm.py b/os/tests/t2_update_vm.py
index ee7b843cc..849d32534 100644
--- a/os/tests/t2_update_vm.py
+++ b/os/tests/t2_update_vm.py
@@ -19,6 +19,7 @@ import time
from footprint_vm import copy_file
from hardware_update_vm import graceful_stop
from session_vm import screen_text
+from session_update_vm import required as session_tools_required
from t2_install_vm import guest_result
from test_t2_firmware import firmware, source_fixture
from vm import VM, check_graphical_keyboard
@@ -144,6 +145,16 @@ def main():
if file.is_file():
vm.command('curl -fsS --retry 3 --max-time 90 ' + shlex.quote(url + '/' + file.name) +
' -o ' + shlex.quote(guest + '/' + file.name), timeout=100)
+ if session_tools_required(args.bundle):
+ # A newer package may add session dependencies absent from the
+ # historical image. Cache them online without changing that image;
+ # the actual baseline/kernel transactions below stay offline.
+ output, _ = vm.command('sudo -n pacman --noconfirm -U --downloadonly '
+ + shlex.quote(guest + '/' + before['package']['filename']) + ' '
+ + shlex.quote(guest + '/' + baseline.name), timeout=180)
+ (folder / 'session-dependency-download.log').write_text(output)
+ vm.command('test "$(pacman -Q harness-os)" = ' + shlex.quote('harness-os ' + image['package_version']))
+ record['checks'].append('New session dependencies are verified and cached before disconnecting; baseline package remains unchanged until the offline transaction')
vm.command('sudo -n nmcli networking off')
vm.monitor('set_link', name='hnnet', up=False)
probe('baseline')
diff --git a/os/tests/test_package.py b/os/tests/test_package.py
index b81bf4418..07f38e930 100644
--- a/os/tests/test_package.py
+++ b/os/tests/test_package.py
@@ -38,7 +38,12 @@ class PackageIdentity(unittest.TestCase):
# Validate the real staged package with the same guard that protects
# installed systems, not only an isolated archive fixture.
output = base / 'harness-os.pkg.tar.gz'
- package.archive_package(destination, output, 'pkgname = harness-os\npkgver = 1-1\narch = x86_64\n', 123456)
+ package.archive_package(destination, output, package.package_info('1-1', 123456, 1024), 123456)
+ with tarfile.open(output) as archive:
+ metadata = archive.extractfile('.PKGINFO').read().decode().splitlines()
+ depends = {row.removeprefix('depend = ') for row in metadata if row.startswith('depend = ')}
+ self.assertTrue({'gtklock', 'grim', 'slurp', 'foot', 'labwc', 'tmux', 'nodejs-lts-jod'} <= depends)
+ self.assertTrue(depends <= set((Path(__file__).parents[1] / 'packages.x86_64').read_text().split()))
spec = importlib.util.spec_from_file_location('runtime_package_check', Path(__file__).parents[1] / 'runtime_update.py')
updater = importlib.util.module_from_spec(spec)
spec.loader.exec_module(updater)
diff --git a/os/tests/test_runtime_update.py b/os/tests/test_runtime_update.py
index c3cefa033..b2f3ae3ac 100644
--- a/os/tests/test_runtime_update.py
+++ b/os/tests/test_runtime_update.py
@@ -4,11 +4,12 @@ import importlib.util
import io
import json
from pathlib import Path
+import subprocess
import tarfile
import tempfile
from types import SimpleNamespace
import unittest
-from unittest.mock import patch
+from unittest.mock import Mock, patch
spec = importlib.util.spec_from_file_location('runtime_update', Path(__file__).parents[1] / 'runtime_update.py')
@@ -85,6 +86,41 @@ class BundleGuards(unittest.TestCase):
run.assert_called_once()
self.assertEqual(run.call_args.args[0], ['pacman', '--noconfirm', '-U', str(kernel), str(self.package)])
+ def test_dependency_prefetch_includes_kernel_without_installing(self):
+ kernel = self.root / 'linux-t2.pkg.tar.zst'
+ with patch.object(update.subprocess, 'run') as run:
+ update.prepare_packages(self.package, [kernel])
+ run.assert_called_once_with(['pacman', '--noconfirm', '-U', '--downloadonly',
+ str(kernel), str(self.package)], check=True)
+
+ def test_missing_dependency_download_leaves_receipt_and_checkpoint_untouched(self):
+ state = self.root / 'state'
+ state.mkdir()
+ previous = state / 'latest.json'
+ previous.write_text('{"id":"previous-good-update"}')
+ checkpoints = self.root / 'checkpoints'
+ checkpoints.mkdir()
+ runtime = self.root / 'runtime.json'
+ runtime.write_text(json.dumps(self.runtime))
+ restart = self.root / 'restart.json'
+ system = SimpleNamespace(CHECKPOINTS=checkpoints, snapshot_date=lambda x: x,
+ write_json=lambda path, value: path.write_text(json.dumps(value)),
+ checkpoint=Mock(side_effect=AssertionError('No checkpoint before downloads')))
+ boot = SimpleNamespace(prepare_update=lambda *args: None)
+ with patch.object(update, 'STATE', state), patch.object(update, 'RUNTIME', runtime), \
+ patch.object(update, 'RESTART_REQUIRED', restart), \
+ patch.object(update, 'latest', return_value={'status': 'applied'}), \
+ patch.object(update, 'boot_module', return_value=boot), \
+ patch.object(update, 'validate_bundle', return_value=(self.manifest, self.package)), \
+ patch.object(update, 'installed_version', return_value='older-1'), \
+ patch.object(update.subprocess, 'run', side_effect=subprocess.CalledProcessError(1, 'pacman')):
+ with self.assertRaises(subprocess.CalledProcessError):
+ update.apply(self.root, system, self.base, {'root_uuid': 'test-root'})
+ system.checkpoint.assert_not_called()
+ self.assertEqual(previous.read_text(), '{"id":"previous-good-update"}')
+ self.assertEqual(list(checkpoints.iterdir()), [])
+ self.assertFalse(restart.exists())
+
def test_legacy_rollback_completes_after_package_removes_platform_helper(self):
folder = self.root / 'installed'
folder.mkdir()
diff --git a/os/tests/update_guest.py b/os/tests/update_guest.py
index 7ab7e40fb..6d9a90ca5 100644
--- a/os/tests/update_guest.py
+++ b/os/tests/update_guest.py
@@ -103,7 +103,7 @@ while True:
assert version() == 'harness-os ' + manifest['package']['version']
assert json.loads(Path('/usr/share/harness-os/runtime.json').read_text()) == manifest['runtime']
alive()
- receipt['checks'].append('Small package installed offline and verified without restarting the existing terminal process')
+ receipt['checks'].append('Package and cached dependencies installed offline and verified without restarting the existing terminal process')
run('sudo', 'harness', 'upgrade', str(bundle))
alive()
receipt['checks'].append('Repeated apply recognizes the installed build without another transaction')
diff --git a/os/tests/update_vm.py b/os/tests/update_vm.py
index c272dcb58..2ddce9772 100644
--- a/os/tests/update_vm.py
+++ b/os/tests/update_vm.py
@@ -14,6 +14,33 @@ import subprocess
import threading
import time
from vm import VM, check_graphical_keyboard
+import session_update_vm
+
+
+def network_state(vm, name):
+ """Retain the real device state without repairing or reactivating it."""
+ state = {}
+ for command in [
+ 'nmcli general status', 'nmcli networking', 'nmcli device show',
+ 'nmcli -f NAME,UUID,TYPE,DEVICE,AUTOCONNECT connection show',
+ 'ip -details link', 'ip address', 'ip route',
+ 'sudo -n cat /var/lib/NetworkManager/NetworkManager.state',
+ 'sudo -n journalctl -b -u NetworkManager -u systemd-logind -u systemd-suspend --no-pager',
+ 'sudo -n journalctl -b -k --no-pager',
+ ]:
+ output, status = vm.command('env PAGER= LC_ALL=C ' + command, timeout=15, check=False)
+ state[command] = {'status': status, 'output': output}
+ (vm.folder / (name + '-network.json')).write_text(json.dumps(state, indent=2) + '\n')
+
+
+def network_roundtrip(vm, url, expected):
+ """Require an actual connection and exact HTTP payload, not just NM state."""
+ vm.command('nm-online -q --timeout=30', timeout=35)
+ vm.command('curl --fail --silent --show-error --max-time 15 ' +
+ shlex.quote(url + '/package-manifest.json') +
+ ' -o /tmp/harness-update-network.json', timeout=20)
+ assert vm.read_file('/tmp/harness-update-network.json') == expected, 'Network payload differs'
+ return {'bytes': len(expected), 'sha256': hashlib.sha256(expected).hexdigest()}
def main():
@@ -27,6 +54,8 @@ def main():
parser.error('This acceptance run requires native x86 KVM.')
iso, bundle, folder = args.iso.resolve(), args.bundle.resolve(), args.output.resolve()
image = json.loads(iso.with_name('manifest.json').read_text())
+ manifest = json.loads((bundle / 'package-manifest.json').read_text())
+ session_tools = session_update_vm.required(bundle)
with iso.open('rb') as handle:
assert hashlib.file_digest(handle, 'sha256').hexdigest() == image['iso']['sha256']
folder.mkdir(parents=True, exist_ok=False)
@@ -39,8 +68,13 @@ def main():
server = ThreadingHTTPServer(('127.0.0.1', 0), partial(SimpleHTTPRequestHandler, directory=str(served)))
thread = threading.Thread(target=server.serve_forever, daemon=True)
thread.start()
- vm = VM(folder, iso, 'uefi', 2048)
- receipt = {'status': 'running', 'started_at': time.time(), 'image': image, 'checks': []}
+ # Match the existing session/suspend gate. The pinned kernel's bochs driver
+ # resumes this virtual display; virtio-vga can leave its scanout inactive.
+ video = 'VGA' if session_tools else 'virtio-vga'
+ vm = VM(folder, iso, 'uefi', 2048, video=video)
+ receipt = {'status': 'running', 'started_at': time.time(), 'image': image,
+ 'video': video, 'checks': [],
+ 'limits': ['Virtual display and ACPI suspend; no physical laptop, panel, or GPU acceptance.']}
config = dict(disk='/dev/vda', expected_serial='HN_OS_TEST', confirm_erase='/dev/vda',
username='me', hostname='harness', password='test-password-123', encrypt=True, serial_console=True)
try:
@@ -67,6 +101,8 @@ def main():
vm.command('curl --fail --silent --show-error --max-time 90 ' + shlex.quote(url + '/' + name) +
' -o ' + shlex.quote('/home/me/update-bundle/' + name), timeout=100)
vm.command('cd /home/me/update-bundle && sha256sum -c SHA256SUMS')
+ if session_tools:
+ receipt['session_dependencies'] = session_update_vm.prepare(vm, manifest)
# The actual update/rollback must not require a package repository or network.
vm.command('sudo nmcli networking off')
output, status = vm.command('python3 /home/me/update-bundle/update_guest.py /home/me/update-bundle', timeout=600, check=False)
@@ -76,11 +112,17 @@ def main():
result = json.loads(next(line.split(marker, 1)[1] for line in output.splitlines() if line.startswith(marker)))
receipt['update'] = result
vm.screenshot('updated-surviving-terminal')
+ if session_tools:
+ # The transactions above finish offline. Restore the ordinary
+ # connected session before the separate reboot/suspend checks.
+ vm.command('printf %s ' + shlex.quote(config['password'] + '\n') + ' | sudo -S -v')
+ vm.command('sudo -n nmcli networking on')
+ network_payload = (bundle / 'package-manifest.json').read_bytes()
+ receipt['network'] = {'after_offline_transactions': network_roundtrip(vm, url, network_payload)}
vm.command('sync')
vm.stop()
vm.start(live=False)
vm.login_installed(config)
- manifest = json.loads((bundle / 'package-manifest.json').read_text())
vm.command('test "$(pacman -Q harness-os)" = ' + shlex.quote('harness-os ' + manifest['package']['version']))
vm.command('test -s ~/projects/update-survivor/keep.txt')
receipt['keyboard'] = check_graphical_keyboard(vm, 'updated')
@@ -97,6 +139,13 @@ def main():
vm.keys('ctrl', 'd')
receipt['checks'].append('A rebooted upgrade preserves hn’s standard footer and Ctrl+b, c opens a real terminal tab')
receipt['checks'].append('Updated encrypted machine reboots to hn, accepts physical-keyboard input and retains the project')
+ if session_tools:
+ vm.command('printf %s ' + shlex.quote(config['password'] + '\n') + ' | sudo -S -v')
+ receipt['network']['before_suspend'] = network_roundtrip(vm, url, network_payload)
+ network_state(vm, 'before-session')
+ session_update_vm.exercise(vm, config, receipt['session_dependencies'])
+ receipt['network']['after_suspend'] = network_roundtrip(vm, url, network_payload)
+ network_state(vm, 'after-session')
if args.fast_fixture:
vm.command('printf %s ' + shlex.quote(config['password'] + '\n') + ' | sudo -S -v')
from fast_update_vm import exercise
@@ -121,6 +170,7 @@ def main():
# Collect diagnostics after the failed assertion. The actual update
# test cleared credentials; never block its error path on a prompt.
vm.command('printf %s ' + shlex.quote(config['password'] + '\n') + ' | sudo -S -v')
+ network_state(vm, 'failure')
output, _ = vm.command('sudo -n journalctl _UID=1000 --no-pager; '
'sudo -n cat /var/lib/harness-os/runtime-updates/*/receipt.json; '
'tail -n 100 /var/log/pacman.log; hn capture-pane -p -S -200 -t Updates; '
diff --git a/os/tools/build-package.py b/os/tools/build-package.py
index a43c2e16c..14a1850f4 100644
--- a/os/tools/build-package.py
+++ b/os/tools/build-package.py
@@ -13,6 +13,20 @@ import tarfile
import tempfile
+DEPENDENCIES = ('nodejs-lts-jod', 'tmux', 'foot', 'labwc', 'gtklock', 'grim', 'slurp')
+
+
+def package_info(version, timestamp, size):
+ # These are needed on upgrades too; adding a tool to the ISO list alone
+ # leaves existing computers with new launchers but no executable to run.
+ return (f'pkgname = harness-os\npkgbase = harness-os\nxdata = pkgtype=pkg\npkgver = {version}\n'
+ 'pkgdesc = Harness session and verified Harness runtime\n'
+ 'url = https://github.com/autonomous-ai/openharness\n'
+ f'builddate = {timestamp}\npackager = OpenHarness\nsize = {size}\n'
+ 'arch = x86_64\nlicense = MIT\n'
+ + ''.join(f'depend = {name}\n' for name in DEPENDENCIES))
+
+
def digest(path):
with path.open('rb') as handle:
return hashlib.file_digest(handle, 'sha256').hexdigest()
@@ -167,12 +181,7 @@ def main():
root = Path(temp) / 'root'
runtime = stage(source, args.runtime.resolve(), root, commit)
size = sum(p.stat().st_size for p in root.rglob('*') if p.is_file() and not p.is_symlink())
- pkginfo = (f'pkgname = harness-os\npkgbase = harness-os\nxdata = pkgtype=pkg\npkgver = {version}\n'
- 'pkgdesc = Harness session and verified Harness runtime\n'
- 'url = https://github.com/autonomous-ai/openharness\n'
- f'builddate = {timestamp}\npackager = OpenHarness\nsize = {size}\n'
- 'arch = x86_64\nlicense = MIT\ndepend = nodejs-lts-jod\ndepend = tmux\n'
- 'depend = foot\ndepend = labwc\n')
+ pkginfo = package_info(version, timestamp, size)
archive_package(root, package, pkginfo, timestamp)
manifest = {'schema': 1, 'kind': 'harness-os-package', 'development': args.development,
'source_commit': commit, 'architecture': lock['architecture'],