From 268ce4e257b9af354a086b729b2d4af52105cf8f Mon Sep 17 00:00:00 2001
From: Lorenzo Pagliai <lorenzo.pagliai@seco.com>
Date: Fri, 17 Feb 2023 11:13:25 +0100
Subject: [PATCH] [FS DEPLOY] Insert fs deploy to Azure

* Change "edgehog-base-image" label to "edgehog-things-image" one
* Fix on intel_apl config file
* Fix on AZURE_PATH variable (the edgehog folder is necessary
for the public container release)
---
 boards/.a62.yml             |  2 +-
 boards/.c20.yml             |  2 +-
 boards/.c31.yml             |  2 +-
 boards/.intel_apl.yml       |  7 +++-
 boards/.tanaro.yml          |  2 +-
 manifest-pipeline-yocto.yml | 66 +++++++++++++++++++++----------------
 6 files changed, 47 insertions(+), 34 deletions(-)

diff --git a/boards/.a62.yml b/boards/.a62.yml
index dc93cd6..c410f6c 100644
--- a/boards/.a62.yml
+++ b/boards/.a62.yml
@@ -22,7 +22,7 @@ deploy-edgehog-a62:
       UBOOT_FILE: u-boot.imx
       KERNEL_FILE: zImage
       AZURE_PATH: imx6/a62
-      IMAGE_NAME: edgehog-base-image
+      IMAGE_NAME: edgehog-things-image
 
 #############################
 ### EDGEHOG EMBEDDED BASE ###
diff --git a/boards/.c20.yml b/boards/.c20.yml
index 4e1c5c4..5244bb6 100644
--- a/boards/.c20.yml
+++ b/boards/.c20.yml
@@ -21,7 +21,7 @@ deploy-edgehog-c20:
       UBOOT_FILE: u-boot.bin
       KERNEL_FILE: Image
       AZURE_PATH: imx8/c20
-      IMAGE_NAME: edgehog-base-image
+      IMAGE_NAME: edgehog-things-image
 
 #############################
 ### EDGEHOG EMBEDDED BASE ###
diff --git a/boards/.c31.yml b/boards/.c31.yml
index 494d838..246aa19 100644
--- a/boards/.c31.yml
+++ b/boards/.c31.yml
@@ -21,7 +21,7 @@ deploy-edgehog-c31:
       UBOOT_FILE: uboot.img
       KERNEL_FILE: Image
       AZURE_PATH: rockchip/c31
-      IMAGE_NAME: edgehog-base-image
+      IMAGE_NAME: edgehog-things-image
 
 #############################
 ### EDGEHOG EMBEDDED BASE ###
diff --git a/boards/.intel_apl.yml b/boards/.intel_apl.yml
index b5e1602..44003fe 100644
--- a/boards/.intel_apl.yml
+++ b/boards/.intel_apl.yml
@@ -1,3 +1,7 @@
+########################
+#### EDGEHOG THINGS ####
+########################
+
 build-edgehog-intel-apl:
   extends: .build
   variables: &build-edgehog-intel-apl
@@ -16,4 +20,5 @@ deploy-edgehog-intel-apl:
       <<: *build-edgehog-intel-apl
       UBOOT_FILE: none
       KERNEL_FILE: none
-      AZURE_PATH: apollolake/Yocto 
\ No newline at end of file
+      AZURE_PATH: apollolake/Yocto
+      IMAGE_NAME: edgehog-things-image
\ No newline at end of file
diff --git a/boards/.tanaro.yml b/boards/.tanaro.yml
index 61667dd..fbb03b2 100644
--- a/boards/.tanaro.yml
+++ b/boards/.tanaro.yml
@@ -21,7 +21,7 @@ deploy-edgehog-tanaro:
     UBOOT_FILE: u-boot.bin
     KERNEL_FILE: Image
     AZURE_PATH: imx8/tanaro
-    IMAGE_NAME: edgehog-base-image
+    IMAGE_NAME: edgehog-things-image
 
 #############################
 ### EDGEHOG EMBEDDED BASE ###
diff --git a/manifest-pipeline-yocto.yml b/manifest-pipeline-yocto.yml
index 0cfb4b7..62e7ad1 100644
--- a/manifest-pipeline-yocto.yml
+++ b/manifest-pipeline-yocto.yml
@@ -264,6 +264,7 @@ retrigger:
           TAG_NAME=${CI_COMMIT_TAG}
           AZURE_STORAGE_SAS_TOKEN="${AZURE_STORAGE_PUBLIC_SAS_TOKEN}"
           AZURE_CONTAINER_NAME="${AZURE_PUBLIC_CONTAINER_NAME}"
+          AZURE_PATH="${AZURE_PATH}/edgehog"
         fi
       - |
          uboot_filename="seco_"$PROCESSOR"_"$BOARD"_uboot_"$KERNEL"_"$TAG_NAME"_"$DEPLOY_DATE".tar.gz"
@@ -359,27 +360,27 @@ retrigger:
                                echo "Finishing Kernel upload";;         
             esac       
 
-            # echo "##################################################################"
-            # echo "######################  FILESYSTEM  ##############################"
-            # echo "##################################################################"
-            # find $BASE_DIRECTORY/$ART_PATH -iname *."$FS_EXTENSION" \
-            #                                -exec cp -L {} $BASE_DIRECTORY/filesystemTMP.tar.bz2 \;
-            # mv filesystemTMP.tar.bz2 $BASE_DIRECTORY/$filesystem_name
-            # az storage blob upload --account-name $AZURE_STORAGE_ACCOUNT \
-            #                        --sas-token $AZURE_STORAGE_SAS_TOKEN \
-            #                        --container-name $AZURE_CONTAINER_NAME \
-            #                        --file $BASE_DIRECTORY/$filesystem_name \
-            #                        --name $AZURE_PATH/$TAG_NAME/$filesystem_name \
-            #                        --overwrite
-
-            # if [ ! -n "$CI_COMMIT_TAG" ]; then
-            # az storage blob upload --account-name $AZURE_STORAGE_ACCOUNT \
-            #                        --sas-token $AZURE_STORAGE_SAS_TOKEN \
-            #                        --container-name $AZURE_CONTAINER_NAME \
-            #                        --file $BASE_DIRECTORY/$filesystem_name \
-            #                        --name $AZURE_PATH/$TAG_NAME/$filesystem_name_latest \
-            #                        --overwrite
-            # fi
+            echo "##################################################################"
+            echo "######################  FILESYSTEM  ##############################"
+            echo "##################################################################"
+            find $BASE_DIRECTORY/$ART_PATH -iname *."$FS_EXTENSION" \
+                                           -exec cp -L {} $BASE_DIRECTORY/filesystemTMP.tar.bz2 \;
+            mv filesystemTMP.tar.bz2 $BASE_DIRECTORY/$filesystem_name
+            az storage blob upload --account-name $AZURE_STORAGE_ACCOUNT \
+                                   --sas-token $AZURE_STORAGE_SAS_TOKEN \
+                                   --container-name $AZURE_CONTAINER_NAME \
+                                   --file $BASE_DIRECTORY/$filesystem_name \
+                                   --name $AZURE_PATH/$TAG_NAME/$filesystem_name \
+                                   --overwrite
+
+            if [ ! -n "$CI_COMMIT_TAG" ]; then
+              az storage blob upload --account-name $AZURE_STORAGE_ACCOUNT \
+                                     --sas-token $AZURE_STORAGE_SAS_TOKEN \
+                                     --container-name $AZURE_CONTAINER_NAME \
+                                     --file $BASE_DIRECTORY/$filesystem_name \
+                                     --name $AZURE_PATH/$TAG_NAME/$filesystem_name_latest \
+                                     --overwrite
+            fi
 
             echo "##################################################################"
             echo "#######################  BUNDLE FILE  ############################"
@@ -467,6 +468,7 @@ retrigger:
           TAG_NAME=${CI_COMMIT_TAG}
           AZURE_STORAGE_SAS_TOKEN="${AZURE_STORAGE_PUBLIC_SAS_TOKEN}"
           AZURE_CONTAINER_NAME="${AZURE_PUBLIC_CONTAINER_NAME}"
+          AZURE_PATH="${AZURE_PATH}/edgehog"
         fi
 
         echo "##################################################################" >> Link_report_$BOARD.txt
@@ -488,20 +490,24 @@ retrigger:
         bundle_filename_latest="seco_"$PROCESSOR"_"$BOARD"_edgehog-bundle_"$KERNEL"_"$TAG_NAME"_latest.raucb"
 
         if [ "$CI_JOB_STATUS" == "success" ]; then
-            echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$uboot_filename) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
-            echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$kernel_filename) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
-            # echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$filesystem_name) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
+            if [[ "${CI_JOB_NAME}" != *"embedded"* ]]; then
+              echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$uboot_filename) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
+              echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$kernel_filename) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
+              echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$bundle_filename) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
+            fi
+            echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$filesystem_name) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
             echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$image_name) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
             echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$bmap_name) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
-            echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$bundle_filename) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
 
             if [ ! -n "$CI_COMMIT_TAG" ]; then
-              echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$uboot_filename_latest) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
-              echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$kernel_filename_latest) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
-              # echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$filesystem_name_latest) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
+              if [[ "${CI_JOB_NAME}" != *"embedded"* ]]; then
+                echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$uboot_filename_latest) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
+                echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$kernel_filename_latest) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
+                echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$bundle_filename_latest) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
+              fi
+              echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$filesystem_name_latest) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
               echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$image_name_latest) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
               echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$bmap_name_latest) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
-              echo -e $(az storage blob url --container-name $AZURE_CONTAINER_NAME --name $AZURE_PATH/$TAG_NAME/$bundle_filename_latest) | sed -E 's/\?s.*//' >> Link_report_$BOARD.txt
             fi
         else
             echo -e "JOBS FAILED" >> Link_report_$BOARD.txt
@@ -630,6 +636,8 @@ release:
     - if: $CI_COMMIT_TAG
   script:
     -  |
+        cat Link_report.txt
+        cat changelog_link.txt
         rm -rf release.sh
         echo "#!/bin/bash" >> release.sh 
         echo "" >> release.sh
-- 
GitLab