meta-digi-dey: swupdate-images: add SWUpdate script support
Enable scripting support during the installation of system images with SWU. A new shell script is included by default in all the SWU update packages that will be executed just before the update starts and just after it finishes. The script is empty and contains two place-holders that will be called in the two scenarios mentioned before. Users can customize this script to execute specific actions based on their final product needs or provide their own one by setting its location in the 'SWUPDATE_SCRIPT' variable. While on it, rename the 'sw-description_template' file to 'sw-description-images_template' as it is more accurate with the update mechanism it is used for. Signed-off-by: David Escalona <david.escalona@digi.com>
This commit is contained in:
parent
1e5bd003bd
commit
4395fa1f11
|
|
@ -8,6 +8,12 @@ software =
|
|||
images: (
|
||||
##IMAGES_PRIMARY##
|
||||
);
|
||||
scripts: (
|
||||
{
|
||||
filename = "@@SWUPDATE_SCRIPT_NAME@@";
|
||||
type = "shellscript";
|
||||
}
|
||||
);
|
||||
uboot: (
|
||||
{
|
||||
name = "upgrade_available";
|
||||
|
|
@ -23,6 +29,12 @@ software =
|
|||
images: (
|
||||
##IMAGES_SECONDARY##
|
||||
);
|
||||
scripts: (
|
||||
{
|
||||
filename = "@@SWUPDATE_SCRIPT_NAME@@";
|
||||
type = "shellscript";
|
||||
}
|
||||
);
|
||||
uboot: (
|
||||
{
|
||||
name = "upgrade_available";
|
||||
|
|
@ -38,6 +50,12 @@ software =
|
|||
images: (
|
||||
##IMAGES_SINGLE##
|
||||
);
|
||||
scripts: (
|
||||
{
|
||||
filename = "@@SWUPDATE_SCRIPT_NAME@@";
|
||||
type = "shellscript";
|
||||
}
|
||||
);
|
||||
uboot: (
|
||||
{
|
||||
name = "rootfstype"
|
||||
|
|
@ -0,0 +1,39 @@
|
|||
#!/bin/sh
|
||||
#===============================================================================
|
||||
#
|
||||
# update_images
|
||||
#
|
||||
# Copyright (C) 2023 by Digi International Inc.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify it
|
||||
# under the terms of the GNU General Public License version 2 as published by
|
||||
# the Free Software Foundation.
|
||||
#
|
||||
#
|
||||
# !Description: SWU update images script
|
||||
#
|
||||
#===============================================================================
|
||||
|
||||
# Sanity check. This script should be always executed with at least one argument.
|
||||
if [ $# -lt 1 ]; then
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Called just before installation process starts.
|
||||
if [ "${1}" = "preinst" ]; then
|
||||
:
|
||||
|
||||
# TODO: Execute custom code here. For example:
|
||||
# - Mount additional devices/partitions.
|
||||
# - Stop services/process before installing files.
|
||||
fi
|
||||
|
||||
# Called just after installation process ends.
|
||||
if [ "${1}" = "postinst" ]; then
|
||||
:
|
||||
|
||||
# TODO: Execute custom code here. For example:
|
||||
# - Clean files/directories.
|
||||
# - Post-process files.
|
||||
fi
|
||||
|
|
@ -6,12 +6,13 @@ LICENSE = "GPL-2.0-only"
|
|||
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/GPL-2.0-only;md5=801f80980d171dd6425610833a22dbe6"
|
||||
|
||||
SRC_URI = " \
|
||||
file://sw-description_template \
|
||||
file://sw-description-images_template \
|
||||
file://sw-description-uboot \
|
||||
file://swupdate_uboot_nand.sh \
|
||||
file://swupdate_uboot_mmc.sh \
|
||||
file://image_template_mmc \
|
||||
file://image_template_nand \
|
||||
file://update_images.sh \
|
||||
"
|
||||
|
||||
inherit swupdate
|
||||
|
|
@ -71,6 +72,11 @@ ROOTFS_TYPE = "${@bb.utils.contains('IMAGE_FEATURES', 'read-only-rootfs', 'squas
|
|||
# Image template based on storage type.
|
||||
IMAGE_TEMPLATE_FILE = "${@bb.utils.contains('STORAGE_MEDIA', 'mmc', '${WORKDIR}/image_template_mmc', '${WORKDIR}/image_template_nand', d)}"
|
||||
|
||||
# Update script.
|
||||
SWUPDATE_SCRIPT ?= "${WORKDIR}/update_images.sh"
|
||||
SWUPDATE_SCRIPT_NAME = "${@os.path.basename(d.getVar('SWUPDATE_SCRIPT'))}"
|
||||
SWUPDATE_IMAGES += " ${SWUPDATE_SCRIPT_NAME}"
|
||||
|
||||
do_unpack[postfuncs] += "fill_description"
|
||||
|
||||
fill_description() {
|
||||
|
|
@ -86,7 +92,12 @@ fill_description() {
|
|||
sed -i -e "s,##SWUPDATE_UBOOT_SCRIPT##,${SWUPDATE_UBOOT_SCRIPT},g" "${WORKDIR}/sw-description"
|
||||
sed -i -e "s,##UBOOTIMG_OFFSET##,${UBOOTIMG_OFFSET},g" "${WORKDIR}/sw-description"
|
||||
else
|
||||
cp ${WORKDIR}/sw-description_template ${WORKDIR}/sw-description
|
||||
cp ${WORKDIR}/sw-description-images_template ${WORKDIR}/sw-description
|
||||
fi
|
||||
|
||||
# Copy update script.
|
||||
if [ -f "${SWUPDATE_SCRIPT}" ]; then
|
||||
cp "${SWUPDATE_SCRIPT}" "${DEPLOY_DIR_IMAGE}"
|
||||
fi
|
||||
|
||||
# Build image names.
|
||||
|
|
|
|||
Loading…
Reference in New Issue