M7350/bootable/scripts/tools/releasetools/make_ota_package.sh
2024-09-09 08:57:42 +00:00

132 lines
3.2 KiB
Bash
Executable File

#!/bin/bash
DEFAULT_NEW_ZIPFILE=mdm9607-ota-target-image-ubi.zip
DEFAULT_OLD_ZIPFILE=old.zip
DEFAULT_UPDATE_ZIPFILE=update.zip
RM_SRC_FILES=" \
/SYSTEM/usr/lib/arm-oe-linux-gnueabi/4.9.2/libcc.a \
/SYSTEM/usr/lib/modules/3.18.20/extra/wlan.ko \
/SYSTEM/usr/bin/smbd \
/SYSTEM/etc/shadow \
/SYSTEM/etc/NetIspInfo.ini
"
RM_TARGET_FILES="system/etc/shadow"
# zip compatibility.txt into update.zip
function zip_compatibility_txt()
{
COMPATIBILITY_FILE=compatibility.txt
if [ -z "$1" ] ; then
local ANSWER=
local default_value='y'
while [ "${ANSWER}" != "y" -a \
"${ANSWER}" != "Y" -a \
"${ANSWER}" != "n" -a \
"${ANSWER}" != "N" ]
do
echo -n "Do you want to zip compatibility file? [y/n] "
read ANSWER
done
else
ANSWER=$1
fi
if [ "${ANSWER}" == "y" -o "${ANSWER}" == "Y" ]; then
if [ ! -f ${COMPATIBILITY_FILE} ]; then
echo -e "\033[31mError:\033[0m"
echo -e " Compatibility file not exist!"
else
echo -e " Zip compatibility file"
zip ${DEFAULT_UPDATE_ZIPFILE} ${COMPATIBILITY_FILE}
fi
else
echo -e "\033[32mWarning: You won't zip compatibility file, it may cause update failed!\033[0m"
fi
}
# zip firmware images into update.zip
function zip_firmware_images()
{
FIRMWARE_PATH=firmware
if [ -z "$1" ] ; then
local ANSWER=
local default_value='y'
while [ "${ANSWER}" != "y" -a \
"${ANSWER}" != "Y" -a \
"${ANSWER}" != "n" -a \
"${ANSWER}" != "N" ]
do
echo -n "Do you want to zip firmware images? [y/n] "
read ANSWER
done
else
ANSWER=$1
fi
if [ "${ANSWER}" == "y" -o "${ANSWER}" == "Y" ]; then
echo -e " Zip firmware images"
./zip_firmware.sh
else
echo -e "\033[32mInfo: You won't zip firmware images!\033[0m"
fi
}
echo "Make OTA package:"
if [ ! $# -eq 4 ]; then
echo -e "Usage: $0 old.zip new.zip zip_firmware(n/y) rm_files(n/y)"
exit 1
fi
OLD_ZIPFILE=$1
NEW_ZIPFILE=$2
IF_ZIP_FIRMWARE=$3
IF_RM_FILES=$4
# check target zipfile
if [ ! -f ${OLD_ZIPFILE} ]; then
echo -e "\033[31mError:\033[0m"
echo -e " Target zipfile: ${OLD_ZIPFILE} not exist"
exit 1
fi
# check incremental zipfile
if [ ! -f ${NEW_ZIPFILE} ]; then
echo -e "\033[31mError:\033[0m"
echo -e " Incremental zipfile: ${NEW_ZIPFILE} not exist"
exit 1
fi
# make ota package: update.zip
if [ "${IF_RM_FILES}" == "y" -o "${IF_RM_FILES}" == "Y" ]; then
zip -d ${OLD_ZIPFILE} ${RM_SRC_FILES}
fi
./ota_from_target_files -v -p . -i ${OLD_ZIPFILE} ${NEW_ZIPFILE} ${DEFAULT_UPDATE_ZIPFILE}
FoundFile=`unzip -l ${DEFAULT_UPDATE_ZIPFILE} | awk '{print $4}' | grep "^${RM_TARGET_FILES}$"`
if [ "${FoundFile}" == "${RM_TARGET_FILES}" ]; then
zip -d ${DEFAULT_UPDATE_ZIPFILE} ${RM_TARGET_FILES}
fi
if [ ! $? -eq 0 ]; then
echo -e "\033[31mError:\033[0m"
echo -e " Making OTA package error, please check the src zipfile"
exit 1
fi
# if you want to select by yourself, please uncomment follow command
#zip_compatibility_txt
zip_compatibility_txt y
# if you want to select by yourself, please uncomment follow command
#zip_firmware_images
zip_firmware_images ${IF_ZIP_FIRMWARE}
echo -e "Make OTA package done!"
echo -e "Output package: \033[36m${DEFAULT_UPDATE_ZIPFILE}\033[0m"