From 4771e4dc37231f80f91e53ec4c11fba28c71065b Mon Sep 17 00:00:00 2001 From: Michal Toman Date: Fri, 20 Nov 2020 15:33:50 +0100 Subject: [PATCH 1/3] jenkins_build.sh: rename resin-flasher.img to balena-flasher.img Change-type: patch Signed-off-by: Michal Toman --- automation/jenkins_build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/automation/jenkins_build.sh b/automation/jenkins_build.sh index 96a5eeab0..87ed4bb7d 100755 --- a/automation/jenkins_build.sh +++ b/automation/jenkins_build.sh @@ -88,7 +88,7 @@ deploy_build () { # uncompressed, just copy and we're done cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_artifact") "$_deploy_dir/image/balena.img" if [ -n "$_deploy_flasher_artifact" ]; then - cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_flasher_artifact") "$_deploy_dir/image/resin-flasher.img" + cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_flasher_artifact") "$_deploy_dir/image/balena-flasher.img" fi return fi @@ -107,12 +107,12 @@ deploy_build () { cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_artifact") "$_deploy_dir/image/balena.img" (cd "$_deploy_dir/image" && zip balena.img.zip balena.img) if [ -n "$_deploy_flasher_artifact" ]; then - cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_flasher_artifact") "$_deploy_dir/image/resin-flasher.img" - (cd "$_deploy_dir/image" && zip resin-flasher.img.zip resin-flasher.img) + cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_flasher_artifact") "$_deploy_dir/image/balena-flasher.img" + (cd "$_deploy_dir/image" && zip balena-flasher.img.zip balena-flasher.img) fi if [ "$_remove_compressed_file" = "true" ]; then rm -rf $_deploy_dir/image/balena.img - rm -rf $_deploy_dir/image/resin-flasher.img + rm -rf $_deploy_dir/image/balena-flasher.img fi fi From 9b5f5d2fe35dbf3ea357468d1874b9765bec3ae1 Mon Sep 17 00:00:00 2001 From: Michal Toman Date: Fri, 20 Nov 2020 15:59:43 +0100 Subject: [PATCH 2/3] jenkins_build.sh: publish explicitly named balena-raw and balena-flasher images At this moment we are providing a single balena.img file that is either raw or flasher based on the coffee script. We want to publish both for some device types, therefore split the single file into balena-raw.img and balena-flasher.img. Temporarily keep the existing balena.img for backwards compatibility until all coffee scripts are updated and image maker is aware of the split. Change-type: minor Signed-off-by: Michal Toman --- automation/jenkins_build.sh | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/automation/jenkins_build.sh b/automation/jenkins_build.sh index 87ed4bb7d..5ebbc16d4 100755 --- a/automation/jenkins_build.sh +++ b/automation/jenkins_build.sh @@ -88,7 +88,13 @@ deploy_build () { # uncompressed, just copy and we're done cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_artifact") "$_deploy_dir/image/balena.img" if [ -n "$_deploy_flasher_artifact" ]; then + cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-raw.img" cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_flasher_artifact") "$_deploy_dir/image/balena-flasher.img" + elif [ "$_image" = "resin-image-flasher" ]; then + # backwards compatibility - deployFlasherArtifact is not set and deployArtifact contains flasher + cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-flasher.img" + else + cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-raw.img" fi return fi @@ -107,11 +113,21 @@ deploy_build () { cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_artifact") "$_deploy_dir/image/balena.img" (cd "$_deploy_dir/image" && zip balena.img.zip balena.img) if [ -n "$_deploy_flasher_artifact" ]; then + cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-raw.img" + (cd "$_deploy_dir/image" && zip balena-raw.img.zip balena-raw.img) cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_flasher_artifact") "$_deploy_dir/image/balena-flasher.img" (cd "$_deploy_dir/image" && zip balena-flasher.img.zip balena-flasher.img) + elif [ "$_image" = "resin-image-flasher" ]; then + # backwards compatibility - deployFlasherArtifact is not set and deployArtifact contains flasher + cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-flasher.img" + (cd "$_deploy_dir/image" && zip balena-flasher.img.zip balena-flasher.img) + else + cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-raw.img" + (cd "$_deploy_dir/image" && zip balena-raw.img.zip balena-raw.img) fi if [ "$_remove_compressed_file" = "true" ]; then rm -rf $_deploy_dir/image/balena.img + rm -rf $_deploy_dir/image/balena-raw.img rm -rf $_deploy_dir/image/balena-flasher.img fi fi From 1b34cd94ea5935cc393e255695ed5eb8a03d399c Mon Sep 17 00:00:00 2001 From: Michal Toman Date: Fri, 20 Nov 2020 16:22:57 +0100 Subject: [PATCH 3/3] jenkins_build.sh: refactor the code for balena.img handling No functional change, just refactor a section of the script to make it more readable. Change-type: patch Signed-off-by: Michal Toman --- automation/jenkins_build.sh | 65 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 33 deletions(-) diff --git a/automation/jenkins_build.sh b/automation/jenkins_build.sh index 5ebbc16d4..eb6fdb3b3 100755 --- a/automation/jenkins_build.sh +++ b/automation/jenkins_build.sh @@ -84,22 +84,9 @@ deploy_build () { cp -v "$YOCTO_BUILD_DEPLOY/kernel_modules_headers.tar.gz" "$_deploy_dir" || true cp -v "$YOCTO_BUILD_DEPLOY/kernel_source.tar.gz" "$_deploy_dir" || true cp -v "$MACHINE.svg" "$_deploy_dir/logo.svg" - if [ "${_compressed}" != 'true' ]; then - # uncompressed, just copy and we're done - cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_artifact") "$_deploy_dir/image/balena.img" - if [ -n "$_deploy_flasher_artifact" ]; then - cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-raw.img" - cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_flasher_artifact") "$_deploy_dir/image/balena-flasher.img" - elif [ "$_image" = "resin-image-flasher" ]; then - # backwards compatibility - deployFlasherArtifact is not set and deployArtifact contains flasher - cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-flasher.img" - else - cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-raw.img" - fi - return - fi - if [ "${_archive}" = 'true' ]; then + if [ "${_archive}" = 'true' ] && [ "${_compressed}" = 'true' ]; then + # Archive and we are done cp -rv "$YOCTO_BUILD_DEPLOY"/"$_deploy_artifact"/* "$_deploy_dir"/image/ (cd "$_deploy_dir/image/" && zip -r "../$_deploy_artifact.zip" .) if [ -n "$_deploy_flasher_artifact" ]; then @@ -109,28 +96,40 @@ deploy_build () { if [ "$_remove_compressed_file" = "true" ]; then rm -rf $_deploy_dir/image fi + return + fi + + cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_artifact") "$_deploy_dir/image/balena-raw.img" + if [ -n "$_deploy_flasher_artifact" ]; then + cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_flasher_artifact") "$_deploy_dir/image/balena-flasher.img" + elif [ "$_image" = "resin-image-flasher" ]; then + # deployFlasherArtifact is not set and deployArtifact contains flasher + mv "$_deploy_dir/image/balena-raw.img" "$_deploy_dir/image/balena-flasher.img" + fi + + # Create the unflagged balena.img for backwards compatibility + if [ "$_image" = "resin-image-flasher" ]; then + cp -v "$_deploy_dir/image/balena-flasher.img" "$_deploy_dir/image/balena.img" else - cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_artifact") "$_deploy_dir/image/balena.img" - (cd "$_deploy_dir/image" && zip balena.img.zip balena.img) - if [ -n "$_deploy_flasher_artifact" ]; then - cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-raw.img" - (cd "$_deploy_dir/image" && zip balena-raw.img.zip balena-raw.img) - cp -v $(readlink --canonicalize "$YOCTO_BUILD_DEPLOY/$_deploy_flasher_artifact") "$_deploy_dir/image/balena-flasher.img" - (cd "$_deploy_dir/image" && zip balena-flasher.img.zip balena-flasher.img) - elif [ "$_image" = "resin-image-flasher" ]; then - # backwards compatibility - deployFlasherArtifact is not set and deployArtifact contains flasher - cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-flasher.img" - (cd "$_deploy_dir/image" && zip balena-flasher.img.zip balena-flasher.img) - else - cp -v "$_deploy_dir/image/balena.img" "$_deploy_dir/image/balena-raw.img" - (cd "$_deploy_dir/image" && zip balena-raw.img.zip balena-raw.img) + cp -v "$_deploy_dir/image/balena-raw.img" "$_deploy_dir/image/balena.img" + fi + + if [ "${_compressed}" != 'true' ]; then + # uncompressed, just copy and we're done + return + fi + + for filename in balena.img balena-raw.img balena-flasher.img; do + if [ ! -f "$_deploy_dir/image/$filename" ]; then + continue fi + + (cd "$_deploy_dir/image" && zip "$filename.zip" "$filename") + if [ "$_remove_compressed_file" = "true" ]; then - rm -rf $_deploy_dir/image/balena.img - rm -rf $_deploy_dir/image/balena-raw.img - rm -rf $_deploy_dir/image/balena-flasher.img + rm -rf "$_deploy_dir/image/$filename" fi - fi + done if [ -d "${WORKSPACE}/layers/meta-balena/tests" ] then