-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path02zipalign
80 lines (72 loc) · 2.75 KB
/
02zipalign
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
#!/system/bin/sh
# Automatic ZipAlign by Wes Garner
# ZipAlign files in /data that have not been previously ZipAligned (using md5sum)
# Thanks to oknowton for the changes
# Changelog:
# 1.1 (12/1/09) Switched to zipalign -c 4 to check the apk instead of MD5 (oknowton)
# 1.0 (11/30/09) Original
# Output the script name for easier run-parts debugging
echo Now running $0
mkdir -p /data/logs/
LOG_FILE=/data/logs/zipalign.log
# If we find the log file and it's 7 days old, then we delete it
find $LOG_FILE -type f -mtime +7
if test -f $LOG_FILE; then
# If the log was found by now, it means it was less than a week old, so we exit
echo ' zipalign was run less than 7 days ago, exiting'
exit
fi
# Since it's been more than a week since we ran the zipalign, create a new log file
rm -rf $LOG_FILE
echo "Starting Automatic ZipAlign $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;
for apk in /data/app/*.apk ; do
zipalign -c 4 $apk;
ZIPCHECK=$?;
if [ $ZIPCHECK -eq 1 ]; then
echo ZipAligning $(busybox basename $apk) | tee -a $LOG_FILE;
zipalign -f 4 $apk /cache/$(basename $apk);
if [ -e /cache/$(busybox basename $apk) ]; then
cp -f -p /cache/$(busybox basename $apk) $apk | tee -a $LOG_FILE;
rm /cache/$(busybox basename $apk);
else
echo ZipAligning $(busybox basename $apk) Failed | tee -a $LOG_FILE;
fi;
else
echo ZipAlign already completed on $apk | tee -a $LOG_FILE;
fi;
done;
echo "Attempting to zipalign frameworks";
for apk1 in /system/framework/*.apk ; do
zipalign -c 4 $apk1;
ZIPCHECK1=$?;
if [ $ZIPCHECK1 -eq 1 ]; then
# echo ZipAligning $(busybox basename $apk1) | tee -a $LOG_FILE;
# zipalign -f 4 $apk1 /cache/$(busybox basename $apk1);
# if [ -e /cache/$(busybox basename $apk1) ]; then
# cp -f -p /cache/$(busybox basename $apk1) $apk1 | tee -a $LOG_FILE;
# rm /cache/$(busybox basename $apk1);
# else
# echo ZipAligning $(busybox basename $apk1) Failed | tee -a $LOG_FILE;
# fi;
# else
# echo ZipAlign already completed on $apk1 | tee -a $LOG_FILE;
# fi;
# done;
# echo "Attempting to zipalign system apps";
# for apk1 in /system/app/*.apk ; do
# zipalign -c 4 $apk1;
# ZIPCHECK1=$?;
# if [ $ZIPCHECK1 -eq 1 ]; then
echo ZipAligning $(busybox basename $apk1) | tee -a $LOG_FILE;
zipalign -f 4 $apk1 /cache/$(busybox basename $apk1);
if [ -e /cache/$(busybox basename $apk1) ]; then
cp -f -p /cache/$(busybox basename $apk1) $apk1 | tee -a $LOG_FILE;
rm /cache/$(busybox basename $apk1);
else
echo ZipAligning $(busybox basename $apk1) Failed | tee -a $LOG_FILE;
fi;
else
echo ZipAlign already completed on $apk1 | tee -a $LOG_FILE;
fi;
done;
echo "Automatic ZipAlign finished at $( date +"%m-%d-%Y %H:%M:%S" )" | tee -a $LOG_FILE;