Blame SOURCES/oaa-1.2_warn-xorg.patch

eaead1
From 6c285154723f618675c3a216ce84b480d770c10d Mon Sep 17 00:00:00 2001
eaead1
From: =?UTF-8?q?Mat=C4=9Bj=20T=C3=BD=C4=8D?= <matyc@redhat.com>
eaead1
Date: Tue, 9 Jun 2020 16:56:32 +0200
eaead1
Subject: [PATCH 1/2] Address incompatible profiles and software selections.
eaead1
eaead1
This change introduces a mechanism that allows to vet packages marked for removal.
eaead1
Such package can now have a record in the ESSENTIAL_PACKAGES dict,
eaead1
that define whether the package is essential => cant be removed
eaead1
based on the environment and groups selected in the Software Selection Anaconda spoke.
eaead1
eaead1
In case when one first selects the profile and then changes the Software Selection
eaead1
to an incompatible setting, the Selection spoke will raise an error, as it already
eaead1
tries to apply the blacklist with its environment/groups.
eaead1
---
eaead1
 org_fedora_oscap/rule_handling.py | 38 +++++++++++++++++++++++++++----
eaead1
 1 file changed, 33 insertions(+), 5 deletions(-)
eaead1
eaead1
diff --git a/org_fedora_oscap/rule_handling.py b/org_fedora_oscap/rule_handling.py
eaead1
index cd67822..3728f89 100644
eaead1
--- a/org_fedora_oscap/rule_handling.py
eaead1
+++ b/org_fedora_oscap/rule_handling.py
eaead1
@@ -40,6 +40,12 @@
eaead1
 __all__ = ["RuleData"]
eaead1
 
eaead1
 
eaead1
+ESSENTIAL_PACKAGES = {
eaead1
+    "xorg-x11-server-common": {
eaead1
+        "env": ["graphical-server-environment", "workstation-product-environment"],
eaead1
+    }
eaead1
+}
eaead1
+
eaead1
 log = logging.getLogger("anaconda")
eaead1
 
eaead1
 _ = common._
eaead1
@@ -627,6 +633,20 @@ def __str__(self):
eaead1
 
eaead1
         return ret
eaead1
 
eaead1
+    def _package_is_essential(self, package_name, ksdata_packages):
eaead1
+        if package_name not in ESSENTIAL_PACKAGES:
eaead1
+            return False
eaead1
+        if package_name in ksdata_packages.packageList:
eaead1
+            return True
eaead1
+        selected_install_env = ksdata_packages.environment
eaead1
+        if selected_install_env in ESSENTIAL_PACKAGES[package_name].get("env"):
eaead1
+            return True
eaead1
+        selected_install_groups_names = {g.name for g in ksdata_packages.groupList}
eaead1
+        for g in ESSENTIAL_PACKAGES[package_name].get("groups", []):
eaead1
+            if g in selected_install_groups_names:
eaead1
+                return True
eaead1
+        return False
eaead1
+
eaead1
     def eval_rules(self, ksdata, storage, report_only=False):
eaead1
         """:see: RuleHandler.eval_rules"""
eaead1
 
eaead1
@@ -655,13 +675,21 @@ def eval_rules(self, ksdata, storage, report_only=False):
eaead1
                                         common.MESSAGE_TYPE_INFO, msg))
eaead1
 
eaead1
         # now do the same for the packages that should be excluded
eaead1
-
eaead1
         # add messages for the already excluded packages
eaead1
         for pkg in self._removed_pkgs:
eaead1
-            msg = _("package '%s' has been added to the list of excluded "
eaead1
-                    "packages" % pkg)
eaead1
-            messages.append(RuleMessage(self.__class__,
eaead1
-                                        common.MESSAGE_TYPE_INFO, msg))
eaead1
+            if self._package_is_essential(pkg, ksdata.packages):
eaead1
+                msg = _(
eaead1
+                    "package '{package}' has been added to the list "
eaead1
+                    "of excluded packages, but it can't be removed "
eaead1
+                    "from the current software selection without breaking the installation."
eaead1
+                    .format(package=pkg))
eaead1
+                messages.append(RuleMessage(self.__class__,
eaead1
+                                            common.MESSAGE_TYPE_FATAL, msg))
eaead1
+            else:
eaead1
+                msg = _("package '%s' has been added to the list of excluded "
eaead1
+                        "packages" % pkg)
eaead1
+                messages.append(RuleMessage(self.__class__,
eaead1
+                                            common.MESSAGE_TYPE_INFO, msg))
eaead1
 
eaead1
         # packages, that should be added
eaead1
         packages_to_remove = (pkg for pkg in self._remove_pkgs