[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.
This commit is contained in:
xumia 2022-03-08 21:15:43 +08:00 committed by GitHub
parent 29f6b01be6
commit f1d6d7ccce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -68,6 +68,8 @@ generate_kvm_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
rm -rf ./installer/x86_64/platforms/
mkdir -p ./installer/x86_64/platforms/
@ -83,7 +85,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
}
@ -119,12 +121,13 @@ 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_device_list "./installer/$TARGET_PLATFORM/platforms_asic"
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
@ -135,8 +138,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!"