From 29ace1069af657cecd2ca5b0cfbece494240dbbd Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Thu, 22 Jul 2021 14:32:55 -0400 Subject: [PATCH 1/5] deploy: Factor out stage commands Pull the stage commands out into deploy_main. For a given target, set the required stage commands, call the staging as needed, and then call the main worker function. This will allow multiple targets without redundent calls to stage. Signed-off-by: Jason Andryuk --- cmds/deploy | 68 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 39 insertions(+), 29 deletions(-) diff --git a/cmds/deploy b/cmds/deploy index f341ac4..5770e37 100755 --- a/cmds/deploy +++ b/cmds/deploy @@ -7,13 +7,6 @@ deploy_iso_legacy() { local iso_name="openxt-installer.iso" local iso_path="${DEPLOY_DIR}/${iso_name}" - # Prepare repository layout and write XC-{PACKAGE,REPOSITORY,SIGNATURE} - # meta files. - call_cmd "stage" "repository" - # Prepare ISO image layout. - # TODO: Amend syslinux files to reflect versions & such - call_cmd "stage" "iso" - if ! genisoimage -o "${iso_path}" \ -b "isolinux/isolinux.bin" -c "isolinux/boot.cat" \ -no-emul-boot \ @@ -44,13 +37,6 @@ deploy_iso() { return 1 fi - # Prepare repository layout and write XC-{PACKAGE,REPOSITORY,SIGNATURE} - # meta files. - call_cmd "stage" "repository" - # Prepare ISO image layout. - # TODO: Amend syslinux files to reflect versions & such - call_cmd "stage" "iso" - xorriso -as mkisofs \ -o "${iso_path}" \ -isohybrid-mbr "${STAGING_DIR}/iso/isolinux/isohdpfx.bin" \ @@ -76,10 +62,6 @@ deploy_iso() { # Usage: deploy_update # Run the required staging steps and generate the update tarball deploy_update() { - # Prepare repository layout and write XC-{PACKAGE,REPOSITORY,SIGNATURE} - # meta files. - call_cmd "stage" "repository" - tar -C "${STAGING_DIR}/repository" \ -cf "${DEPLOY_DIR}/update.tar" packages.main } @@ -95,10 +77,6 @@ __deploy_pxe() { local pxe_staging="${STAGING_DIR}/pxe" local repo_dst="" - # Prepare repository layout and write XC-{PACKAGE,REPOSITORY,SIGNATURE} - # meta files. - call_cmd "stage" "repository" - while getopts "hr:" opt; do case "${opt}" in h) deploy_pxe_usage 0 ;; @@ -131,9 +109,6 @@ __deploy_pxe() { fi } deploy_pxe() { - # Prepare PXE staging. - call_cmd "stage" "pxe" - __deploy_pxe "$@" } @@ -174,7 +149,45 @@ deploy_need_conf() { return 0; } # Deploy OpenXT on the selected installation media. deploy_main() { target="$1" - shift 1 + shift + local stage_repo=0 + local stage_iso=0 + local stage_pxe=0 + + case "${target}" in + "iso*") + check_cmd_version "${target}" + stage_repo=1 + stage_iso=1 + ;; + "pxe"*) + stage_repo=1 + stage_pxe=1 + ;; + "update") + stage_repo=1 + ;; + "help") deploy_usage 0 + return + ;; + esac + + if [ "$stage_repo" -eq 1 ] ; then + # Prepare repository layout and write XC-{PACKAGE,REPOSITORY,SIGNATURE} + # meta files. + call_cmd "stage" "repository" + fi + + if [ "$stage_iso" -eq 1 ] ; then + # Prepare ISO image layout. + # TODO: Amend syslinux files to reflect versions & such + call_cmd "stage" "iso" + fi + + if [ "$stage_pxe" -eq 1 ] ; then + # Prepare PXE staging. + call_cmd "stage" "pxe" + fi pushd "${TOP}/${BUILD_DIR}" >/dev/null @@ -186,9 +199,6 @@ deploy_main() { "pxe"*) deploy_pxe "$@" ;; "help") deploy_usage 0 ;; "update") deploy_update ;; - *) echo "Unknown staging command \`${target}'." >&2 - deploy_usage 1 - ;; esac popd >/dev/null From 58b3f2c00a9205ed1c728401a22243c78f98d3e0 Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Wed, 29 Sep 2021 08:25:55 -0400 Subject: [PATCH 2/5] config: Rename BUILD_DIR in build_env When bordel build is run, the bordel bash process sources build_env. build_env redefines BUILD_DIR to a different value than the main bordel process. This is fine when bordel just runs once, but it breaks if additional bordel commands are run within the bordel process. Rename to ABS_BUILD_DIR to avoid overwriting the desired BUILD_DIR value. This will allow batching up some bordel commands in subsequent changes. Signed-off-by: Jason Andryuk --- cmds/build | 1 + cmds/config | 8 ++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cmds/build b/cmds/build index d2eb746..67ef663 100755 --- a/cmds/build +++ b/cmds/build @@ -20,6 +20,7 @@ build_main() { pushd "${TOP}/${BUILD_DIR}" >/dev/null # Source build_env to get access to necessary OE variables. + # cd-s into BUILD_DIR.. after it redefined it. # shellcheck disable=SC1090 . "${TOP}/${BUILD_DIR}/build_env" diff --git a/cmds/config b/cmds/config index fc7cb89..b2e52b4 100755 --- a/cmds/config +++ b/cmds/config @@ -122,13 +122,13 @@ if [ "\$_" == "\$0" ]; then return 1 fi -BUILD_DIR="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" +ABS_BUILD_DIR="\$( cd "\$( dirname "\${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -BBPATH="\${BUILD_DIR}/layers/bitbake/bin:\${BUILD_DIR}/layers/openembedded-core/scripts:" +BBPATH="\${ABS_BUILD_DIR}/layers/bitbake/bin:\${ABS_BUILD_DIR}/layers/openembedded-core/scripts:" BB_ENV_EXTRAWHITE="MACHINE DISTRO BUILD_UID LAYERS_DIR" -LAYERS_DIR="\${BUILD_DIR}/layers" -BUILDDIR="\${BUILD_DIR}" +LAYERS_DIR="\${ABS_BUILD_DIR}/layers" +BUILDDIR="\${ABS_BUILD_DIR}" PATH=\$BBPATH\$(echo "\$PATH" | sed -e "s|:\$BBPATH|:|g" -e "s|^\$BBPATH||") unset BBPATH From c89e092cbdebc1b51fe668c56415f7209018468e Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Wed, 29 Sep 2021 08:36:18 -0400 Subject: [PATCH 3/5] deploy: Print build outputs Provide feedback on what has been built and where to find it. This makes it a little nicer for users. Also document the update command. Signed-off-by: Jason Andryuk --- cmds/deploy | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmds/deploy b/cmds/deploy index 5770e37..2234fff 100755 --- a/cmds/deploy +++ b/cmds/deploy @@ -57,6 +57,8 @@ deploy_iso() { -quiet \ "${STAGING_DIR}/iso" \ "${STAGING_DIR}/repository" + + echo "ISO created: $iso_path" } # Usage: deploy_update @@ -64,6 +66,8 @@ deploy_iso() { deploy_update() { tar -C "${STAGING_DIR}/repository" \ -cf "${DEPLOY_DIR}/update.tar" packages.main + + echo "OTA update tarball created: ${DEPLOY_DIR}/update.tar" } deploy_pxe_usage() { @@ -139,6 +143,7 @@ Deployment command list: pxe: Copy a PXE compatible OpenXT installer to the given [@]: tftp server, and setup the installer to fetch repository from + update: Create the update.tar OTA package. End-of-usage exit "${1:-0}" } From 1c3ef1d70812002e1b68fc40af55038aead74c85 Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Wed, 29 Sep 2021 08:38:21 -0400 Subject: [PATCH 4/5] deploy: Allow multiple targets We can make the deploy step deploy multiple targets in a single call with the earlier staging optimization. The wrinkle is the arguments to pxe. Therefore update and iso are pulled off the list. If pxe is found, parsing stops and all subsequent arguments are passed to the pxe subcommand. Signed-off-by: Jason Andryuk --- cmds/deploy | 67 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/cmds/deploy b/cmds/deploy index 2234fff..7155f85 100755 --- a/cmds/deploy +++ b/cmds/deploy @@ -144,6 +144,9 @@ Deployment command list: [@]: tftp server, and setup the installer to fetch repository from update: Create the update.tar OTA package. + +Multiple commands can be specified together. e.g. deploy update iso. +If pxe is used, it must be last. End-of-usage exit "${1:-0}" } @@ -153,29 +156,35 @@ deploy_need_conf() { return 0; } # Usage: deploy # Deploy OpenXT on the selected installation media. deploy_main() { - target="$1" - shift local stage_repo=0 local stage_iso=0 local stage_pxe=0 - case "${target}" in - "iso*") - check_cmd_version "${target}" - stage_repo=1 - stage_iso=1 - ;; - "pxe"*) - stage_repo=1 - stage_pxe=1 - ;; - "update") - stage_repo=1 - ;; - "help") deploy_usage 0 - return - ;; - esac + targets=() + for target in "$@" ; do + targets+=("$target") + shift + + case "${target}" in + iso*) + check_cmd_version "${target}" + stage_repo=1 + stage_iso=1 + ;; + pxe*) + stage_repo=1 + stage_pxe=1 + # break to maintain "$@" for deploy_pxe + break + ;; + update) + stage_repo=1 + ;; + help) deploy_usage 0 + return + ;; + esac + done if [ "$stage_repo" -eq 1 ] ; then # Prepare repository layout and write XC-{PACKAGE,REPOSITORY,SIGNATURE} @@ -196,15 +205,17 @@ deploy_main() { pushd "${TOP}/${BUILD_DIR}" >/dev/null - case "${target}" in - "iso-old") check_cmd_version "${target}" - deploy_iso_legacy "$@" ;; - "iso") check_cmd_version "${target}" - deploy_iso "$@" ;; - "pxe"*) deploy_pxe "$@" ;; - "help") deploy_usage 0 ;; - "update") deploy_update ;; - esac + for target in "${targets[@]}"; do + case "${target}" in + "iso-old") check_cmd_version "${target}" + deploy_iso_legacy ;; + "iso") check_cmd_version "${target}" + deploy_iso ;; + "pxe"*) deploy_pxe "$@" ;; + "help") deploy_usage 0 ;; + "update") deploy_update ;; + esac + done popd >/dev/null } From 3ded015872bc6fb942e10f95f7cadf7121101e91 Mon Sep 17 00:00:00 2001 From: Jason Andryuk Date: Wed, 29 Sep 2021 08:56:05 -0400 Subject: [PATCH 5/5] Add make command to build and deploy Often you want a single command to build and deploy the iso and upgrade tarball. Add it as "make" which just calls the other commands. Signed-off-by: Jason Andryuk --- cmds/make | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 cmds/make diff --git a/cmds/make b/cmds/make new file mode 100644 index 0000000..7f2b24e --- /dev/null +++ b/cmds/make @@ -0,0 +1,12 @@ +#! /bin/bash + +make_describe() { + echo "Build all the images and then deploy the iso and update." +} + +make_need_conf() { return 0; } + +make_main() { + call_cmd "build" + call_cmd "deploy" "iso" "update" +}