blob: 7f96cb1fc5dd98a9e169fdf20432121580292e0c [file] [log] [blame]
Mohamad Ayyashf0d5f8c2015-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:
8${0##*/} SRC_DIR OUTPUT_FILE [-m MOUNT_POINT] [-c FILE_CONTEXTS] [-b BLOCK_SIZE]
9EOT
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
45OPT=""
46if [ -n "$MOUNT_POINT" ]; then
47 OPT="$OPT -mount-point $MOUNT_POINT"
48fi
49if [ -n "$FILE_CONTEXTS" ]; then
50 OPT="$OPT -context-file $FILE_CONTEXTS"
51fi
52if [ -n "$BLOCK_SIZE" ]; then
53 OPT="$OPT -b $BLOCK_SIZE"
54fi
55
56MAKE_SQUASHFS_CMD="mksquashfs $SRC_DIR $OUTPUT_FILE -no-progress -comp lz4 -Xhc -no-exports -noappend -no-recovery -android-fs-config $OPT"
57echo $MAKE_SQUASHFS_CMD
58$MAKE_SQUASHFS_CMD
59if [ $? -ne 0 ]; then
60 exit 4
61fi