mirror of
https://github.com/isjerryxiao/pacroller.git
synced 2024-11-25 17:20:41 +08:00
various fixes
This commit is contained in:
parent
7083d4b41b
commit
fc23239e30
4 changed files with 12 additions and 9 deletions
|
@ -30,7 +30,7 @@ REGEX: Dict[str, Pattern] # get through lint
|
|||
class checkReport:
|
||||
def __init__(self, info: List[str] = None, warn: List[str] = None,
|
||||
crit: List[str] = None, changes: List[Tuple[str]] = None,
|
||||
date: int = int(time)) -> None:
|
||||
date: int = int(time())) -> None:
|
||||
self._info = info or list()
|
||||
self._warn = warn or list()
|
||||
self._crit = crit or list()
|
||||
|
@ -86,7 +86,7 @@ class checkReport:
|
|||
ret.append("Package changes:")
|
||||
ret.extend([" " * indent + i for i in pkg_ret])
|
||||
if len(ret) == 1:
|
||||
ret.append('all systems go')
|
||||
ret.append('nothing to show')
|
||||
return "\n".join(ret)
|
||||
def info(self, text: str) -> None:
|
||||
logger.debug(f'report info {text}')
|
||||
|
@ -229,7 +229,7 @@ def _log_parser(log: List[str], report: checkReport) -> None:
|
|||
report.crit(f'ALPM {line=} is unknown')
|
||||
elif source == 'ALPM-SCRIPTLET':
|
||||
(_, _, _pmsg) = _split_log_line(log[ln-1])
|
||||
if _m := REGEX['s_upgrade_pkg'].match(_pmsg):
|
||||
if _m := REGEX['l_upgrade'].match(_pmsg):
|
||||
pkg, *_ = _m.groups()
|
||||
elif _m := REGEX['l_install'].match(_pmsg):
|
||||
pkg, *_ = _m.groups()
|
||||
|
@ -237,6 +237,8 @@ def _log_parser(log: List[str], report: checkReport) -> None:
|
|||
pkg, *_ = _m.groups()
|
||||
else:
|
||||
report.crit(f'{line=} has unknown SCRIPTLET output')
|
||||
ln += 1
|
||||
continue
|
||||
logger.debug(f'.install start {pkg=}')
|
||||
while True:
|
||||
ln += 1
|
||||
|
|
|
@ -8,9 +8,9 @@
|
|||
"hold": {
|
||||
"linux": "(.*)",
|
||||
"python": "[0-9]+[.]([0-9]+)[.][0-9]+[-][0-9]+"
|
||||
}
|
||||
'ignored_pacnew': [
|
||||
'/etc/locale.gen',
|
||||
'/etc/pacman.d/mirrorlist'
|
||||
},
|
||||
"ignored_pacnew": [
|
||||
"/etc/locale.gen",
|
||||
"/etc/pacman.d/mirrorlist"
|
||||
]
|
||||
}
|
||||
|
|
|
@ -27,7 +27,7 @@ EXTRA_SAFE = bool(_config.get('extra_safe', False))
|
|||
SHELL = str(_config.get('shell', '/bin/bash'))
|
||||
|
||||
HOLD = _config.get('hold', dict())
|
||||
for (k, v) in HOLD:
|
||||
for (k, v) in HOLD.items():
|
||||
assert isinstance(k, str) and isinstance(v, str)
|
||||
|
||||
IGNORED_PACNEW = _config.get('ignored_pacnew', list())
|
||||
|
|
|
@ -68,8 +68,8 @@ class alpmCallback:
|
|||
|
||||
def upgrade() -> List[str]:
|
||||
logger.info('upgrade start')
|
||||
handle = pycman.config.init_with_config(PACMAN_CONFIG)
|
||||
pycman.config.cb_log = lambda *_: None
|
||||
handle = pycman.config.init_with_config(PACMAN_CONFIG)
|
||||
localdb = handle.get_localdb()
|
||||
alpmCallback().setup_hdl(handle)
|
||||
t = handle.init_transaction()
|
||||
|
@ -77,6 +77,7 @@ def upgrade() -> List[str]:
|
|||
t.sysupgrade(False) # no downgrade
|
||||
if len(t.to_add) + len(t.to_remove) == 0:
|
||||
logger.info('upgrade end, nothing to do')
|
||||
exit(0)
|
||||
else:
|
||||
def examine_upgrade(toadd: List[pyalpm.Package], toremove: List[pyalpm.Package]) -> None:
|
||||
for pkg in toadd:
|
||||
|
|
Loading…
Reference in a new issue