/
githubmirror
/
salt
Обзор
Документация
Войти
/
githubmirror
/
salt
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
scripts/suse/yum/plugins/yumnotify.py
55 строк
1 KB
Pedro Algarvio
Update pre-commit hook versions
29 фев 2024, 15:30
Не верифицирован
29 фев 2024, 15:30
f454911
Код
Авторство
О чём код?
# Copyright (c) 2016 SUSE Linux LLC # All Rights Reserved. # # Author: Bo Maryniuk <bo@suse.de> import hashlib import os from yum.plugins import TYPE_CORE CK_PATH = "/var/cache/salt/minion/rpmdb.cookie" RPM_PATH = "/var/lib/rpm/Packages" requires_api_version = "2.5" plugin_type = TYPE_CORE def _get_mtime(): """ Get the modified time of the RPM Database. Returns: Unix ticks """ return os.path.exists(RPM_PATH) and int(os.path.getmtime(RPM_PATH)) or 0 def _get_checksum(): """ Get the checksum of the RPM Database. Returns: hexdigest """ digest = hashlib.sha256() with open(RPM_PATH, "rb") as rpm_db_fh: while True: buff = rpm_db_fh.read(0x1000) if not buff: break digest.update(buff) return digest.hexdigest() def posttrans_hook(conduit): """ Hook after the package installation transaction. :param conduit: :return: """ # Integrate Yum with Salt if "SALT_RUNNING" not in os.environ: with open(CK_PATH, "w") as ck_fh: ck_fh.write(f"{_get_checksum()} {_get_mtime()}\n")