2016-03-08 13:42:20 -06:00
#!/bin/bash
## This script is to generate an ONIE installer image based on a file system overload
## Read ONIE image related config file
. ./onie-image.conf
[ -n " $ONIE_IMAGE_PART_SIZE " ] || {
echo "Error: Invalid ONIE_IMAGE_PART_SIZE in onie image config file"
exit 1
}
[ -n " $ONIE_INSTALLER_PAYLOAD " ] || {
echo "Error: Invalid ONIE_INSTALLER_PAYLOAD in onie image config file"
exit 1
}
## Retrieval short version of Git revision hash for partition metadata
2017-02-14 18:56:08 -06:00
if [ -z " $( git status --untracked-files= no -s --ignore-submodules) " ] ; then
GIT_REVISION = $( git rev-parse --short HEAD)
elif [ ! " $DEBUG_BUILD " = "y" ] ; then
echo "Error: There are local changes not committed to git repo. Cannot get a revision hash for partition metadata."
2016-03-08 13:42:20 -06:00
exit 1
2017-02-14 18:56:08 -06:00
else
echo "Warning: There are local changes not committed to git repo, revision hash won't be tracked. Never deploy this image for other than debugging purpose."
GIT_REVISION = $( git rev-parse --short HEAD) "_local_debug"
fi
2016-03-08 13:42:20 -06:00
2017-01-29 13:33:33 -06:00
if [ " $IMAGE_TYPE " = "onie" ] ; then
2017-02-05 17:59:59 -06:00
echo "Build ONIE installer"
mkdir -p ` dirname $OUTPUT_ONIE_IMAGE `
sudo rm -f $OUTPUT_ONIE_IMAGE
2017-03-29 06:17:49 -05:00
# 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/
for VENDOR in ` ls ./device` ; do
for PLATFORM in ` ls ./device/$VENDOR ` ; do
if [ -f ./device/$VENDOR /$PLATFORM /installer.conf ] ; then
cp ./device/$VENDOR /$PLATFORM /installer.conf ./installer/x86_64/platforms/$PLATFORM
fi
done
done
2016-03-16 01:38:26 -05:00
## 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 \
2017-01-29 13:33:33 -06:00
installer platform/$TARGET_MACHINE /platform.conf $OUTPUT_ONIE_IMAGE OS $GIT_REVISION $ONIE_IMAGE_PART_SIZE \
2016-03-16 01:38:26 -05:00
$ONIE_INSTALLER_PAYLOAD
## Use 'aboot' as target machine category which includes Aboot as bootloader
2017-01-29 13:33:33 -06:00
elif [ " $IMAGE_TYPE " = "aboot" ] ; then
2017-02-05 17:59:59 -06:00
echo "Build Aboot installer"
mkdir -p ` dirname $OUTPUT_ABOOT_IMAGE `
sudo rm -f $OUTPUT_ABOOT_IMAGE
sudo rm -f $ABOOT_BOOT_IMAGE
## Add main payload
cp $ONIE_INSTALLER_PAYLOAD $OUTPUT_ABOOT_IMAGE
## Add Aboot boot0 file
j2 -f env files/Aboot/boot0.j2 ./onie-image.conf > files/Aboot/boot0
pushd files/Aboot && zip -g $OLDPWD /$OUTPUT_ABOOT_IMAGE boot0; popd
pushd files/Aboot && zip -g $OLDPWD /$ABOOT_BOOT_IMAGE boot0; popd
2016-03-16 01:38:26 -05:00
echo " $GIT_REVISION " >> .imagehash
2017-02-05 17:59:59 -06:00
zip -g $OUTPUT_ABOOT_IMAGE .imagehash
zip -g $ABOOT_BOOT_IMAGE .imagehash
2016-03-16 01:38:26 -05:00
rm .imagehash
2017-02-03 18:33:33 -06:00
echo "SWI_VERSION=42.0.0" > version
2017-02-08 16:13:44 -06:00
echo "SWI_MAX_HWEPOCH=1" >> version
echo "SWI_VARIANT=US" >> version
2017-02-05 17:59:59 -06:00
zip -g $OUTPUT_ABOOT_IMAGE version
zip -g $ABOOT_BOOT_IMAGE version
2017-02-03 18:33:33 -06:00
rm version
2017-02-05 17:59:59 -06:00
zip -g $OUTPUT_ABOOT_IMAGE $ABOOT_BOOT_IMAGE
rm $ABOOT_BOOT_IMAGE
2016-03-16 01:38:26 -05:00
else
echo " Error: Non supported target platform: $TARGET_PLATFORM "
exit 1
fi