rjw | 1f88458 | 2022-01-06 17:20:42 +0800 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | |
| 3 | |
| 4 | usage() |
| 5 | { |
| 6 | printf "The right format is:\n" |
| 7 | printf "./pack_one_image.sh <PATH_TO_IMAGE_DIR> <PARTITION_SIZE> <EXT4_IMAGE_NAME> \n" |
| 8 | exit |
| 9 | } |
| 10 | |
| 11 | |
| 12 | |
| 13 | OUTDIR=`pwd` |
| 14 | if [ -d "$1" ]; then |
| 15 | TARDIR=$OUTDIR/out/ |
| 16 | if [ $2 ] && [ $3 ]; then |
| 17 | set -e |
| 18 | $OUTDIR/tools/make_ext4fs -s -j 1 -l $2 $TARDIR/one_sparse.img $1 1> /dev/null |
| 19 | $OUTDIR/tools/simg2img $TARDIR/one_sparse.img $TARDIR/$3 |
| 20 | set +e |
| 21 | else |
| 22 | usage |
| 23 | fi |
| 24 | else |
| 25 | usage |
| 26 | fi |
| 27 | |
| 28 | |
| 29 | rm -f $TARDIR/one_sparse.img |
| 30 | |
| 31 | |
| 32 | |