mirror of
https://github.com/isjerryxiao/pacroller.git
synced 2024-12-23 06:39:24 +08:00
check for pacman lock and handle sync timeout
This commit is contained in:
parent
c75cf9100e
commit
09404979b0
2 changed files with 11 additions and 1 deletions
|
@ -8,6 +8,7 @@ DB_FILE = 'db'
|
|||
PACMAN_CONFIG = '/etc/pacman.conf'
|
||||
PACMAN_LOG = '/var/log/pacman.log'
|
||||
PACMAN_PKG_DIR = '/var/cache/pacman/pkg'
|
||||
PACMAN_DB_LCK = '/var/lib/pacman/db.lck'
|
||||
assert LIB_DIR.is_dir()
|
||||
|
||||
if (cfg := (CONFIG_DIR / CONFIG_FILE)).exists():
|
||||
|
|
|
@ -15,7 +15,7 @@ from pacroller.checker import log_checker, sync_err_is_net, upgrade_err_is_net,
|
|||
from pacroller.config import (CONFIG_DIR, CONFIG_FILE, LIB_DIR, DB_FILE, PACMAN_LOG, PACMAN_CONFIG,
|
||||
TIMEOUT, UPGRADE_TIMEOUT, NETWORK_RETRY, CUSTOM_SYNC, SYNC_SH,
|
||||
EXTRA_SAFE, SHELL, HOLD, NEEDRESTART, NEEDRESTART_CMD, SYSTEMD,
|
||||
PACMAN_PKG_DIR, PACMAN_SCC)
|
||||
PACMAN_PKG_DIR, PACMAN_SCC, PACMAN_DB_LCK)
|
||||
|
||||
logger = logging.getLogger()
|
||||
|
||||
|
@ -55,6 +55,12 @@ def sync() -> None:
|
|||
else:
|
||||
logger.exception(f'sync failed with {e.returncode=} {e.output=}')
|
||||
raise
|
||||
except subprocess.TimeoutExpired as e:
|
||||
logger.warning('database download timeout {e.timeout=} {e.output=}')
|
||||
if PACMAN_DB_LCK.exists():
|
||||
logger.warning(f'automatically removing {PACMAN_DB_LCK}')
|
||||
Path(PACMAN_DB_LCK).unlink()
|
||||
raise SyncRetry()
|
||||
else:
|
||||
logger.debug(f'sync {p.stdout=}')
|
||||
logger.info('sync end')
|
||||
|
@ -252,6 +258,9 @@ def main() -> None:
|
|||
if _s := is_system_failed():
|
||||
logger.error(f'systemd is in {_s} state, refused')
|
||||
exit(11)
|
||||
if Path(PACMAN_DB_LCK).exists():
|
||||
logger.error(f'Database is locked at {PACMAN_DB_LCK}')
|
||||
exit(2)
|
||||
try:
|
||||
report = do_system_upgrade(args.debug)
|
||||
except NonFatal:
|
||||
|
|
Loading…
Reference in a new issue