Update SWUpdate images for new autogen method
authorHugo Villeneuve <hugo@hugovil.com>
Wed, 28 Feb 2024 23:54:09 +0000 (18:54 -0500)
committerHugo Villeneuve <hugo@hugovil.com>
Tue, 28 May 2024 19:00:29 +0000 (15:00 -0400)
SWUpdate images are automatically generated by the top-level Makefile.

recipes-core/images/image-hvmpd-dev-update.bb [deleted file]
recipes-core/images/image-hvmpd-prod-update.bb [deleted file]
recipes-core/images/include/update-common.inc [new file with mode: 0644]
recipes-core/images/include/update/sw-description [new file with mode: 0644]
recipes-core/images/include/update/update.sh [new file with mode: 0644]
recipes-core/images/update-common.inc [deleted file]
recipes-core/images/update/sw-description [deleted file]
recipes-core/images/update/update.sh [deleted file]

diff --git a/recipes-core/images/image-hvmpd-dev-update.bb b/recipes-core/images/image-hvmpd-dev-update.bb
deleted file mode 100644 (file)
index f874b45..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-SUMMARY = "HV MPD SWUpdate development image"
-
-# Image(s) to build before building swupdate image
-IMAGE_DEPENDS = "image-hvmpd-dev"
-
-require update-common.inc
-
-SWUPDATE_IMAGES_FSTYPES[image-hvmpd-dev] = ".tar.gz"
diff --git a/recipes-core/images/image-hvmpd-prod-update.bb b/recipes-core/images/image-hvmpd-prod-update.bb
deleted file mode 100644 (file)
index 754da4d..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-SUMMARY = "HV MPD SWUpdate production image"
-
-# Image(s) to build before building swupdate image
-IMAGE_DEPENDS = "image-hvmpd-prod"
-
-require update-common.inc
-
-SWUPDATE_IMAGES_FSTYPES[image-hvmpd-prod] = ".tar.gz"
diff --git a/recipes-core/images/include/update-common.inc b/recipes-core/images/include/update-common.inc
new file mode 100644 (file)
index 0000000..ed80f58
--- /dev/null
@@ -0,0 +1,15 @@
+LICENSE = "CLOSED"
+
+FILESEXTRAPATHS:prepend := "${THISDIR}/update:"
+
+SRC_URI = " \
+    file://sw-description \
+    file://update.sh \
+"
+
+# Image(s) and files that will be included in the .swu image
+SWUPDATE_IMAGES = "${IMAGE_DEPENDS}"
+
+UBOOT_PART_VAR ?= "mmcpart"
+
+inherit swupdate
diff --git a/recipes-core/images/include/update/sw-description b/recipes-core/images/include/update/sw-description
new file mode 100644 (file)
index 0000000..78d91e9
--- /dev/null
@@ -0,0 +1,83 @@
+software = {
+       version = "@@DISTRO_VERSION@@";
+       description = "Firmware update description for @@MACHINE@@";
+
+       @@MACHINE@@ = {
+               hardware-compatibility: [ "revA" ];
+               stable: {
+                       bootenv-common: (
+                               {
+                                       name = "bootcount";
+                                       value = "0";
+                               },
+                               {
+                                       name = "upgrade_available";
+                                       value = "1";
+                               },
+                       );
+
+                       rootfsA: {
+                               images: (
+                                       {
+                                               filename = "@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@";
+                                               type = "archive";
+                                               compressed = "zlib";
+                                               preserve-attributes = true;
+                                               sha256 = "$swupdate_get_sha256(@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@)";
+                                               path = "/"; /* Destination path when decompressing. */
+                                               filesystem = "ext4";
+                                               device = "@@ROOT_PARENT_DEV@@@@ROOT_PART_PREFIX@@@@ROOT_PART_A_ID@@";
+                                       }
+                               );
+                               scripts: (
+                                       {
+                                               filename = "update.sh";
+                                               type = "shellscript";
+                                               data = "@@ROOT_PART_PREFIX@@@@ROOT_PART_A_ID@@"; /* Destination partition ID */
+                                               sha256 = "$swupdate_get_sha256(update.sh)";
+                                        }
+                                );
+                               bootenv: (
+                                       {
+                                               ref = "#./../bootenv-common";
+                                       },
+                                       {
+                                               name = "@@UBOOT_PART_VAR@@";
+                                               value = "@@ROOT_PART_A_ID@@";
+                                       }
+                               );
+                       };
+                       rootfsB: {
+                               images: (
+                                       {
+                                               filename = "@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@";
+                                               type = "archive";
+                                               compressed = "zlib";
+                                               preserve-attributes = true;
+                                               sha256 = "$swupdate_get_sha256(@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@)";
+                                               path = "/"; /* Destination path when decompressing. */
+                                               filesystem = "ext4";
+                                               device = "@@ROOT_PARENT_DEV@@@@ROOT_PART_PREFIX@@@@ROOT_PART_B_ID@@";
+                                       }
+                               );
+                               scripts: (
+                                       {
+                                               filename = "update.sh";
+                                               type = "shellscript";
+                                               data = "@@ROOT_PART_PREFIX@@@@ROOT_PART_B_ID@@"; /* Destination partition ID */
+                                               sha256 = "$swupdate_get_sha256(update.sh)";
+                                        }
+                                );
+                               bootenv: (
+                                       {
+                                               ref = "#./../bootenv-common";
+                                       },
+                                       {
+                                               name = "@@UBOOT_PART_VAR@@";
+                                               value = "@@ROOT_PART_B_ID@@";
+                                       }
+                               );
+                       };
+               };
+       };
+}
diff --git a/recipes-core/images/include/update/update.sh b/recipes-core/images/include/update/update.sh
new file mode 100644 (file)
index 0000000..6efa218
--- /dev/null
@@ -0,0 +1,90 @@
+#!/bin/sh
+set -e
+
+# Shell scripts are called via system command. SWUpdate scans for all scripts
+# and calls them before and after installing the images. SWUpdate passes
+# ‘preinst’ or ‘postinst’ as first argument to the script. If the data attribute
+# is defined, its value is passed as the last argument(s) to the script.
+
+FSTYPE="ext4"
+
+echo "${0}: arguments = \"${*}\""
+
+if [ $# -lt 2 ]; then
+    exit 1;
+fi
+
+# L'environnement U-Boot doit être valide pour utiliser ce script.
+# Après la programmation initiale avec uuu, il faut effectuer la sauvegarde
+# de l'environnement en mémoire non-volatile (ex: eMMC) dans U-boot avec
+# 'saveenv'. Sinon, fw_saveenv va utiliser l'environnement par défaut contenu
+# dans /etc/u-boot-initial-env
+if fw_printenv 2>&1 | grep -q 'Cannot read environment'; then
+    echo "Warning: U-Boot environment cannot be read. Make sure you save the"
+    echo "         default environment to flash using these U-Boot commands:"
+    echo "             $> env default -a"
+    echo "             $> saveenv"
+fi
+
+do_preinst()
+{
+    # Find internal parent kernel device name of rootfs.
+    # For example:
+    # - /dev/sda1 --> /dev/sda
+    # - /dev/mmcblk2p2 --> /dev/mmcblk2
+    disk="/dev/$(lsblk -ndo pkname $(findmnt -n -o SOURCE /))"
+
+    if [ ! -b "${disk}" ]; then
+        echo "Error: disk \"${disk}\" not found"
+        exit 1
+    fi
+
+    update_dev="${disk}${next_part}"
+
+    if [ ! -b "${update_dev}" ]; then
+        echo "Error: destination partition \"${update_dev}\" not found"
+        exit 1
+    fi
+
+    echo "${0}: destination device = ${update_dev}"
+
+    # Create temporary mount point:
+    tmp_file=$(mktemp -q -d /tmp/swupdate-mount.XXXXXX)
+    if [ ${?} -ne 0 ]; then
+        echo "Error: cannot create temporary file"
+        exit 1
+    fi
+
+    # Mount update partition:
+    mount -t ${FSTYPE} ${update_dev} ${tmp_file}
+
+    # Remove old data:
+    echo "${0}: erasing old data..."
+    rm -rf ${tmp_file}/*
+
+    # Finish
+    umount ${tmp_file}
+    rmdir ${tmp_file}
+
+    exit 0
+}
+
+do_postinst()
+{
+    exit 0
+}
+
+next_part=${2}
+
+case "$1" in
+    preinst)
+        do_preinst
+        ;;
+    postinst)
+        do_postinst
+        ;;
+    *)
+        echo "unsupported install mode: \"${1}\""
+        exit 1
+        ;;
+esac
diff --git a/recipes-core/images/update-common.inc b/recipes-core/images/update-common.inc
deleted file mode 100644 (file)
index ed80f58..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-LICENSE = "CLOSED"
-
-FILESEXTRAPATHS:prepend := "${THISDIR}/update:"
-
-SRC_URI = " \
-    file://sw-description \
-    file://update.sh \
-"
-
-# Image(s) and files that will be included in the .swu image
-SWUPDATE_IMAGES = "${IMAGE_DEPENDS}"
-
-UBOOT_PART_VAR ?= "mmcpart"
-
-inherit swupdate
diff --git a/recipes-core/images/update/sw-description b/recipes-core/images/update/sw-description
deleted file mode 100644 (file)
index 78d91e9..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-software = {
-       version = "@@DISTRO_VERSION@@";
-       description = "Firmware update description for @@MACHINE@@";
-
-       @@MACHINE@@ = {
-               hardware-compatibility: [ "revA" ];
-               stable: {
-                       bootenv-common: (
-                               {
-                                       name = "bootcount";
-                                       value = "0";
-                               },
-                               {
-                                       name = "upgrade_available";
-                                       value = "1";
-                               },
-                       );
-
-                       rootfsA: {
-                               images: (
-                                       {
-                                               filename = "@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@";
-                                               type = "archive";
-                                               compressed = "zlib";
-                                               preserve-attributes = true;
-                                               sha256 = "$swupdate_get_sha256(@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@)";
-                                               path = "/"; /* Destination path when decompressing. */
-                                               filesystem = "ext4";
-                                               device = "@@ROOT_PARENT_DEV@@@@ROOT_PART_PREFIX@@@@ROOT_PART_A_ID@@";
-                                       }
-                               );
-                               scripts: (
-                                       {
-                                               filename = "update.sh";
-                                               type = "shellscript";
-                                               data = "@@ROOT_PART_PREFIX@@@@ROOT_PART_A_ID@@"; /* Destination partition ID */
-                                               sha256 = "$swupdate_get_sha256(update.sh)";
-                                        }
-                                );
-                               bootenv: (
-                                       {
-                                               ref = "#./../bootenv-common";
-                                       },
-                                       {
-                                               name = "@@UBOOT_PART_VAR@@";
-                                               value = "@@ROOT_PART_A_ID@@";
-                                       }
-                               );
-                       };
-                       rootfsB: {
-                               images: (
-                                       {
-                                               filename = "@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@";
-                                               type = "archive";
-                                               compressed = "zlib";
-                                               preserve-attributes = true;
-                                               sha256 = "$swupdate_get_sha256(@@IMAGE_DEPENDS@@-@@MACHINE@@@@SWUPDATE_IMAGES_FSTYPES[@@IMAGE_DEPENDS@@]@@)";
-                                               path = "/"; /* Destination path when decompressing. */
-                                               filesystem = "ext4";
-                                               device = "@@ROOT_PARENT_DEV@@@@ROOT_PART_PREFIX@@@@ROOT_PART_B_ID@@";
-                                       }
-                               );
-                               scripts: (
-                                       {
-                                               filename = "update.sh";
-                                               type = "shellscript";
-                                               data = "@@ROOT_PART_PREFIX@@@@ROOT_PART_B_ID@@"; /* Destination partition ID */
-                                               sha256 = "$swupdate_get_sha256(update.sh)";
-                                        }
-                                );
-                               bootenv: (
-                                       {
-                                               ref = "#./../bootenv-common";
-                                       },
-                                       {
-                                               name = "@@UBOOT_PART_VAR@@";
-                                               value = "@@ROOT_PART_B_ID@@";
-                                       }
-                               );
-                       };
-               };
-       };
-}
diff --git a/recipes-core/images/update/update.sh b/recipes-core/images/update/update.sh
deleted file mode 100644 (file)
index 6efa218..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-#!/bin/sh
-set -e
-
-# Shell scripts are called via system command. SWUpdate scans for all scripts
-# and calls them before and after installing the images. SWUpdate passes
-# ‘preinst’ or ‘postinst’ as first argument to the script. If the data attribute
-# is defined, its value is passed as the last argument(s) to the script.
-
-FSTYPE="ext4"
-
-echo "${0}: arguments = \"${*}\""
-
-if [ $# -lt 2 ]; then
-    exit 1;
-fi
-
-# L'environnement U-Boot doit être valide pour utiliser ce script.
-# Après la programmation initiale avec uuu, il faut effectuer la sauvegarde
-# de l'environnement en mémoire non-volatile (ex: eMMC) dans U-boot avec
-# 'saveenv'. Sinon, fw_saveenv va utiliser l'environnement par défaut contenu
-# dans /etc/u-boot-initial-env
-if fw_printenv 2>&1 | grep -q 'Cannot read environment'; then
-    echo "Warning: U-Boot environment cannot be read. Make sure you save the"
-    echo "         default environment to flash using these U-Boot commands:"
-    echo "             $> env default -a"
-    echo "             $> saveenv"
-fi
-
-do_preinst()
-{
-    # Find internal parent kernel device name of rootfs.
-    # For example:
-    # - /dev/sda1 --> /dev/sda
-    # - /dev/mmcblk2p2 --> /dev/mmcblk2
-    disk="/dev/$(lsblk -ndo pkname $(findmnt -n -o SOURCE /))"
-
-    if [ ! -b "${disk}" ]; then
-        echo "Error: disk \"${disk}\" not found"
-        exit 1
-    fi
-
-    update_dev="${disk}${next_part}"
-
-    if [ ! -b "${update_dev}" ]; then
-        echo "Error: destination partition \"${update_dev}\" not found"
-        exit 1
-    fi
-
-    echo "${0}: destination device = ${update_dev}"
-
-    # Create temporary mount point:
-    tmp_file=$(mktemp -q -d /tmp/swupdate-mount.XXXXXX)
-    if [ ${?} -ne 0 ]; then
-        echo "Error: cannot create temporary file"
-        exit 1
-    fi
-
-    # Mount update partition:
-    mount -t ${FSTYPE} ${update_dev} ${tmp_file}
-
-    # Remove old data:
-    echo "${0}: erasing old data..."
-    rm -rf ${tmp_file}/*
-
-    # Finish
-    umount ${tmp_file}
-    rmdir ${tmp_file}
-
-    exit 0
-}
-
-do_postinst()
-{
-    exit 0
-}
-
-next_part=${2}
-
-case "$1" in
-    preinst)
-        do_preinst
-        ;;
-    postinst)
-        do_postinst
-        ;;
-    *)
-        echo "unsupported install mode: \"${1}\""
-        exit 1
-        ;;
-esac