1:8 /ˆÈÇ 547Æ¿Ê#/"""Remove __future__ imports from __future__ import foo is replaced with an empty line. """ # Author: Christian Heimes # Local imports from .. import fixer_base from ..fixer_util import BlankLine class FixFuture(fixer_base.BaseFix): BM_compatible = True PATTERN = """import_from< 'from' module_name="__future__" 'import' any >""" # This should be run last -- some things check for the import run_order = 10 def transform(self, node, results): new = BlankLine() new.prefix = node.prefix return new 1ˆ¾Ç 0Æ¿Ê 3ˆ¾Ç ƒh¹Æ¿Ê31B252D4060FF09CC633A32A $5ˆl–äY>” jC]Šq@³p\jbÑ¿È „ m¿ÇÀË2ÿ5# kpatch patch module packages management plugin for dnf # # Copyright (C) 2020 Julien Thierry # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License # as published by the Free Software Foundation; either version 2 # of the License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, # 02110-1301, USA. """ The DNF plugin helps customers to install kpatch-patch packages when the kernel is upgraded and filter kernel-core packages that are supported by the kpatch team. """ from __future__ import absolute_import from __future__ import unicode_literals import configparser import os.path import re from dnfpluginscore import _, logger import dnf import dnf.callback import dnf.cli import dnf.exceptions import dnf.transaction import hawkey KPATCH_PLUGIN_NAME = "kpatch" KPATCH_UPDATE_OPT = "autoupdate" KPATCH_FILTER_OPT = "autofilter" KERNEL_PKG_NAME = "kernel-core" # Dnf offers to lookup and read the plugin config file but doesn't provide # a way to update that file nor to get the name... def _get_plugin_cfg_file(base_conf): files = ['%s/%s.conf' % (path, KPATCH_PLUGIN_NAME) for path in base_conf.pluginconfpath] for file in files: if os.path.isfile(file): return file return None def _kpp_name_from_kernel_pkg(kernel_pkg): kernel_release = re.match(r"(.*)\.el.*", kernel_pkg.release).group(1) kpp_kernel_release = kernel_release.replace(".", "_") kpp_kernel_version = kernel_pkg.version.replace(".", "_") return "kpatch-patch-{}-{}".format(kpp_kernel_version, kpp_kernel_release) def _install_kpp_pkg(dnf_base, kernel_pkg): kpp_pkg_name = _kpp_name_from_kernel_pkg(kernel_pkg) kpp_pkgs_query = dnf_base.sack.query().filter(name=kpp_pkg_name, arch=kernel_pkg.arch) kpp_sltr = dnf.selector.Selector(dnf_base.sack) kpp_sltr.set(pkg=kpp_pkgs_query.latest()) dnf_base.goal.install(select=kpp_sltr, optional=not dnf_base.conf.strict) class KpatchCmd(dnf.cli.Command): """ Extend DNF with kpatch specific commands """ aliases = ('kpatch',) summary = _('Toggles automatic installation of kpatch-patch packages') def __init__(self, cli): super().__init__(cli) self.cfg_file = _get_plugin_cfg_file(self.base.conf) @staticmethod def set_argparser(parser): """ argparse python class """ parser.add_argument('action', metavar="auto-update|manual-update|" \ "auto-filter|no-filter|install|status|" \ "auto|manual" ) def configure(self): """ configure DemandSheet Collection of demands that different CLI parts have on other parts """ demands = self.cli.demands demands.root_user = True