lh | 9ed821d | 2023-04-07 01:36:19 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [ x"$ERASEBLOCK" = x"" ]; then |
| 4 | ERASEBLOCK=0x20000 |
| 5 | fi |
| 6 | |
| 7 | if [ x"$SQUASHFS_BLOCK_KB" = x"" ]; then |
| 8 | # squashfs 256KB default |
| 9 | SQUASHFS_BLOCK_KB=256 |
| 10 | fi |
| 11 | |
| 12 | which mksquashfs > /dev/null 2>&1 |
| 13 | if [ $? -eq 0 ]; then |
| 14 | echo "check command mksquashfs ok" |
| 15 | else |
| 16 | echo "[error]check command mksquashfs fail, Maybe run [ sudo apt-get install squashfs-tools ] to install" |
| 17 | exit 1 |
| 18 | fi |
| 19 | |
| 20 | squashfs_tools_version=`mksquashfs -version | grep "mksquashfs version 4"` |
| 21 | if [ $? -ne 0 ]; then |
| 22 | echo "[error]Requires the minimum version of squashfs-tools is 4.0" |
| 23 | echo `mksquashfs -version | grep "mksquashfs version"` |
| 24 | exit 2 |
| 25 | else |
| 26 | echo "squashfs-tools version check pass" |
| 27 | fi |
| 28 | |
| 29 | BLOCK_CNT_SQUASHFS=$(awk "BEGIN { print $SQUASHFS_BLOCK_KB * 1024 / $ERASEBLOCK }") |
| 30 | |
| 31 | echo "one squashfs block contain $BLOCK_CNT_SQUASHFS flash block" |
| 32 | |
| 33 | mksquashfs $1 $2 -b ${SQUASHFS_BLOCK_KB}k -nopad -noappend -comp xz -Xbcj armthumb -Xdict-size 100% -root-owned -no-xattrs |
| 34 | if [ $? -ne 0 ]; then |
| 35 | echo "mksquashfs error" |
| 36 | exit -1 |
| 37 | else |
| 38 | echo "mksquashfs ok" |
| 39 | fi |
| 40 | |
| 41 | exit 0 |