3 # To call this script, make sure make_ext4fs is somewhere in PATH
8 mkuserimg.sh [-s] SRC_DIR OUTPUT_FILE EXT_VARIANT MOUNT_POINT SIZE [-j <journal_size>]
9 [-T TIMESTAMP] [-C FS_CONFIG] [-D PRODUCT_OUT] [-B BLOCK_LIST_FILE]
10 [-d BASE_ALLOC_FILE_IN ] [-A BASE_ALLOC_FILE_OUT ] [-L LABEL]
11 [-i INODES ] [FILE_CONTEXTS]
16 if [ "$1" = "-s" ]; then
17 ENABLE_SPARSE_IMAGE="-s"
27 if [ ! -d $SRC_DIR ]; then
28 echo "Can not find directory $SRC_DIR!"
36 shift; shift; shift; shift; shift
39 if [ "$1" = "-j" ]; then
40 if [ "$2" = "0" ]; then
49 if [[ "$1" == "-T" ]]; then
55 if [[ "$1" == "-C" ]]; then
61 if [[ "$1" == "-D" ]]; then
67 if [[ "$1" == "-B" ]]; then
73 if [[ "$1" == "-d" ]]; then
79 if [[ "$1" == "-A" ]]; then
80 BASE_ALLOC_FILE_OUT=$2
85 if [[ "$1" == "-L" ]]; then
91 if [[ "$1" == "-i" ]]; then
99 *) echo "Only ext4 is supported!"; exit 3 ;;
102 if [ -z $MOUNT_POINT ]; then
103 echo "Mount point is required"
107 if [ -z $SIZE ]; then
108 echo "Need size of filesystem"
110 elif [ 0 -eq 0$SIZE ]; then
111 s=$(du -sm $SRC_DIR | cut -f1)
112 SIZE=$(($s / 10 + $s))M
116 if [ -n "$FC" ]; then
119 if [ -n "$FS_CONFIG" ]; then
120 OPT="$OPT -C $FS_CONFIG"
122 if [ -n "$BLOCK_LIST" ]; then
123 OPT="$OPT -B $BLOCK_LIST"
125 if [ -n "$BASE_ALLOC_FILE_IN" ]; then
126 OPT="$OPT -d $BASE_ALLOC_FILE_IN"
128 if [ -n "$BASE_ALLOC_FILE_OUT" ]; then
129 OPT="$OPT -D $BASE_ALLOC_FILE_OUT"
131 if [ -n "$LABEL" ]; then
134 if [ -n "$INODES" ]; then
135 OPT="$OPT -i $INODES"
138 MAKE_EXT4FS_CMD="make_ext4fs $ENABLE_SPARSE_IMAGE -T $TIMESTAMP $OPT -l $SIZE $JOURNAL_FLAGS -a $MOUNT_POINT $OUTPUT_FILE $SRC_DIR $PRODUCT_OUT"
139 echo $MAKE_EXT4FS_CMD
141 if [ $? -ne 0 ]; then