]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
UBUNTU: [Packaging] annotations: unify same rule across all flavour within the same...
authorAndrea Righi <andrea.righi@canonical.com>
Thu, 15 Dec 2022 08:03:22 +0000 (09:03 +0100)
committerAndrea Righi <andrea.righi@canonical.com>
Thu, 9 Mar 2023 14:58:15 +0000 (15:58 +0100)
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
debian/scripts/misc/kconfig/annotations.py

index 92167f806849aaa4510ef01419eb6c2dc439c9d1..e7eb42324666f058a16e1993116334e57f987cd9 100644 (file)
@@ -208,11 +208,30 @@ class Annotation(Config):
                     if self.config[conf]['policy'][flavour] == self.config[conf]['policy'][generic]:
                         del self.config[conf]['policy'][flavour]
                         continue
+            # Remove rules for flavours / arches that are not supported (not
+            # listed in the annotations header).
             for flavour in self.config[conf]['policy'].copy():
                 if flavour not in list(set(self.arch + self.flavour)):
                     del self.config[conf]['policy'][flavour]
+            # Drop empty rules
             if not self.config[conf]['policy']:
                 del self.config[conf]
+            else:
+                # Compact same value across all flavour within the same arch
+                for arch in self.arch:
+                    arch_flavours = [i for i in self.flavour if i.startswith(arch)]
+                    value = None
+                    for flavour in arch_flavours:
+                        if flavour not in self.config[conf]['policy']:
+                            break
+                        elif value is None:
+                            value = self.config[conf]['policy'][flavour]
+                        elif value != self.config[conf]['policy'][flavour]:
+                            break
+                    else:
+                        for flavour in arch_flavours:
+                            del self.config[conf]['policy'][flavour]
+                        self.config[conf]['policy'][arch] = value
 
     def save(self, fname: str):
         """ Save annotations data to the annotation file """