[Build]: Fix the bin image generated from raw image issue (#10083) (#13672)

#### Why I did it
Cherry pick from #10083
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.

#### How I did it
Rename the intermediate file.
This commit is contained in:
xumia 2023-02-09 12:24:06 +08:00 committed by GitHub
parent ff5a703301
commit f48734fe50
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -27,6 +27,8 @@ IMAGE_VERSION="${SONIC_IMAGE_VERSION}"
generate_onie_installer_image() 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 # Copy platform-specific ONIE installer config files where onie-mk-demo.sh expects them
rm -rf ./installer/${TARGET_PLATFORM}/platforms/ rm -rf ./installer/${TARGET_PLATFORM}/platforms/
mkdir -p ./installer/${TARGET_PLATFORM}/platforms/ mkdir -p ./installer/${TARGET_PLATFORM}/platforms/
@ -42,7 +44,7 @@ generate_onie_installer_image()
## Generate an ONIE installer image ## Generate an ONIE installer image
## Note: Don't leave blank between lines. It is single line command. ## 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 \ ./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 $ONIE_INSTALLER_PAYLOAD
} }
@ -59,10 +61,11 @@ if [ "$IMAGE_TYPE" = "onie" ]; then
elif [ "$IMAGE_TYPE" = "raw" ]; then elif [ "$IMAGE_TYPE" = "raw" ]; then
echo "Build RAW image" echo "Build RAW image"
tmp_output_onie_image=${OUTPUT_ONIE_IMAGE}.tmp
mkdir -p `dirname $OUTPUT_RAW_IMAGE` mkdir -p `dirname $OUTPUT_RAW_IMAGE`
sudo rm -f $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" 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 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 ## Generate a partition dump that can be used to 'dd' in-lieu of using the onie-nos-installer
## Run the installer ## Run the installer
## The 'build' install mode of the installer is used to generate this dump. ## The 'build' install mode of the installer is used to generate this dump.
sudo chmod a+x $OUTPUT_ONIE_IMAGE sudo chmod a+x $tmp_output_onie_image
sudo ./$OUTPUT_ONIE_IMAGE sudo ./$tmp_output_onie_image
rm $tmp_output_onie_image
[ -r $OUTPUT_RAW_IMAGE ] || { [ -r $OUTPUT_RAW_IMAGE ] || {
echo "Error : $OUTPUT_RAW_IMAGE not generated!" echo "Error : $OUTPUT_RAW_IMAGE not generated!"