-
Notifications
You must be signed in to change notification settings - Fork 0
/
shit.sh
57 lines (40 loc) · 1.63 KB
/
shit.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
#!/bin/bash
# Remove files what can interfere with script and unpack APK (it's just zip archive)
# Don't launch me in directory with other files!!!
rm shit.bmp shit.png tmp.jar shit_oldfague.apk files-to-compress
rm -r shit
unzip -d shit "$1"
zipinfo -1 "$1" | grep -v ^META-INF/ > files-to-compress
# do some uglify with images
find shit -iname "*.jpg" -o -iname "*.jpeg" | while read aa; do convert "$aa" shit.bmp; convert shit.bmp -quality 10 "$aa";rm shit.bmp;done
find shit -iname "*.png" | while read aa; do rm shit.bmp
echo "Processing $aa"
convert "$aa" -ordered-dither o8x8 shit.bmp
optipng -O2 shit.bmp
mv shit.png "$aa"
done
# multiple volume in sounds by 100 times!
find shit -iname "*.ogg" | while read aa; do rm
ffmpeg -nostdin -i "$aa" -af volume=100 -y shit.ogg
echo "Processing $aa"
mv shit.ogg "$aa"
done
find shit -iname "*.mp3" | while read aa; do rm
ffmpeg -nostdin -i "$aa" -af volume=100 -y shit.mp3
echo "Processing $aa"
mv shit.mp3 "$aa"
done
# repack it back!
# do it without any aapt or other shit
cd shit
cat ../files-to-compress | grep ^assets/ | zip -0 -D -X ../tmp.jar -@
cat ../files-to-compress | grep -v ^assets/ | zip -9 -D -X ../tmp.jar -@
cd ..
# Generate new key, if here none
[ ! -e "shit.key" ] && keytool -genkey -keyalg rsa -keystore shit.key -storepass shit123 -keypass shit123 -alias shit -keysize 1024 -dname "CN=1, OU=2, O=shit" -validity 10000
# Signing apk with our key
jarsigner -verbose -keypass shit123 -storepass shit123 -keystore shit.key tmp.jar shit
# Align. Well, not very need, but can improve perfomance.
zipalign 4 tmp.jar shit_oldfague.apk
# Remove temporary files
rm tmp.jar files-to-compress