forked from rayae/OpenGapps-For-Magisk-Converter
-
Notifications
You must be signed in to change notification settings - Fork 2
/
convert-opengappss-to-magisk.sh
executable file
·114 lines (83 loc) · 1.58 KB
/
convert-opengappss-to-magisk.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
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
#!/bin/bash
usage(){
echo "
usage : $0 <opengapps flashable zip file> <output directory>
e.g : $0 gapps.zip ./magisk-template/system
"
}
#blacklist for skip convert
blacklist=(
googleonetimeinitializer-all
gmssetup-all
setupwizarddefault-all
setupwizardtablet-all
googlepartnersetup-all
packageinstallergoogle-all
carriersetup-all
backuprestore-all
googlebackuptransport-all
)
# check_compatibility(){
# if [ zip 1> ]
# echo "
# Have you installed : tar lzip zip
# "
# exit 1
# }
clean_up(){
echo "[EXIT] CLEAN UP"
cd "$src"
rm -rf "$tmp"
}
if test -z "$1" || test -z "$2";then
usage
exit 1
fi
opengapps="$PWD/$1"
output="$PWD/$2"
src="$PWD"
tmp="$PWD/.converting-$(date +%s)"
# check_compatibility
trap clean_up EXIT
set -e
mkdir "$tmp"
echo "Unzipping $opengapps..."
unzip -q "$opengapps" -d "$tmp/gapps"
cd "$tmp/gapps/Core/"
for f in *.tar.lz
do
echo "Unpacking...Core/$f"
lzip -cd "$f" | tar x
done
cd "$src"
cd "$tmp/gapps/GApps/"
for f in *.tar.lz
do
echo "Unpacking...GApps/$f"
lzip -cd "$f" | tar x
done
cd "$src"
rm -rf "$output"
mkdir "$output"
for dir in `find "$tmp/gapps/Core" "$tmp/gapps/GApps" -maxdepth 1 -type d`
do
bn=$(basename "$dir")
if [[ "${blacklist[@]}" =~ "$bn" ]];then
echo "[BLACKLIST] Skip convert -> $bn"
continue
fi
if test -d "$dir/common";then
echo "[CONVERT] $bn --> type:common"
cd "$dir/common"
cp -rf * "$output/"
elif test -d "$dir/nodpi";then
echo "[CONVERT] $bn --> type:nodpi"
cd "$dir/nodpi"
cp -rf * "$output/"
else
echo "Matched nothins in $dir"
fi
done
cd "$src"
echo "Wow, converted!"
exit 0