Skip to content

Commit

Permalink
[Build]: Fix the bin image generated from raw image issue (#10083)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
xumia authored Mar 8, 2022
1 parent 29f6b01 commit f1d6d7c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand All @@ -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
}

Expand Down Expand Up @@ -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
Expand All @@ -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!"
Expand Down

0 comments on commit f1d6d7c

Please sign in to comment.