1
0
This repository has been archived on 2025-01-10. You can view files and clone it, but cannot push or open issues or pull requests.
alacn1_pace_v5471/fwbuild.sh
2017-07-30 16:48:02 -03:00

80 lines
1.0 KiB
Bash
Executable File

#!/bin/bash
COLORINFO=4
UPDATEFW=./updatefw
ROOTFS=squashfs-root
OUTDIR=build
if [ -z "$1" ] || [ -z "$2" ]
then
echo "usage: $0 srcfw.bin outfw.bin"
exit 1
fi
SRCFW=$1
OUTFW=$2
# sanity check
if [ ! -f "$SRCFW" ]
then
echo "ERROR: $SRCFW doesn't exist"
exit 1
fi
if [ ! -d "$ROOTFS" ]
then
echo "ERROR: $ROOTFS is missing, extract it"
exit 1
fi
if [ ! -x "$UPDATEFW" ]
then
echo "ERROR: $UPDATEFW doesn't exist"
exit 1
fi
OUTFILE=$OUTDIR/$OUTFW
# already exist?
if [ -e "$OUTFILE" ]
then
echo "ERROR: $OUTFILE already exist"
exit 1
#echo "WARNING: removing $OUTFILE"
#rm -f $OUTFILE
fi
if [ ! -d "$OUTDIR" ]
then
mkdir -p $OUTDIR
fi
# build fs
FS=`dirname $OUTFILE`/`basename -s .bin $OUTFILE`.fs
./fsbuild.sh $FS
RET=$?
if [ $RET != 0 ]
then
echo "ERROR: fs build failed"
exit 1
fi
# build fw
echo "building $OUTFILE ..."
echo '------>>>'
tput setaf $COLORINFO
$UPDATEFW -u $SRCFW -s $FS -o $OUTFILE
RET=$?
tput sgr0
echo '<<<------'
if [ $RET != 0 ]
then
echo "ERROR: fw build failed"
exit 1
fi
#rm -f $FS
echo "$OUTFILE done."
exit 0