-
Notifications
You must be signed in to change notification settings - Fork 4
/
extract_images.sh
executable file
·52 lines (40 loc) · 1.08 KB
/
extract_images.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/bin/bash
IMG_DIR=$1
if [ ! -d $IMG_DIR ];then
echo "Usage: $0 <path to otafirmware/images>"
exit 0
fi
SYSTEM_IMG=$1/system.img
VENDOR_IMG=$1/vendor.img
PRODUCT_IMG=$1/product.img
SYSTEM_RAW=system.raw
VENDOR_RAW=vendor.raw
PRODUCT_RAW=product.raw
OUT_DIR=extracted_images_$(date +%s)
mkdir -p $OUT_DIR
OUT_DIR=$(readlink -f $OUT_DIR)
mkdir -p $OUT_DIR/tmp
OUT_TMP_DIR=$(readlink -f $OUT_DIR/tmp)
echo "[i] Converting system.img to system.raw"
simg2img $SYSTEM_IMG $OUT_TMP_DIR/$SYSTEM_RAW
echo "[i] Converting vendor.img to vendor.raw"
simg2img $VENDOR_IMG $OUT_TMP_DIR/$VENDOR_RAW
echo "[i] Converting product.img to product.raw"
simg2img $PRODUCT_IMG $OUT_TMP_DIR/$PRODUCT_RAW
cd $OUT_DIR
echo "[i] Extracting system.raw"
7z x $OUT_TMP_DIR/$SYSTEM_RAW
echo "[i] Extracting vendor.raw"
cd vendor
7z x $OUT_TMP_DIR/$VENDOR_RAW
cd ..
echo "[i] Extracting product.raw"
cd product
7z x $OUT_TMP_DIR/$PRODUCT_RAW
cd ..
cd $OUT_DIR/system
rm -rf vendor
rm -rf product
echo "[i] Creating symlinks and finishing up! OUT_DIR=$OUT_DIR"
ln -s $OUT_DIR/vendor ./vendor
ln -s $OUT_DIR/product ./product