-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdeodex.sh
More file actions
executable file
·136 lines (119 loc) · 2.84 KB
/
deodex.sh
File metadata and controls
executable file
·136 lines (119 loc) · 2.84 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
#!/bin/bash
PWD=`pwd`
SMALI=${PORT_TOOLS}/smali
BAKSMALI=${PORT_TOOLS}/baksmali
OUT_SMALI=${PORT_ROOT}/device/smali_out
#SIGNAPK_JAR=${PORT_TOOLS}/signapk.jar
#SIGNAPK=${PORT_TOOLS}/sign.sh
#KEYPATH=${PORT_BUILD}/res-build/oppo-security
#PEMKEY=$KEYPATH/platform.x509.pem
#PK8KEY=$KEYPATH/platform.pk8
mkdir -p $OUT_SMALI
function deodex_one_file() {
if [ "$1" = '-a' ]
then
apilevel=$2
file=$3
out=${OUT_SMALI}/${file}_out
tofile=${file/odex/$4}
echo "processing $tofile"
$BAKSMALI -a $apilevel -o $out -d framework -I -x $file || exit -2
else
file=$1
out=${OUT_SMALI}/${file}_out
tofile=${file/odex/$2}
echo "processing $tofile $out"
$BAKSMALI -o $out -d framework -I -x $file || exit -2
fi
$SMALI $out -o classes.dex || exit -2
jar uf $tofile classes.dex
rm classes.dex
#rm -rf $out
rm $file
#oppo.zyx:add sign
#echo "extension: ${${tofile}##*.}"
#java -Xmx512M -jar $SIGNAPK PEMKEY PK8KEY ${tofile} ${tofile}.signed
#$ZIPALIGN 4 $tofile $tofile.aligned
#$ZIPALIGN 4 ${tofile}.signed $tofile.aligned
#mv $tofile.aligned $tofile
}
#usage
if [ $1 = '--help' ]
then
echo "usage: ./deodex.sh [-a APILevel] absolute_path_to_ota_zip_file"
echo " -a specify APILevel, default Level is 15"
exit 0
fi
if [ ! -x $BAKSMALI -o ! -x $SMALI ]
then
echo "Error: Can not find tool baksmali/smali"
exit -1
fi
if [ $1 = '-a' ]
then
apilevel=$2
orignzip=$3
else
orignzip=$1
fi
temppath=`pwd`
tempdir=`mktemp -p $temppath -d tempdir.XXX`
echo "temp dir: $tempdir"
echo "unzip $stockzip to $tempdir"
unzip -q $orignzip -d $tempdir
if [ -d $tempdir/system ]
then
cd $tempdir/system
elif [ -d $tempdir/SYSTEM ]
then
cd $tempdir/SYSTEM
else
echo "can't find system or SYSTEM dir in $tempdir"
exit -1
fi
ls framework/core.odex > /dev/null
if [ $? -eq 0 ]
then
if [ $1 = '-a' ]
then
deodex_one_file -a $apilevel framework/core.odex jar
else
deodex_one_file framework/core.odex jar
fi
fi
ls framework/*.odex > /dev/null
if [ $? -eq 0 ]
then
for file in framework/*.odex
do
if [ $1 = '-a' ]
then
deodex_one_file -a $apilevel $file jar
else
deodex_one_file $file jar
fi
done
fi
ls app/*.odex > /dev/null
if [ $? -eq 0 ]
then
for file in app/*.odex
do
if [ $1 = '-a' ]
then
deodex_one_file -a $apilevel $file apk
else
deodex_one_file $file apk
fi
done
fi
cd $tempdir
echo "zip deodexed update package!!!"
zip -q -r -y update.deodexed.zip .
echo "${PWD}"
cd ${PORT_ROOT}/device
mv $tempdir/update.deodexed.zip update.deodexed.zip
rm -rf $tempdir
rm -rf ${OUT_SMALI}
echo "deodex ${orignzip} ok"
echo "output package is update.deodexed.zip"