Blame SOURCES/oaa-1.2_warn-xorg.patch

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