mirror of
https://github.com/isjerryxiao/pacroller.git
synced 2024-12-23 06:39:24 +08:00
parent
6bdbd52707
commit
c5d110c9b8
3 changed files with 28 additions and 1 deletions
|
@ -1,8 +1,12 @@
|
|||
import json
|
||||
from pathlib import Path
|
||||
import sys
|
||||
import importlib.util
|
||||
from typing import Any
|
||||
|
||||
CONFIG_DIR = Path('/etc/pacroller')
|
||||
CONFIG_FILE = 'config.json'
|
||||
F_KNOWN_OUTPUT_OVERRIDE = 'known_output_override.py'
|
||||
LIB_DIR = Path('/var/lib/pacroller')
|
||||
DB_FILE = 'db'
|
||||
PACMAN_CONFIG = '/etc/pacman.conf'
|
||||
|
@ -16,6 +20,17 @@ if (cfg := (CONFIG_DIR / CONFIG_FILE)).exists():
|
|||
else:
|
||||
_config = dict()
|
||||
|
||||
def _import_module(fpath: str) -> Any:
|
||||
spec = importlib.util.spec_from_file_location(fpath.removesuffix('.py').replace('/', '.'), fpath)
|
||||
mod = importlib.util.module_from_spec(spec)
|
||||
spec.loader.exec_module(mod)
|
||||
return mod
|
||||
if (_komf := (CONFIG_DIR / F_KNOWN_OUTPUT_OVERRIDE)).exists():
|
||||
_kom = _import_module(str(_komf.resolve()))
|
||||
KNOWN_OUTPUT_OVERRIDE = (_kom.KNOWN_HOOK_OUTPUT, _kom.KNOWN_PACKAGE_OUTPUT)
|
||||
else:
|
||||
KNOWN_OUTPUT_OVERRIDE = (dict(), dict())
|
||||
|
||||
TIMEOUT = int(_config.get('timeout', 300))
|
||||
UPGRADE_TIMEOUT = int(_config.get('upgrade_timeout', 3600))
|
||||
NETWORK_RETRY = int(_config.get('network_retry', 5))
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
from pacroller.config import KNOWN_OUTPUT_OVERRIDE
|
||||
KNOWN_HOOK_OUTPUT_OVERRIDE, KNOWN_PACKAGE_OUTPUT_OVERRIDE = KNOWN_OUTPUT_OVERRIDE
|
||||
|
||||
KNOWN_HOOK_OUTPUT = {
|
||||
'': [],
|
||||
'20-systemd-sysusers.hook': [
|
||||
|
@ -15,7 +18,8 @@ KNOWN_HOOK_OUTPUT = {
|
|||
r'==> Creating (?:.+)-compressed initcpio image: .+',
|
||||
r'==> Image generation successful.*',
|
||||
r'[ ]+-> .+',
|
||||
]
|
||||
],
|
||||
**KNOWN_HOOK_OUTPUT_OVERRIDE
|
||||
}
|
||||
|
||||
_keyring_output = [
|
||||
|
@ -46,4 +50,5 @@ KNOWN_PACKAGE_OUTPUT = {
|
|||
r'Generation complete\.',
|
||||
r' .*_.*\.\.\. done',
|
||||
],
|
||||
**KNOWN_PACKAGE_OUTPUT_OVERRIDE
|
||||
}
|
||||
|
|
7
src/pacroller/known_output_override.py
Normal file
7
src/pacroller/known_output_override.py
Normal file
|
@ -0,0 +1,7 @@
|
|||
KNOWN_HOOK_OUTPUT = {
|
||||
'example.hook': [],
|
||||
}
|
||||
|
||||
KNOWN_PACKAGE_OUTPUT = {
|
||||
'example-package': [],
|
||||
}
|
Loading…
Reference in a new issue