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