|
|
17a86d |
From 5a05773dfcfbd317e082a8a58edc391d53bed845 Mon Sep 17 00:00:00 2001
|
|
|
17a86d |
From: Marek Blaha <mblaha@redhat.com>
|
|
|
17a86d |
Date: Thu, 2 Jul 2020 14:30:34 +0200
|
|
|
17a86d |
Subject: [PATCH 5/5] [debug] Do not remove install-only packages
|
|
|
17a86d |
(RhBug:1844533)
|
|
|
17a86d |
|
|
|
17a86d |
Running debug-restore command may result in an attempt to remove the
|
|
|
17a86d |
running kernel (in case the running kernel package is not present in the
|
|
|
17a86d |
dump file).
|
|
|
17a86d |
Newly the install-only packages are not removed, only the versions
|
|
|
17a86d |
mentioned in the dump file are marked for installation (the decision on
|
|
|
17a86d |
what versions to keep on the system is done according to
|
|
|
17a86d |
installonly_limit config option).
|
|
|
17a86d |
New option `--remove-installonly` to force removal of those versions of
|
|
|
17a86d |
install-only packages that are not present in the dump file is
|
|
|
17a86d |
introduced.
|
|
|
17a86d |
|
|
|
17a86d |
https://bugzilla.redhat.com/show_bug.cgi?id=1844533
|
|
|
17a86d |
---
|
|
|
17a86d |
doc/debug.rst | 18 +++++++++++++++++-
|
|
|
17a86d |
plugins/debug.py | 13 +++++++++----
|
|
|
17a86d |
2 files changed, 26 insertions(+), 5 deletions(-)
|
|
|
17a86d |
|
|
|
17a86d |
diff --git a/doc/debug.rst b/doc/debug.rst
|
|
|
17a86d |
index ee9860f..2f8418f 100644
|
|
|
17a86d |
--- a/doc/debug.rst
|
|
|
17a86d |
+++ b/doc/debug.rst
|
|
|
17a86d |
@@ -23,7 +23,18 @@ DNF debug Plugin
|
|
|
17a86d |
Description
|
|
|
17a86d |
-----------
|
|
|
17a86d |
|
|
|
17a86d |
-Writes system RPM configuration to a dump file and restore it.
|
|
|
17a86d |
+The plugin provides two dnf commands:
|
|
|
17a86d |
+
|
|
|
17a86d |
+``debug-dump``
|
|
|
17a86d |
+ Writes system RPM configuration to a dump file
|
|
|
17a86d |
+
|
|
|
17a86d |
+``debug-restore``
|
|
|
17a86d |
+ Restore the installed packages to the versions written in the dump file. By
|
|
|
17a86d |
+ default, it does not remove already installed versions of install-only
|
|
|
17a86d |
+ packages and only marks those versions that are mentioned in the dump file
|
|
|
17a86d |
+ for installation. The final decision on which versions to keep on the
|
|
|
17a86d |
+ system is left to dnf and can be fine-tuned using the `installonly_limit`
|
|
|
17a86d |
+ (see :manpage:`dnf.conf(5)`) configuration option.
|
|
|
17a86d |
|
|
|
17a86d |
.. note:: DNF and Yum debug files are not compatible and thus can't be used
|
|
|
17a86d |
by the other program.
|
|
|
17a86d |
@@ -70,3 +81,8 @@ All general DNF options are accepted, see `Options` in :manpage:`dnf(8)` for det
|
|
|
17a86d |
``--output``
|
|
|
17a86d |
Only output list of packages which will be installed or removed.
|
|
|
17a86d |
No actuall changes are done.
|
|
|
17a86d |
+
|
|
|
17a86d |
+``--remove-installonly``
|
|
|
17a86d |
+ Allow removal of install-only packages. Using this option may result in an
|
|
|
17a86d |
+ attempt to remove the running kernel version (in situations when the currently
|
|
|
17a86d |
+ running kernel version is not part of the dump file).
|
|
|
17a86d |
diff --git a/plugins/debug.py b/plugins/debug.py
|
|
|
17a86d |
index efe6bea..ad136a9 100644
|
|
|
17a86d |
--- a/plugins/debug.py
|
|
|
17a86d |
+++ b/plugins/debug.py
|
|
|
17a86d |
@@ -194,6 +194,10 @@ class DebugRestoreCommand(dnf.cli.Command):
|
|
|
17a86d |
"--filter-types", metavar="[install, remove, replace]",
|
|
|
17a86d |
default="install, remove, replace",
|
|
|
17a86d |
help=_("limit to specified type"))
|
|
|
17a86d |
+ parser.add_argument(
|
|
|
17a86d |
+ "--remove-installonly", action="store_true",
|
|
|
17a86d |
+ help=_('Allow removing of install-only packages. Using this option may '
|
|
|
17a86d |
+ 'result in an attempt to remove the running kernel.'))
|
|
|
17a86d |
parser.add_argument(
|
|
|
17a86d |
"filename", nargs=1, help=_("name of dump file"))
|
|
|
17a86d |
|
|
|
17a86d |
@@ -238,10 +242,11 @@ class DebugRestoreCommand(dnf.cli.Command):
|
|
|
17a86d |
# package should not be installed
|
|
|
17a86d |
pkg_remove = True
|
|
|
17a86d |
if pkg_remove and "remove" in opts.filter_types:
|
|
|
17a86d |
- if opts.output:
|
|
|
17a86d |
- print("remove %s" % spec)
|
|
|
17a86d |
- else:
|
|
|
17a86d |
- self.base.package_remove(pkg)
|
|
|
17a86d |
+ if pkg not in installonly_pkgs or opts.remove_installonly:
|
|
|
17a86d |
+ if opts.output:
|
|
|
17a86d |
+ print("remove %s" % spec)
|
|
|
17a86d |
+ else:
|
|
|
17a86d |
+ self.base.package_remove(pkg)
|
|
|
17a86d |
|
|
|
17a86d |
def process_dump(self, dump_pkgs, opts):
|
|
|
17a86d |
for (n, a) in sorted(dump_pkgs.keys()):
|
|
|
17a86d |
--
|
|
|
17a86d |
2.25.4
|
|
|
17a86d |
|