From 74643665ec113143bd46378601a733b81580b078 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jonas=20H=C3=B6ppner?= <jonas.hoeppner@garz-fricke.com>
Date: Wed, 23 Feb 2022 10:38:57 +0100
Subject: [PATCH] alphaplan_fwr: Create u-boot package from imx-boot.tar.gz if
 found

The main install file for u-boot changed to imx-boot.tar.gz, so this
should be added to alphaplan. Leaving the imx-boot implementation
as fallback.

BCS 746-000600
---
 alphaplan_fwr.py  | 23 ++++++++++++++++-------
 alphaplan_keys.py | 12 ++++++++++++
 2 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/alphaplan_fwr.py b/alphaplan_fwr.py
index c1231431..7cee5129 100755
--- a/alphaplan_fwr.py
+++ b/alphaplan_fwr.py
@@ -85,6 +85,7 @@ def generate_ap_subarticle(
     ap_dict = get_ap_dict(machine, machine_ap, release_name_ap)
     # Match artifacts and get path and md5sum
     for artifact in artifacts:
+        # Compare the artifact with the match from ap_key
         if artifact.casefold().endswith(ap_dict[ap_key][ApSubKeys.MATCH].casefold()):
             path = os.path.join(output_dir, machine, artifact)
             path = os.path.join(*(path.split(os.path.sep)[2:]))
@@ -161,13 +162,21 @@ def generate_fwr_articles(
             attribute,
             stueckliste=stueckliste,
         )
-        # If imx-boot is in artifacts_all (TANARO), add an uboot FWR package
-        if "imx-boot" in artifacts_all:
-            subarticles_uboot = [
-                ApKeys.FNGSYS_UBOOT_UPDATE,
-                ApKeys.FNGSYS_UBOOT_IMAGE,
-                ApKeys.FNGSYS_UBOOT_CHECKSUM,
-            ]
+        # If imx-boot.tar.gz or deprecated imx-boot is in artifacts_all (imx8mX)i
+        # add an uboot FWR package
+        if "imx-boot.tar.gz" in artifacts_all or "imx-boot" in artifacts_all:
+            if "imx-boot.tar.gz" in artifacts_all:
+                subarticles_uboot = [
+                    ApKeys.FNGSYS_UBOOT_UPDATE,
+                    ApKeys.FNGSYS_UBOOT_IMAGETAR,
+                ]
+            # this is not needed if the above tar.gz is used.
+            elif "imx-boot" in artifacts_all:
+                subarticles_uboot = [
+                    ApKeys.FNGSYS_UBOOT_UPDATE,
+                    ApKeys.FNGSYS_UBOOT_IMAGE,
+                    ApKeys.FNGSYS_UBOOT_CHECKSUM,
+                ]
             stueckliste_uboot = []
             for key in subarticles_uboot:
                 stueckliste_uboot.append(
diff --git a/alphaplan_keys.py b/alphaplan_keys.py
index 45bba3ac..0b5e3293 100755
--- a/alphaplan_keys.py
+++ b/alphaplan_keys.py
@@ -16,6 +16,7 @@ class ApKeys(Flag):
     FNGSYS_UBOOT_UPDATE = auto()
     FNGSYS_UBOOT_IMAGE = auto()
     FNGSYS_UBOOT_CHECKSUM = auto()
+    FNGSYS_UBOOT_IMAGETAR = auto()
 
 
 class ApSubKeys(Flag):
@@ -133,6 +134,17 @@ def get_ap_dict(machine, machine_ap, release_name_local):
         ApSubKeys.ATTRIBUTESET: "Firmware, Bestandteil eines SW-Paketes",
     }
 
+    ap_dict[ApKeys.FNGSYS_UBOOT_IMAGETAR] = {
+        ApSubKeys.MATCH: "imx-boot.tar.gz",
+        ApSubKeys.MATCHCODE: "FS",
+        ApSubKeys.BEZEICHNUNG: "{} U-Boot {} Bootloader Image".format(
+            machine_ap, release_name_local
+        ),
+        ApSubKeys.LANGTEXT: "",
+        ApSubKeys.TYP: "FS",
+        ApSubKeys.ATTRIBUTESET: "Firmware, Bestandteil eines SW-Paketes",
+    }
+
     ap_dict[ApKeys.FNGSYS_UBOOT_CHECKSUM] = {
         ApSubKeys.MATCH: "imx-boot.md5",
         ApSubKeys.MATCHCODE: "TFTP",
-- 
GitLab