Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add onie image install's platform verification #8814

Merged
merged 10 commits into from
Oct 25, 2021
26 changes: 26 additions & 0 deletions build_image.sh
Original file line number Diff line number Diff line change
@@ -87,11 +87,30 @@ generate_onie_installer_image()
$ONIE_INSTALLER_PAYLOAD
}

# Generate asic-specific device list
generate_device_list()
{
local platforms_asic=$1

# Create an empty function, and later append to it
echo -n > $platforms_asic

for d in `find -L ./device -maxdepth 2 -mindepth 2 -type d`; do
if [ -f $d/platform_asic ]; then
if [ "$CONFIGURED_PLATFORM" = "generic" ] || grep -Fxq "$CONFIGURED_PLATFORM" $d/platform_asic; then
echo "${d##*/}" >> "$platforms_asic";
fi;
fi;
done
}

if [ "$IMAGE_TYPE" = "onie" ]; then
wen587 marked this conversation as resolved.
Show resolved Hide resolved
echo "Build ONIE installer"
mkdir -p `dirname $OUTPUT_ONIE_IMAGE`
sudo rm -f $OUTPUT_ONIE_IMAGE

generate_device_list "./installer/$TARGET_PLATFORM/platforms_asic"

generate_onie_installer_image

## Build a raw partition dump image using the ONIE installer that can be
@@ -103,6 +122,8 @@ elif [ "$IMAGE_TYPE" = "raw" ]; then
mkdir -p `dirname $OUTPUT_RAW_IMAGE`
sudo rm -f $OUTPUT_RAW_IMAGE

generate_device_list "./installer/$TARGET_PLATFORM/platforms_asic"

generate_onie_installer_image

echo "Creating SONiC raw partition : $OUTPUT_RAW_IMAGE of size $RAW_IMAGE_DISK_SIZE MB"
@@ -134,6 +155,8 @@ elif [ "$IMAGE_TYPE" = "raw" ]; then

elif [ "$IMAGE_TYPE" = "kvm" ]; then

generate_device_list "./installer/$TARGET_PLATFORM/platforms_asic"

generate_onie_installer_image
# Generate single asic KVM image
generate_kvm_image
@@ -170,6 +193,9 @@ elif [ "$IMAGE_TYPE" = "aboot" ]; then
zip -g $ABOOT_BOOT_IMAGE version
rm version

generate_device_list ".platforms_asic"
zip -g $OUTPUT_ABOOT_IMAGE .platforms_asic

zip -g $OUTPUT_ABOOT_IMAGE $ABOOT_BOOT_IMAGE
rm $ABOOT_BOOT_IMAGE
if [ "$SONIC_ENABLE_IMAGE_SIGNATURE" = "y" ]; then
22 changes: 22 additions & 0 deletions installer/arm64/install.sh
Original file line number Diff line number Diff line change
@@ -64,6 +64,28 @@ VAR_LOG_SIZE=4096

[ -r platforms/$onie_platform ] && . platforms/$onie_platform

# Verify image platform is inside devices list
if [ "$install_env" = "onie" ]; then
if ! grep -Fxq "$onie_platform" platforms_asic; then
echo "The image you're trying to install is of a different ASIC type as the running platform's ASIC"
while true; do
read -r -p "Do you still wish to install this image? [y/n]: " input
case $input in
[Yy])
echo "Force installing..."
break
;;
[Nn])
echo "Exited installation!"
exit 1
;;
*)
echo "Error: Invalid input"
;;
esac
done
fi
fi

# If running in ONIE
if [ "$install_env" = "onie" ]; then
22 changes: 22 additions & 0 deletions installer/armhf/install.sh
Original file line number Diff line number Diff line change
@@ -64,6 +64,28 @@ VAR_LOG_SIZE=4096

[ -r platforms/$onie_platform ] && . platforms/$onie_platform

# Verify image platform is inside devices list
if [ "$install_env" = "onie" ]; then
if ! grep -Fxq "$onie_platform" platforms_asic; then
echo "The image you're trying to install is of a different ASIC type as the running platform's ASIC"
while true; do
read -r -p "Do you still wish to install this image? [y/n]: " input
case $input in
[Yy])
echo "Force installing..."
break
;;
[Nn])
echo "Exited installation!"
exit 1
;;
*)
echo "Error: Invalid input"
;;
esac
done
fi
fi

# If running in ONIE
if [ "$install_env" = "onie" ]; then
23 changes: 23 additions & 0 deletions installer/x86_64/install.sh
Original file line number Diff line number Diff line change
@@ -92,6 +92,29 @@ VAR_LOG_SIZE=4096

[ -r platforms/$onie_platform ] && . platforms/$onie_platform

# Verify image platform is inside devices list
if [ "$install_env" = "onie" ]; then
if ! grep -Fxq "$onie_platform" platforms_asic; then
echo "The image you're trying to install is of a different ASIC type as the running platform's ASIC"
while true; do
read -r -p "Do you still wish to install this image? [y/n]: " input
case $input in
[Yy])
echo "Force installing..."
break
;;
[Nn])
echo "Exited installation!"
exit 1
;;
*)
echo "Error: Invalid input"
;;
esac
done
fi
wen587 marked this conversation as resolved.
Show resolved Hide resolved
fi

# Pick up console port and speed from install enviroment if not defined yet.
# Console port and speed setting in cmdline is like "console=ttyS0,9600n",
# so we can use pattern 'console=ttyS[0-9]+,[0-9]+' to match it.