From 1bafba41a6d0312914475056eef34cb3e3b4678b Mon Sep 17 00:00:00 2001 From: yangcheng1203 Date: Tue, 29 Mar 2022 16:43:04 +0800 Subject: [PATCH] fix dnf error when history sqlite missing (cherry picked from commit 0414d0ec135641c825162debd866be1ed6ae2ae7) --- ...rk-error-when-history-sqlite-missing.patch | 25 ++++++++++++++++++ dnf.spec | 8 +++++- ...do-error-when-history-sqlite-missing.patch | 26 +++++++++++++++++++ 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 backport-fix-dnf-mark-error-when-history-sqlite-missing.patch create mode 100644 fix-dnf-history-undo-error-when-history-sqlite-missing.patch diff --git a/backport-fix-dnf-mark-error-when-history-sqlite-missing.patch b/backport-fix-dnf-mark-error-when-history-sqlite-missing.patch new file mode 100644 index 0000000..b0bccd1 --- /dev/null +++ b/backport-fix-dnf-mark-error-when-history-sqlite-missing.patch @@ -0,0 +1,25 @@ +From 0fefe7c1ad1d9c60f6159b14871837043b5e0d1f Mon Sep 17 00:00:00 2001 +From: zhanghaolian <65838930+iWhy98@users.noreply.github.com> +Date: Tue, 25 Jan 2022 15:41:16 +0800 +Subject: [PATCH] dnf:fix dnf mark error when history sqlite missing + +Conflict: NA +Reference:https://github.com/rpm-software-management/dnf/pull/1808 + +--- + dnf/cli/commands/mark.py | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/dnf/cli/commands/mark.py b/dnf/cli/commands/mark.py +index ec16b738dc..cb1f91c135 100644 +--- a/dnf/cli/commands/mark.py ++++ b/dnf/cli/commands/mark.py +@@ -89,7 +89,7 @@ def run(self): + + old = self.base.history.last() + if old is None: +- rpmdb_version = self.sack._rpmdb_version() ++ rpmdb_version = self.base.sack._rpmdb_version() + else: + rpmdb_version = old.end_rpmdb_version + diff --git a/dnf.spec b/dnf.spec index f1a074c..3b9ec1c 100644 --- a/dnf.spec +++ b/dnf.spec @@ -3,7 +3,7 @@ Name: dnf Version: 4.2.23 -Release: 7 +Release: 8 Summary: A software package manager that manages packages on Linux distributions. License: GPLv2+ and GPLv2 and GPL URL: https://github.com/rpm-software-management/dnf @@ -20,6 +20,9 @@ Patch7: Pass-the-package-to-rpmkeys-stdin.patch Patch8: Use-rpmkeys-alone-to-verify-signature.patch Patch9: Add-fail_fast-parameter-to-download_payloads-methods.patch Patch10: Fix-reporting-irrecoverable-errors-on-packages-downl.patch +Patch6000: backport-fix-dnf-mark-error-when-history-sqlite-missing.patch + +Patch9000: fix-dnf-history-undo-error-when-history-sqlite-missing.patch BuildArch: noarch BuildRequires: cmake gettext systemd bash-completion python3-sphinx @@ -210,6 +213,9 @@ popd %{_mandir}/man8/%{name}-automatic.8* %changelog +* Tue Mar 29 2022 yangcheng - 4.2.23-8 +- fix dnf error when history sqlite missing + * Thu Mar 10 2022 zhangshaoning - 4.2.23-7 - Type:bugfix - ID:NA diff --git a/fix-dnf-history-undo-error-when-history-sqlite-missing.patch b/fix-dnf-history-undo-error-when-history-sqlite-missing.patch new file mode 100644 index 0000000..978f635 --- /dev/null +++ b/fix-dnf-history-undo-error-when-history-sqlite-missing.patch @@ -0,0 +1,26 @@ +From 57455df96b6dc9f8c90e8d783a2654896ac483e5 Mon Sep 17 00:00:00 2001 +From: zhujunhao +Date: Thu, 17 Mar 2022 11:40:59 +0800 +Subject: [PATCH] + fix-dnf-history-undo-error-when-history-sqlite-missing + +--- + dnf/cli/commands/__init__.py | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/dnf/cli/commands/__init__.py b/dnf/cli/commands/__init__.py +index 86f560b..088e958 100644 +--- a/dnf/cli/commands/__init__.py ++++ b/dnf/cli/commands/__init__.py +@@ -954,6 +954,9 @@ class HistoryCommand(Command): + s = s[4:] + transaction_id = int(s) + if transaction_id <= 0: ++ if not self.output.history.last(): ++ logger.critical("Not found given transaction ID") ++ raise ValueError + transaction_id += self.output.history.last().tid + return transaction_id + +-- +2.27.0