From f9ce7679fed5f28b165841fbae6f27581d1ca4b6 Mon Sep 17 00:00:00 2001 From: Anton Hvornum Date: Mon, 12 Jun 2023 10:49:53 +0200 Subject: Added a service-started wait timer for keyring.timer (#1858) * Added a service-started wait timer for keyring.timer, and then we check the service state for keyring.service. This is because the .service can be 'dead' right from the start without the timer ever have started. This ensures that we wait for the timer to kick in before we monitor for the .service execution * Removed pacman-init.service wait timer, as we can rely on keyring.timer instead: https://github.com/archlinux/archinstall/issues/1846#issuecomment-1586872920 --- archinstall/lib/installer.py | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/archinstall/lib/installer.py b/archinstall/lib/installer.py index 6eac85fc..e3dd3f04 100644 --- a/archinstall/lib/installer.py +++ b/archinstall/lib/installer.py @@ -147,12 +147,17 @@ class Installer: while self._service_state('reflector') not in ('dead', 'failed', 'exited'): time.sleep(1) - info('Waiting pacman-init.service to complete.') - while self._service_state('pacman-init') not in ('dead', 'failed', 'exited'): + # info('Waiting for pacman-init.service to complete.') + # while self._service_state('pacman-init') not in ('dead', 'failed', 'exited'): + # time.sleep(1) + + info('Waiting for Arch Linux keyring sync (archlinux-keyring-wkd-sync) to complete.') + # Wait for the timer to kick in + while self._service_started('archlinux-keyring-wkd-sync.timer') is None: time.sleep(1) - info('Waiting Arch Linux keyring sync (archlinux-keyring-wkd-sync) to complete.') - while self._service_state('archlinux-keyring-wkd-sync') not in ('dead', 'failed', 'exited'): + # Wait for the service to enter a finished state + while self._service_state('archlinux-keyring-wkd-sync.service') not in ('dead', 'failed', 'exited'): time.sleep(1) def _verify_boot_part(self): @@ -1206,8 +1211,19 @@ class Installer: return True + def _service_started(self, service_name: str) -> str | None: + if os.path.splitext(service_name)[1] not in ('.service', '.target', '.timer'): + service_name += '.service' # Just to be safe + + last_execution_time = b''.join(SysCommand(f"systemctl show --property=ActiveEnterTimestamp --no-pager {service_name}", environment_vars={'SYSTEMD_COLORS': '0'})) + last_execution_time = last_execution_time.lstrip(b'ActiveEnterTimestamp=').strip() + if not last_execution_time: + return None + + return last_execution_time.decode('UTF-8') + def _service_state(self, service_name: str) -> str: - if os.path.splitext(service_name)[1] != '.service': + if os.path.splitext(service_name)[1] not in ('.service', '.target', '.timer'): service_name += '.service' # Just to be safe state = b''.join(SysCommand(f'systemctl show --no-pager -p SubState --value {service_name}', environment_vars={'SYSTEMD_COLORS': '0'})) -- cgit v1.2.3-54-g00ecf