OSDN Git Service

Add mkuserimg.sh script for the build system
[android-x86/system-extras.git] / ext4_utils / mkuserimg.sh
1 #!/bin/bash
2 #
3 # To call this script, make sure make_ext4fs is somewhere in PATH
4
5 function usage() {
6 cat<<EOT
7 Usage:
8 mkuserimg.sh SRC_DIR OUTPUT_FILE EXT_VARIANT LABEL SIZE
9 EOT
10 }
11
12 echo "in mkuserimg.sh PATH=$PATH"
13
14 if [ $# -ne 4 -a $# -ne 5 ]; then
15   usage
16   exit 1
17 fi
18
19 SRC_DIR=$1
20 if [ ! -d $SRC_DIR ]; then
21   echo "Can not find directory $SRC_DIR!"
22   exit 2
23 fi
24
25 OUTPUT_FILE=$2
26 EXT_VARIANT=$3
27 LABEL=$4
28 SIZE=$5
29
30 case $EXT_VARIANT in
31   ext4) ;;
32   *) echo "Only ext4 is supported!"; exit 3 ;;
33 esac
34
35 if [ -z $LABEL ]; then
36   echo "Label is required"
37   exit 2
38 fi
39
40 if [ -z $SIZE ]; then
41     SIZE=128M
42 fi
43
44 echo "make_ext4fs -l $SIZE -a $LABEL $OUTPUT_FILE $SRC_DIR"
45 make_ext4fs -l $SIZE -a $LABEL $OUTPUT_FILE $SRC_DIR
46 if [ $? -ne 0 ]; then
47   exit 4
48 fi