-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdyn.sh
More file actions
executable file
·140 lines (137 loc) · 4.52 KB
/
Copy pathdyn.sh
File metadata and controls
executable file
·140 lines (137 loc) · 4.52 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
#Variables
LOCALDIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
payload_extractor="$LOCALDIR/payload/payload_dumper.py"
outdir="$LOCALDIR/cache"
tmpdir="$LOCALDIR/cache/tmp"
#let's start
echo "Create temp and cache dir"
mkdir -p "$outdir"
mkdir -p "$tmpdir"
echo "Extracting Required Partitions . . . . "
if [ $1 = "Generic" ]; then
bash $LOCALDIR/zip2img.sh $2 $outdir
bash $LOCALDIR/zip2img.sh $2 $outdir --product
mv $outdir/system.img $outdir/system-old.img
elif [ $1 = "MIUI" ]; then
bash $LOCALDIR/zip2img.sh $2 $outdir
bash $LOCALDIR/zip2img.sh $2 $outdir --product
mv $outdir/system.img $outdir/system-old.img
elif [ $1 = "OxygenOS" ]; then
unzip $2 -d $tmpdir &> /dev/null
python $payload_extractor --out $outdir $tmpdir/payload.bin &> /dev/null
mv $outdir/system.img $outdir/system-old.img
elif [ $1 = "Pixel" ]; then
unzip $2 -d $tmpdir &> /dev/null
unzip $tmpdir/*/*.zip -d $tmpdir &> /dev/null
simg2img $tmpdir/system.img $outdir/system-old.img
simg2img $tmpdir/product.img $outdir/product.img
simg2img $tmpdir/system_other.img $outdir/system_other.img
if [ -f "$tmpdir/system_ext.img" ]; then
simg2img $tmpdir/system_ext.img $outdir/system_ext.img
fi
fi
rm -rf $tmpdir
echo "Creating Dummy System Image . . . . "
dd if=/dev/zero of=$outdir/system.img bs=4k count=1048576
mkfs.ext4 $outdir/system.img
tune2fs -c0 -i0 $outdir/system.img
echo "Merging system . . . . "
mkdir system
mkdir system-old
mount -o loop $outdir/system.img system/
mount -o ro $outdir/system-old.img system-old/
cp -v -r -p system-old/* system/ &> /dev/null
sync
umount system-old
rm $outdir/system-old.img
rmdir system-old/
echo "Merging product . . . . "
rm -rf system/product
ln -s system/product system/product
rm -rf system/system/product
mkdir system/system/product
sudo mkdir $outdir/product
mount -o ro $outdir/product.img $outdir/product
cp -v -r -p $outdir/product/* system/system/product/ &> /dev/null
sync
umount $outdir/product
rmdir $outdir/product/
rm $outdir/product.img
if [ $1 = "OxygenOS" ]; then
if [ -f "$outdir/opproduct.img" ]; then
echo "Merging opproduct . . . . "
sudo mkdir $outdir/opproduct
mount -o ro $outdir/opproduct.img $outdir/opproduct/
cp -v -r -p $outdir/opproduct/* system/oneplus/ &> /dev/null
sync
umount $outdir/opproduct
rmdir $outdir/opproduct/
rm $outdir/opproduct.img
fi
if [ -f "$outdir/reserve.img" ]; then
echo "Merging reserve . . . . "
sudo mkdir $outdir/reserve
mount -o ro $outdir/reserve.img $outdir/reserve/
cp -v -r -p $outdir/reserve/* system/system/reserve/ &> /dev/null
sync
umount $outdir/reserve
rmdir $outdir/reserve/
rm $outdir/reserve.img
fi
echo "Merging overlays . . . . "
sudo mkdir $outdir/vendor
mount -o ro $outdir/vendor.img $outdir/vendor/
cp -r $outdir/vendor/overlay $outdir
rm -rf $outdir/overlay/*.apk
cp -v -r -p $outdir/overlay/* system/system/product/overlay/ &> /dev/null
sync
rm -rf $outdir/overlay
umount $outdir/vendor
rmdir $outdir/vendor/
rm $outdir/vendor.img
if [ -f "$outdir/system_ext.img" ]; then
echo "Merging system_ext . . . . "
sudo mkdir $outdir/system_ext
mount -o ro $outdir/system_ext.img $outdir/system_ext/
rm -rf system/system_ext
rm -rf system/system/system_ext
mkdir system/system/system_ext
ln -s system/system_ext system/system_ext
cp -v -r -p $outdir/system_ext/* system/system/system_ext/ &> /dev/null
sync
umount $outdir/system_ext
rmdir $outdir/system_ext/
rm $outdir/system_ext.img
fi
elif [ $1 = "Pixel" ]; then
echo "Merging system_other . . . . "
mkdir $outdir/system_other
mount -o ro $outdir/system_other.img $outdir/system_other/
cp -v -r -p $outdir/system_other/* system/system/ &> /dev/null
sync
umount $outdir/system_other
rmdir $outdir/system_other/
rm $outdir/system_other.img
if [ -f "$outdir/system_ext.img" ]; then
echo "Merging system_ext . . . . "
mkdir $outdir/system_ext
mount -o ro $outdir/system_ext.img $outdir/system_ext/
rm -rf system/system_ext
rm -rf system/system/system_ext
mkdir system/system/system_ext
ln -s system/system_ext system/system_ext
cp -v -r -p $outdir/system_ext/* system/system/system_ext/ &> /dev/null
sync
umount $outdir/system_ext
rmdir $outdir/system_ext/
rm $outdir/system_ext.img
fi
fi
echo "Finalising "
cp -r system working/ &> /dev/null
umount system
rm -rf cache
rm -rf system
rm -rf $outdir/system.img
echo "Dynamic Script Done"