mirror of
https://github.com/isjerryxiao/pacroller.git
synced 2024-11-15 04:42:24 +08:00
check news
This commit is contained in:
parent
cd64807a39
commit
b685ec00a4
5 changed files with 27 additions and 5 deletions
|
@ -40,6 +40,8 @@ A list of pacnew files that are silently ignored during parsing, any other pacne
|
||||||
Custom pacman hooks and packages output matching is configurable via `/etc/pacroller/known_output_override.py`.
|
Custom pacman hooks and packages output matching is configurable via `/etc/pacroller/known_output_override.py`.
|
||||||
### check systemd status
|
### check systemd status
|
||||||
The "systemd-check" option allows pacroller to check fo degraded systemd services before an upgrade.
|
The "systemd-check" option allows pacroller to check fo degraded systemd services before an upgrade.
|
||||||
|
### check news from archinux.org
|
||||||
|
Automatically checks news before upgrade, unless "news-check" is set to false.
|
||||||
### clear package cache
|
### clear package cache
|
||||||
Pacroller wipes /var/cache/pacman/pkg after a successful upgrade if the option "clear_pkg_cache" is set.
|
Pacroller wipes /var/cache/pacman/pkg after a successful upgrade if the option "clear_pkg_cache" is set.
|
||||||
### save pacman output
|
### save pacman output
|
||||||
|
@ -52,4 +54,3 @@ Configure `/etc/pacroller/smtp.json` to receive an email notification when an up
|
||||||
- Your favourite package may not be supported, however it's easy to add another set of rules.
|
- Your favourite package may not be supported, however it's easy to add another set of rules.
|
||||||
- Restarting the whole system after a kernel upgrade is not implemented.
|
- Restarting the whole system after a kernel upgrade is not implemented.
|
||||||
- Human interaction is required occasionally.
|
- Human interaction is required occasionally.
|
||||||
- Does not check news from archlinux.org
|
|
||||||
|
|
|
@ -26,5 +26,6 @@
|
||||||
"-l"
|
"-l"
|
||||||
],
|
],
|
||||||
"systemd-check": true,
|
"systemd-check": true,
|
||||||
|
"news-check": true,
|
||||||
"clear_pkg_cache": false
|
"clear_pkg_cache": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ CONFIG_FILE_SMTP = 'smtp.json'
|
||||||
F_KNOWN_OUTPUT_OVERRIDE = 'known_output_override.py'
|
F_KNOWN_OUTPUT_OVERRIDE = 'known_output_override.py'
|
||||||
LIB_DIR = Path('/var/lib/pacroller')
|
LIB_DIR = Path('/var/lib/pacroller')
|
||||||
DB_FILE = 'db'
|
DB_FILE = 'db'
|
||||||
|
NEWS_FILE = 'news'
|
||||||
LOG_DIR = Path('/var/log/pacroller')
|
LOG_DIR = Path('/var/log/pacroller')
|
||||||
PACMAN_CONFIG = '/etc/pacman.conf'
|
PACMAN_CONFIG = '/etc/pacman.conf'
|
||||||
PACMAN_LOG = '/var/log/pacman.log'
|
PACMAN_LOG = '/var/log/pacman.log'
|
||||||
|
@ -75,6 +76,7 @@ for i in NEEDRESTART_CMD:
|
||||||
assert isinstance(i, str)
|
assert isinstance(i, str)
|
||||||
|
|
||||||
SYSTEMD = bool(_config.get('systemd-check', True))
|
SYSTEMD = bool(_config.get('systemd-check', True))
|
||||||
|
NEWS = bool(_config.get('news-check', True))
|
||||||
PACMAN_SCC = bool(_config.get('clear_pkg_cache', False))
|
PACMAN_SCC = bool(_config.get('clear_pkg_cache', False))
|
||||||
|
|
||||||
SMTP_ENABLED = bool(_smtp_config.get('enabled', False))
|
SMTP_ENABLED = bool(_smtp_config.get('enabled', False))
|
||||||
|
|
|
@ -12,11 +12,12 @@ from datetime import datetime
|
||||||
from typing import List, Iterator
|
from typing import List, Iterator
|
||||||
from pacroller.utils import execute_with_io, UnknownQuestionError, back_readline, ask_interactive_question
|
from pacroller.utils import execute_with_io, UnknownQuestionError, back_readline, ask_interactive_question
|
||||||
from pacroller.checker import log_checker, sync_err_is_net, upgrade_err_is_net, checkReport
|
from pacroller.checker import log_checker, sync_err_is_net, upgrade_err_is_net, checkReport
|
||||||
from pacroller.config import (CONFIG_DIR, CONFIG_FILE, LIB_DIR, DB_FILE, PACMAN_LOG, PACMAN_CONFIG,
|
from pacroller.config import (CONFIG_DIR, CONFIG_FILE, LIB_DIR, DB_FILE, NEWS_FILE, PACMAN_LOG,
|
||||||
TIMEOUT, UPGRADE_TIMEOUT, NETWORK_RETRY, CUSTOM_SYNC, SYNC_SH,
|
PACMAN_CONFIG, TIMEOUT, UPGRADE_TIMEOUT, NETWORK_RETRY, CUSTOM_SYNC,
|
||||||
EXTRA_SAFE, SHELL, HOLD, NEEDRESTART, NEEDRESTART_CMD, SYSTEMD,
|
SYNC_SH, EXTRA_SAFE, SHELL, HOLD, NEEDRESTART, NEEDRESTART_CMD, SYSTEMD,
|
||||||
PACMAN_PKG_DIR, PACMAN_SCC, PACMAN_DB_LCK, SAVE_STDOUT, LOG_DIR)
|
NEWS, PACMAN_PKG_DIR, PACMAN_SCC, PACMAN_DB_LCK, SAVE_STDOUT, LOG_DIR)
|
||||||
from pacroller.mailer import MailSender
|
from pacroller.mailer import MailSender
|
||||||
|
from pacroller.news import get_news
|
||||||
|
|
||||||
logger = logging.getLogger()
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
@ -32,6 +33,8 @@ class CheckFailed(Exception):
|
||||||
pass
|
pass
|
||||||
class NeedrestartFailed(Exception):
|
class NeedrestartFailed(Exception):
|
||||||
pass
|
pass
|
||||||
|
class NewsUnread(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
def sync() -> None:
|
def sync() -> None:
|
||||||
logger.info('sync start')
|
logger.info('sync start')
|
||||||
|
@ -318,6 +321,21 @@ def main() -> None:
|
||||||
logger.error(_err)
|
logger.error(_err)
|
||||||
send_mail(_err)
|
send_mail(_err)
|
||||||
exit(11)
|
exit(11)
|
||||||
|
if NEWS:
|
||||||
|
_newsf = LIB_DIR / NEWS_FILE
|
||||||
|
try:
|
||||||
|
_old_news = _newsf.read_text() if _newsf.exists() else ''
|
||||||
|
if (_news := get_news(_old_news)):
|
||||||
|
_newsf.write_text(_news[0])
|
||||||
|
_err = NewsUnread(_news)
|
||||||
|
write_db(None, _err)
|
||||||
|
for _n in _news:
|
||||||
|
logger.warn(f"news: {_n}")
|
||||||
|
send_mail(_err)
|
||||||
|
exit(11)
|
||||||
|
except Exception:
|
||||||
|
send_mail(f"Checking news:\n{traceback.format_exc()}")
|
||||||
|
raise
|
||||||
if Path(PACMAN_DB_LCK).exists():
|
if Path(PACMAN_DB_LCK).exists():
|
||||||
_err = f'Database is locked at {PACMAN_DB_LCK}'
|
_err = f'Database is locked at {PACMAN_DB_LCK}'
|
||||||
logger.error(_err)
|
logger.error(_err)
|
||||||
|
|
Loading…
Reference in a new issue