#!/bin/bash

if [ ! -f ../linaro-rootfs.img ]; then
	echo "Error, linaro-rootfs.img not found." 1>&2
	exit 1
fi

rm -rf update.img ../Image/update.img
echo "start to make update.img..."

./afptool -pack ./ ../Image/update.img
if [ $? -ne 0 ] ; then
	rm -rf update.img ../Image/update.img
	echo "Error, failed to generate ../Image/update.img" 1>&2
	exit 2
fi

./rkImageMaker -RK3568 ../Image/MiniLoaderAll.bin ../Image/update.img \
	update.img -os_type:androidos
if [ $? -ne 0 ] ; then
	echo "Error, failed to generate update.img" 1>&2
	exit 3
fi

echo "Making update.img OK."
exit 0
