[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit
Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/ap/build/squashfs.sh b/ap/build/squashfs.sh
new file mode 100755
index 0000000..b145560
--- /dev/null
+++ b/ap/build/squashfs.sh
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+if [ x"$ERASEBLOCK" = x"" ]; then
+ ERASEBLOCK=0x20000
+fi
+
+if [ x"$SQUASHFS_BLOCK_KB" = x"" ]; then
+ # squashfs 256KB default
+ SQUASHFS_BLOCK_KB=256
+fi
+
+which mksquashfs > /dev/null 2>&1
+if [ $? -eq 0 ]; then
+ echo "check command mksquashfs ok"
+else
+ echo "[error]check command mksquashfs fail, Maybe run [ sudo apt-get install squashfs-tools ] to install"
+ exit 1
+fi
+
+squashfs_tools_version=`mksquashfs -version | grep "mksquashfs version 4"`
+if [ $? -ne 0 ]; then
+ echo "[error]Requires the minimum version of squashfs-tools is 4.0"
+ echo `mksquashfs -version | grep "mksquashfs version"`
+ exit 2
+else
+ echo "squashfs-tools version check pass"
+fi
+
+BLOCK_CNT_SQUASHFS=$(awk "BEGIN { print $SQUASHFS_BLOCK_KB * 1024 / $ERASEBLOCK }")
+
+echo "one squashfs block contain $BLOCK_CNT_SQUASHFS flash block"
+
+mksquashfs $1 $2 -b ${SQUASHFS_BLOCK_KB}k -nopad -noappend -comp xz -Xbcj armthumb -Xdict-size 100% -root-owned -no-xattrs
+if [ $? -ne 0 ]; then
+ echo "mksquashfs error"
+ exit -1
+else
+ echo "mksquashfs ok"
+fi
+
+exit 0