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