142 lines
2.6 KiB
Bash
Executable File
142 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
dir=`pwd`
|
|
version=$1
|
|
filepath=$2
|
|
PROJECT_NAME=$3
|
|
PROJECT_BIZID=$4
|
|
|
|
if [ $# -lt 2 ]
|
|
then
|
|
echo "please ./mkzip.sh version filepath"
|
|
exit -1
|
|
fi
|
|
|
|
if [ ! -f $filepath ]
|
|
then
|
|
echo "not found $filepath"
|
|
exit -1
|
|
fi
|
|
|
|
rm -rf ./output/ota
|
|
mkdir -p ./output/ota
|
|
mkdir -p ./output/ota/updatezip/image
|
|
mkdir -p ./output/ota/updatezip/split
|
|
|
|
dir=$dir/output/ota
|
|
|
|
unzip $filepath -d ./output/ota/updatezip/image
|
|
filepath_tz="$dir/updatezip/image/tz.img"
|
|
filepath_boot="$dir/updatezip/image/boot.img"
|
|
filepath_rootfs="$dir/updatezip/image/rootfs.ubi"
|
|
|
|
if [ ! -f "$filepath_tz" ]
|
|
then
|
|
echo "not found $filepath_tz"
|
|
exit -1
|
|
fi
|
|
if [ ! -f "$filepath_boot" ]
|
|
then
|
|
echo "not found $filepath_boot"
|
|
exit -1
|
|
fi
|
|
if [ ! -f "$filepath_rootfs" ]
|
|
then
|
|
echo "not found $filepath_rootfs"
|
|
exit -1
|
|
fi
|
|
|
|
cd $dir
|
|
rm -rf files
|
|
mkdir files
|
|
echo version=$version >> $dir/files/info
|
|
|
|
split -b 1M -d $filepath_tz $dir/updatezip/split/tz.img_
|
|
split -b 1M -d $filepath_boot $dir/updatezip/split/boot.img_
|
|
split -b 1M -d $filepath_rootfs $dir/updatezip/split/rootfs.ubi_
|
|
|
|
|
|
cd $dir
|
|
files_tz=`ls $dir/updatezip/split/tz.img_*`
|
|
files_boot=`ls $dir/updatezip/split/boot.img_*`
|
|
files_rootfs=`ls $dir/updatezip/split/rootfs.ubi_*`
|
|
|
|
totalfiles_tz=0
|
|
totalfiles_boot=0
|
|
totalfiles_rootfs=0
|
|
|
|
|
|
for f in $files_tz
|
|
do
|
|
(( ++totalfiles_tz ))
|
|
done
|
|
|
|
for f in $files_boot
|
|
do
|
|
(( ++totalfiles_boot ))
|
|
done
|
|
|
|
for f in $files_rootfs
|
|
do
|
|
(( ++totalfiles_rootfs ))
|
|
done
|
|
|
|
echo "wait for calculate md5..."
|
|
cd $dir/updatezip/split/
|
|
for i in $(seq 0 `expr $totalfiles_tz - 1`)
|
|
do
|
|
if [ $i -lt 10 ];then
|
|
fileindex=0$i
|
|
else
|
|
fileindex=$i
|
|
fi
|
|
|
|
md5filename=`md5sum tz.img_$fileindex | awk '{ print $1 }'`
|
|
md5filename="tz.img-$fileindex-$md5filename"
|
|
echo "file=$md5filename" >> $dir/files/info
|
|
mv tz.img_$fileindex $dir/files/$md5filename
|
|
(( ++i ))
|
|
done
|
|
|
|
for i in $(seq 0 `expr $totalfiles_boot - 1`)
|
|
do
|
|
if [ $i -lt 10 ];then
|
|
fileindex=0$i
|
|
else
|
|
fileindex=$i
|
|
fi
|
|
|
|
md5filename=`md5sum boot.img_$fileindex | awk '{ print $1 }'`
|
|
md5filename="boot.img-$fileindex-$md5filename"
|
|
echo "file=$md5filename" >> $dir/files/info
|
|
mv boot.img_$fileindex $dir/files/$md5filename
|
|
(( ++i ))
|
|
done
|
|
|
|
for i in $(seq 0 `expr $totalfiles_rootfs - 1`)
|
|
do
|
|
if [ $i -lt 10 ];then
|
|
fileindex=0$i
|
|
else
|
|
fileindex=$i
|
|
fi
|
|
|
|
md5filename=`md5sum rootfs.ubi_$fileindex | awk '{ print $1 }'`
|
|
md5filename="rootfs.ubi-$fileindex-$md5filename"
|
|
echo "file=$md5filename" >> $dir/files/info
|
|
mv rootfs.ubi_$fileindex $dir/files/$md5filename
|
|
(( ++i ))
|
|
done
|
|
|
|
cd $dir
|
|
rm ./updatezip -rf
|
|
mv ./files/info .
|
|
zip -r "Firmware_"$PROJECT_NAME"_OTA_"$version"_"$PROJECT_BIZID".zip" ./*
|
|
rm ./files -rf
|
|
rm info
|
|
cd ../..
|
|
|
|
echo "work done"
|