-
-
Notifications
You must be signed in to change notification settings - Fork 770
Skip custom mirror config when keyring sync fails #4577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
23ff97c
cf478a0
490e71f
6b9cc77
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,8 +4,8 @@ | |
| from pathlib import Path | ||
|
|
||
| from archinstall.lib.command import SysCommand | ||
| from archinstall.lib.exceptions import RequirementError | ||
| from archinstall.lib.log import error, info, warn | ||
| from archinstall.lib.exceptions import RequirementError, SysCallError | ||
| from archinstall.lib.log import debug, error, info, warn | ||
| from archinstall.lib.pathnames import PACMAN_CONF | ||
| from archinstall.lib.plugins import plugins | ||
| from archinstall.lib.translationhandler import tr | ||
|
|
@@ -53,15 +53,45 @@ def ask(self, error_message: str, bail_message: str, func: Callable, *args, **kw | |
| def sync(self) -> None: | ||
| if self.synced: | ||
| return | ||
| self.ask( | ||
| 'Could not sync a new package database', | ||
| 'Could not sync mirrors', | ||
| self.run, | ||
| '-Syy', | ||
| default_cmd='pacman', | ||
| ) | ||
|
|
||
| try: | ||
| self.run('-Syy') | ||
| except SysCallError as err: | ||
| if b'GPGME' in err.worker_log or b'keyring' in err.worker_log.lower(): | ||
| warn('Pacman sync failed with keyring error, attempting keyring reinit') | ||
| self._reinit_keyring() | ||
| msg = 'Could not sync a new package database after keyring reinit' | ||
| else: | ||
| msg = 'Could not sync a new package database' | ||
|
|
||
| self.ask(msg, 'Could not sync mirrors', self.run, '-Syy') | ||
|
|
||
| self.synced = True | ||
|
|
||
| @staticmethod | ||
| def _is_running(process: str) -> bool: | ||
| try: | ||
| SysCommand(f'pgrep -x {process}') | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given that Maybe even put that into the utils https://github.com/archlinux/archinstall/blob/af2120c0e94ada1bb7e9eea44283d19323ce2f27/archinstall/lib/utils/util.py
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good call on systemctl, that's cleaner and I see we already do exactly this for espeakup. One thing I'm unsure about though: in the live ISO, gpg-agent is usually spawned on-demand by gpg/pacman-key rather than started as a systemd service, so systemctl is-active --quiet gpg-agent.service might report it inactive even while the process is actually running. In that case we'd skip the killall, and that's the one spot where killing it matters (a stale agent holding the old /etc/pacman.d/gnupg open before --init). pgrep catches the process directly regardless of how it was started, which is why I reached for it. That said, I might be overthinking the ISO behavior here. Have you actually seen gpg-agent show up as an active unit in that context? If so I'm happy to switch to systemctl, otherwise maybe pgrep is the safer bet. What do you think?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| return True | ||
| except SysCallError: | ||
| debug(f'{process} is not running') | ||
| return False | ||
|
|
||
| @staticmethod | ||
| def _reinit_keyring() -> None: | ||
| if Pacman._is_running('gpg-agent'): | ||
| try: | ||
| SysCommand('killall gpg-agent') | ||
| except SysCallError as err: | ||
| debug(f'Failed to kill gpg-agent: {err}') | ||
|
|
||
| try: | ||
| SysCommand('pacman-key --init') | ||
| SysCommand('pacman-key --populate archlinux') | ||
| debug('Keyring reinitialized successfully') | ||
| except SysCallError as err: | ||
| debug(f'Keyring reinit failed: {err}') | ||
|
|
||
| def strap(self, packages: str | list[str]) -> None: | ||
| self.sync() | ||
| if isinstance(packages, str): | ||
|
|
||

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can be simplified to
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done