blob: 0686092603f5ea06ee90666579f646cd2bb9d931 [file] [log] [blame]
Mohamad Ayyasheca016e2015-03-03 12:33:48 -08001#!/bin/bash
2#
3# To call this script, make sure mksquashfs is somewhere in PATH
4
5function usage() {
6cat<<EOT
7Usage:
Simon Wilsonb4cf7b32015-06-17 12:36:53 -07008${0##*/} SRC_DIR OUTPUT_FILE [-m MOUNT_POINT] [-c FILE_CONTEXTS] [-b BLOCK_SIZE] [-z COMPRESSOR] [-zo COMPRESSOR_OPT]
Mohamad Ayyasheca016e2015-03-03 12:33:48 -08009EOT
10}
11
12echo "in mksquashfsimage.sh PATH=$PATH"
13
14if [ $# -lt 2 ]; then
15 usage
16 exit 1
17fi
18
19SRC_DIR=$1
20if [ ! -d $SRC_DIR ]; then
21 echo "Can not find directory $SRC_DIR!"
22 exit 2
23fi
24OUTPUT_FILE=$2
25shift; shift
26
27MOUNT_POINT=
28if [[ "$1" == "-m" ]]; then
29 MOUNT_POINT=$2
30 shift; shift
31fi
32
33FILE_CONTEXTS=
34if [[ "$1" == "-c" ]]; then
35 FILE_CONTEXTS=$2
36 shift; shift
37fi
38
39BLOCK_SIZE=131072
40if [[ "$1" == "-b" ]]; then
41 BLOCK_SIZE=$2
42 shift; shift
43fi
44
Simon Wilsonb4cf7b32015-06-17 12:36:53 -070045COMPRESSOR="lz4"
46COMPRESSOR_OPT="-Xhc"
47if [[ "$1" == "-z" ]]; then
48 COMPRESSOR=$2
49 COMPRESSOR_OPT=
50 shift; shift
51fi
52
53if [[ "$1" == "-zo" ]]; then
54 COMPRESSOR_OPT=$2
55 shift; shift
56fi
57
Mohamad Ayyasheca016e2015-03-03 12:33:48 -080058OPT=""
59if [ -n "$MOUNT_POINT" ]; then
60 OPT="$OPT -mount-point $MOUNT_POINT"
61fi
62if [ -n "$FILE_CONTEXTS" ]; then
63 OPT="$OPT -context-file $FILE_CONTEXTS"
64fi
65if [ -n "$BLOCK_SIZE" ]; then
66 OPT="$OPT -b $BLOCK_SIZE"
67fi
68
Simon Wilsonb4cf7b32015-06-17 12:36:53 -070069MAKE_SQUASHFS_CMD="mksquashfs $SRC_DIR $OUTPUT_FILE -no-progress -comp $COMPRESSOR $COMPRESSOR_OPT -no-exports -noappend -no-recovery -android-fs-config $OPT"
Mohamad Ayyasheca016e2015-03-03 12:33:48 -080070echo $MAKE_SQUASHFS_CMD
71$MAKE_SQUASHFS_CMD
72if [ $? -ne 0 ]; then
73 exit 4
74fi