|
|
922fe2 |
From 7ba2cd6a86945e0ec6f9ed866e2ef6b6759ee092 Mon Sep 17 00:00:00 2001
|
|
|
922fe2 |
From: Jan Kolarik <jkolarik@redhat.com>
|
|
|
922fe2 |
Date: Thu, 25 Aug 2022 08:06:34 +0200
|
|
|
922fe2 |
Subject: [PATCH] Add support for group upgrade rollback (RhBug:2016070)
|
|
|
922fe2 |
|
|
|
922fe2 |
= changelog =
|
|
|
922fe2 |
type: bugfix
|
|
|
922fe2 |
resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2016070
|
|
|
922fe2 |
---
|
|
|
922fe2 |
dnf/db/group.py | 8 +++++++-
|
|
|
922fe2 |
dnf/transaction_sr.py | 24 ++++++++++++++++++++++++
|
|
|
922fe2 |
2 files changed, 31 insertions(+), 1 deletion(-)
|
|
|
922fe2 |
|
|
|
922fe2 |
diff --git a/dnf/db/group.py b/dnf/db/group.py
|
|
|
922fe2 |
index 4dc8cb06..312e3b98 100644
|
|
|
922fe2 |
--- a/dnf/db/group.py
|
|
|
922fe2 |
+++ b/dnf/db/group.py
|
|
|
922fe2 |
@@ -34,14 +34,16 @@ class PersistorBase(object):
|
|
|
922fe2 |
self._installed = {}
|
|
|
922fe2 |
self._removed = {}
|
|
|
922fe2 |
self._upgraded = {}
|
|
|
922fe2 |
+ self._downgraded = {}
|
|
|
922fe2 |
|
|
|
922fe2 |
def __len__(self):
|
|
|
922fe2 |
- return len(self._installed) + len(self._removed) + len(self._upgraded)
|
|
|
922fe2 |
+ return len(self._installed) + len(self._removed) + len(self._upgraded) + len(self._downgraded)
|
|
|
922fe2 |
|
|
|
922fe2 |
def clean(self):
|
|
|
922fe2 |
self._installed = {}
|
|
|
922fe2 |
self._removed = {}
|
|
|
922fe2 |
self._upgraded = {}
|
|
|
922fe2 |
+ self._downgraded = {}
|
|
|
922fe2 |
|
|
|
922fe2 |
def _get_obj_id(self, obj):
|
|
|
922fe2 |
raise NotImplementedError
|
|
|
922fe2 |
@@ -62,6 +64,10 @@ class PersistorBase(object):
|
|
|
922fe2 |
self._upgraded[self._get_obj_id(obj)] = obj
|
|
|
922fe2 |
self._add_to_history(obj, libdnf.transaction.TransactionItemAction_UPGRADE)
|
|
|
922fe2 |
|
|
|
922fe2 |
+ def downgrade(self, obj):
|
|
|
922fe2 |
+ self._downgraded[self._get_obj_id(obj)] = obj
|
|
|
922fe2 |
+ self._add_to_history(obj, libdnf.transaction.TransactionItemAction_DOWNGRADE)
|
|
|
922fe2 |
+
|
|
|
922fe2 |
def new(self, obj_id, name, translated_name, pkg_types):
|
|
|
922fe2 |
raise NotImplementedError
|
|
|
922fe2 |
|
|
|
922fe2 |
diff --git a/dnf/transaction_sr.py b/dnf/transaction_sr.py
|
|
|
922fe2 |
index dae8d300..5d403a3e 100644
|
|
|
922fe2 |
--- a/dnf/transaction_sr.py
|
|
|
922fe2 |
+++ b/dnf/transaction_sr.py
|
|
|
922fe2 |
@@ -416,6 +416,16 @@ class TransactionReplay(object):
|
|
|
922fe2 |
if swdb_group is not None:
|
|
|
922fe2 |
self._base.history.group.upgrade(swdb_group)
|
|
|
922fe2 |
|
|
|
922fe2 |
+ def _swdb_group_downgrade(self, group_id, pkg_types, pkgs):
|
|
|
922fe2 |
+ if not self._base.history.group.get(group_id):
|
|
|
922fe2 |
+ self._raise_or_warn(self._ignore_installed, _("Group id '%s' is not installed.") % group_id)
|
|
|
922fe2 |
+ return
|
|
|
922fe2 |
+
|
|
|
922fe2 |
+ swdb_group = self._create_swdb_group(group_id, pkg_types, pkgs)
|
|
|
922fe2 |
+
|
|
|
922fe2 |
+ if swdb_group is not None:
|
|
|
922fe2 |
+ self._base.history.group.downgrade(swdb_group)
|
|
|
922fe2 |
+
|
|
|
922fe2 |
def _swdb_group_remove(self, group_id, pkg_types, pkgs):
|
|
|
922fe2 |
if not self._base.history.group.get(group_id):
|
|
|
922fe2 |
self._raise_or_warn(self._ignore_installed, _("Group id '%s' is not installed.") % group_id)
|
|
|
922fe2 |
@@ -482,6 +492,16 @@ class TransactionReplay(object):
|
|
|
922fe2 |
if swdb_env is not None:
|
|
|
922fe2 |
self._base.history.env.upgrade(swdb_env)
|
|
|
922fe2 |
|
|
|
922fe2 |
+ def _swdb_environment_downgrade(self, env_id, pkg_types, groups):
|
|
|
922fe2 |
+ if not self._base.history.env.get(env_id):
|
|
|
922fe2 |
+ self._raise_or_warn(self._ignore_installed, _("Environment id '%s' is not installed.") % env_id)
|
|
|
922fe2 |
+ return
|
|
|
922fe2 |
+
|
|
|
922fe2 |
+ swdb_env = self._create_swdb_environment(env_id, pkg_types, groups)
|
|
|
922fe2 |
+
|
|
|
922fe2 |
+ if swdb_env is not None:
|
|
|
922fe2 |
+ self._base.history.env.downgrade(swdb_env)
|
|
|
922fe2 |
+
|
|
|
922fe2 |
def _swdb_environment_remove(self, env_id, pkg_types, groups):
|
|
|
922fe2 |
if not self._base.history.env.get(env_id):
|
|
|
922fe2 |
self._raise_or_warn(self._ignore_installed, _("Environment id '%s' is not installed.") % env_id)
|
|
|
922fe2 |
@@ -535,6 +555,8 @@ class TransactionReplay(object):
|
|
|
922fe2 |
self._swdb_group_install(group_id, pkg_types, group_data["packages"])
|
|
|
922fe2 |
elif action == "Upgrade":
|
|
|
922fe2 |
self._swdb_group_upgrade(group_id, pkg_types, group_data["packages"])
|
|
|
922fe2 |
+ elif action == "Downgraded":
|
|
|
922fe2 |
+ self._swdb_group_downgrade(group_id, pkg_types, group_data["packages"])
|
|
|
922fe2 |
elif action == "Removed":
|
|
|
922fe2 |
self._swdb_group_remove(group_id, pkg_types, group_data["packages"])
|
|
|
922fe2 |
else:
|
|
|
922fe2 |
@@ -564,6 +586,8 @@ class TransactionReplay(object):
|
|
|
922fe2 |
self._swdb_environment_install(env_id, pkg_types, env_data["groups"])
|
|
|
922fe2 |
elif action == "Upgrade":
|
|
|
922fe2 |
self._swdb_environment_upgrade(env_id, pkg_types, env_data["groups"])
|
|
|
922fe2 |
+ elif action == "Downgraded":
|
|
|
922fe2 |
+ self._swdb_environment_downgrade(env_id, pkg_types, env_data["groups"])
|
|
|
922fe2 |
elif action == "Removed":
|
|
|
922fe2 |
self._swdb_environment_remove(env_id, pkg_types, env_data["groups"])
|
|
|
922fe2 |
else:
|
|
|
922fe2 |
--
|
|
|
922fe2 |
2.37.1
|
|
|
922fe2 |
|