From 24d74235fbb6f625a41d23853d2217d05d68d0d5 Mon Sep 17 00:00:00 2001 From: xumia <59720581+xumia@users.noreply.github.com> Date: Tue, 8 Mar 2022 21:15:43 +0800 Subject: [PATCH] [Build]: Fix the bin image generated from raw image issue (#10083) Why I did it It is to fix the issue #10048 When building .raw image, for instance, target/sonic-broadcom.raw, it will generate a .bin image, target/sonic-broadcom.bin, as the intermediate file. The intermediate file is a build target which may contains different dependencies with the raw one. --- build_image.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/build_image.sh b/build_image.sh index d67826e08303..d6f4c7e60b60 100755 --- a/build_image.sh +++ b/build_image.sh @@ -27,6 +27,8 @@ IMAGE_VERSION="${SONIC_IMAGE_VERSION}" generate_onie_installer_image() { + output_file=$OUTPUT_ONIE_IMAGE + [ -n "$1" ] && output_file=$1 # Copy platform-specific ONIE installer config files where onie-mk-demo.sh expects them rm -rf ./installer/${TARGET_PLATFORM}/platforms/ mkdir -p ./installer/${TARGET_PLATFORM}/platforms/ @@ -42,7 +44,7 @@ generate_onie_installer_image() ## Generate an ONIE installer image ## Note: Don't leave blank between lines. It is single line command. ./onie-mk-demo.sh $TARGET_PLATFORM $TARGET_MACHINE $TARGET_PLATFORM-$TARGET_MACHINE-$ONIEIMAGE_VERSION \ - installer platform/$TARGET_MACHINE/platform.conf $OUTPUT_ONIE_IMAGE OS $IMAGE_VERSION $ONIE_IMAGE_PART_SIZE \ + installer platform/$TARGET_MACHINE/platform.conf $output_file OS $IMAGE_VERSION $ONIE_IMAGE_PART_SIZE \ $ONIE_INSTALLER_PAYLOAD } @@ -59,10 +61,11 @@ if [ "$IMAGE_TYPE" = "onie" ]; then elif [ "$IMAGE_TYPE" = "raw" ]; then echo "Build RAW image" + tmp_output_onie_image=${OUTPUT_ONIE_IMAGE}.tmp mkdir -p `dirname $OUTPUT_RAW_IMAGE` sudo rm -f $OUTPUT_RAW_IMAGE - generate_onie_installer_image + generate_onie_installer_image "$tmp_output_onie_image" echo "Creating SONiC raw partition : $OUTPUT_RAW_IMAGE of size $RAW_IMAGE_DISK_SIZE MB" fallocate -l "$RAW_IMAGE_DISK_SIZE"M $OUTPUT_RAW_IMAGE @@ -73,8 +76,9 @@ elif [ "$IMAGE_TYPE" = "raw" ]; then ## Generate a partition dump that can be used to 'dd' in-lieu of using the onie-nos-installer ## Run the installer ## The 'build' install mode of the installer is used to generate this dump. - sudo chmod a+x $OUTPUT_ONIE_IMAGE - sudo ./$OUTPUT_ONIE_IMAGE + sudo chmod a+x $tmp_output_onie_image + sudo ./$tmp_output_onie_image + rm $tmp_output_onie_image [ -r $OUTPUT_RAW_IMAGE ] || { echo "Error : $OUTPUT_RAW_IMAGE not generated!"