forked from apk-spectrum/apk-scanner
-
Notifications
You must be signed in to change notification settings - Fork 0
/
debian_setup.sh
executable file
·201 lines (181 loc) · 8.23 KB
/
debian_setup.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
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
#!/bin/bash
APP_PATH="/opt/APKScanner"
APP_VERSION="2.6"
APP_FILE="ApkScanner.jar"
DEBIAN_DATA_PATH="./debian"$APP_PATH
rm -rf ./debian
##############################
# make contorl file
##############################
mkdir -p ./debian/DEBIAN
cat << EOF > ./debian/DEBIAN/control
Package: apk-scanner
Version: $APP_VERSION-1
Section: utils
Architecture: all
Maintainer: Sunggyu Kam <[email protected]>
Installed-Size: 157,130,534
Description: APK Scanner $APP_VERSION
EOF
cat ./debian/DEBIAN/control
##############################
# copy for release data
##############################
TARGET_PATH="$DEBIAN_DATA_PATH/"
mkdir -p "$TARGET_PATH"
cp -f "release/ApkScanner.jar" "$TARGET_PATH"
cp -f "res/icons/AppIcon.png" "$TARGET_PATH"
TARGET_PATH="$DEBIAN_DATA_PATH/data/build-master-target-product-security/"
mkdir -p "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/Android.mk" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/media.pk8" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/media.x509.pem" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/platform.pk8" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/platform.x509.pem" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/README" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/shared.pk8" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/shared.x509.pem" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/testkey.pk8" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/testkey.x509.pem" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/verity.pk8" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/verity.x509.pem" "$TARGET_PATH"
cp -f "release/data/build-master-target-product-security/verity_key" "$TARGET_PATH"
TARGET_PATH="$DEBIAN_DATA_PATH/lib/"
mkdir -p "$TARGET_PATH"
cp -f "release/lib/autocomplete-2.6.0.jar" "$TARGET_PATH"
cp -f "release/lib/commons-cli-1.3.1.jar" "$TARGET_PATH"
cp -f "release/lib/ddmlib.jar" "$TARGET_PATH"
cp -f "release/lib/guava-18.0.jar" "$TARGET_PATH"
cp -f "release/lib/jna-4.4.0.jar" "$TARGET_PATH"
cp -f "release/lib/jna-platform-4.4.0.jar" "$TARGET_PATH"
cp -f "release/lib/json-simple-1.1.1.jar" "$TARGET_PATH"
cp -f "release/lib/libwebp-imageio64.so" "$TARGET_PATH"
cp -f "release/lib/luciad-webp-imageio.jar" "$TARGET_PATH"
cp -f "release/lib/mslinks.jar" "$TARGET_PATH"
cp -f "release/lib/rstaui-2.6.0.jar" "$TARGET_PATH"
cp -f "release/lib/rsyntaxtextarea-2.6.1.jar" "$TARGET_PATH"
TARGET_PATH="$DEBIAN_DATA_PATH/lib/proxy-vole"
mkdir -p "$TARGET_PATH"
cp -f "release/lib/proxy-vole/delight-nashorn-sandbox-0.1.11.jar" "$TARGET_PATH"
cp -f "release/lib/proxy-vole/ini4j-0.5.4.jar" "$TARGET_PATH"
cp -f "release/lib/proxy-vole/js-beautify-1.6.12.jar" "$TARGET_PATH"
cp -f "release/lib/proxy-vole/proxy-vole-1.0.5.jar" "$TARGET_PATH"
cp -f "release/lib/proxy-vole/slf4j-api-1.7.25.jar" "$TARGET_PATH"
TARGET_PATH="$DEBIAN_DATA_PATH"
cp -rf "release/plugin" "$TARGET_PATH"
TARGET_PATH="$DEBIAN_DATA_PATH/security"
mkdir -p "$TARGET_PATH"
cp -f "release/security/trustStore.jks" "$TARGET_PATH"
TARGET_PATH="$DEBIAN_DATA_PATH/tool/"
mkdir -p "$TARGET_PATH"
cp -f "release/tool/aapt" "$TARGET_PATH"
cp -f "release/tool/adb" "$TARGET_PATH"
cp -f "release/tool/apktool.jar" "$TARGET_PATH"
cp -f "release/tool/Bytecode-Viewer-2.9.22.jar" "$TARGET_PATH"
cp -f "release/tool/d2j_invoke.sh" "$TARGET_PATH"
cp -f "release/tool/d2j-dex2jar.sh" "$TARGET_PATH"
cp -f "release/tool/jd-gui-1.6.2.jar" "$TARGET_PATH"
cp -f "release/tool/jd_icon_128.png" "$TARGET_PATH"
cp -f "release/tool/libAaptNativeWrapper32.so" "$TARGET_PATH"
cp -f "release/tool/libAaptNativeWrapper64.so" "$TARGET_PATH"
cp -f "release/tool/libc++32.so" "$TARGET_PATH"
cp -f "release/tool/libc++64.so" "$TARGET_PATH"
cp -f "release/tool/signapk.jar" "$TARGET_PATH"
cp -rf "release/tool/jadx" "$TARGET_PATH"
cp -rf "release/tool/lib" "$TARGET_PATH"
cp -rf "release/tool/lib64" "$TARGET_PATH"
##############################
# etc
##############################
cat << EOF > $DEBIAN_DATA_PATH/APKScanner.sh
#!/bin/bash
java -Xms512m -Xmx1024m -jar $APP_PATH/$APP_FILE "\$@" > /dev/null
EOF
chmod 775 $DEBIAN_DATA_PATH/APKScanner.sh
echo "{}" > $DEBIAN_DATA_PATH/settings.txt
chmod 666 $DEBIAN_DATA_PATH/settings.txt
chmod 666 $DEBIAN_DATA_PATH/plugin/plugins.conf
chmod 666 $DEBIAN_DATA_PATH/security/trustStore.jks
mkdir -p ./debian/usr/share/applications/
cat << EOF > ./debian/usr/share/applications/apkscanner.desktop
[Desktop Entry]
Encoding=UTF-8
Version=$APP_VERSION
Type=Application
Exec=java -jar $APP_PATH/$APP_FILE %f
Name=APK Scanner
Comment=APK Scanner
Icon=$APP_PATH/AppIcon.png
MimeType=application/apk;application/vnd.android.package-archive;
EOF
cat << POST_EOF > ./debian/DEBIAN/postinst
#!/bin/bash
echo postinst
if [ ! -e /usr/share/mime/application/vnd.android.package-archive.xml ]; then
cat << EOF > ./vnd.android.package-archive.xml
<?xml version="1.0" encoding="utf-8"?>
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
<!--Created automatically by update-mime-database. DO NOT EDIT!-->
<mime-type type="application/vnd.android.package-archive">
<comment>Android package</comment>
<comment xml:lang="bg">Пакет — Android</comment>
<comment xml:lang="ca">paquet d'Android</comment>
<comment xml:lang="cs">Balíčky systému Android</comment>
<comment xml:lang="de">Android-Paket</comment>
<comment xml:lang="en_AU">Android package</comment>
<comment xml:lang="en_GB">Android package</comment>
<comment xml:lang="eo">Android-pakaĵo</comment>
<comment xml:lang="es">Paquete de Android</comment>
<comment xml:lang="fi">Android-paketti</comment>
<comment xml:lang="fr">paquet Android</comment>
<comment xml:lang="gl">paquete de Android</comment>
<comment xml:lang="he">חבילת אנדרויד</comment>
<comment xml:lang="hu">Android csomag</comment>
<comment xml:lang="id">Paket Android</comment>
<comment xml:lang="it">Pacchetto Android</comment>
<comment xml:lang="ja">Android パッケージ</comment>
<comment xml:lang="kk">Android дестесі</comment>
<comment xml:lang="ko">안드로이드 패키지</comment>
<comment xml:lang="lv">Android pakotne</comment>
<comment xml:lang="pl">Pakiet Androida</comment>
<comment xml:lang="pt_BR">Pacote Android</comment>
<comment xml:lang="ru">пакет Android</comment>
<comment xml:lang="sl">Paket Android</comment>
<comment xml:lang="sv">Android-paket</comment>
<comment xml:lang="uk">пакунок Android</comment>
<comment xml:lang="zh_CN">Android</comment>
<comment xml:lang="zh_TW">Android 套件</comment>
<sub-class-of type="application/x-java-archive"/>
<glob pattern="*.apk"/>
</mime-type>
</mime-info>
EOF
sudo cp -f ./vnd.android.package-archive.xml /usr/share/mime/packages/
sudo update-mime-database /usr/share/mime/
sudo rm -f /usr/share/mime/packages/vnd.android.package-archive.xml
fi
if [ -e ~/.local/share/applications/mimeapps.list ]; then
cp -f ~/.local/share/applications/mimeapps.list ~/.local/share/applications/mimeapps_old.list
cat ~/.local/share/applications/mimeapps_old.list \
| sed '/application\/vnd\.android\.package-archive\=/d;/^$/d' \
| sed 's/^\s*\[.*\]\s*$/&\napplication\/vnd.android.package-archive=apkscanner.desktop;/' > ~/.local/share/applications/mimeapps.list
else
cat << EOF > ~/.local/share/applications/mimeapps.list
[Added Associations]
application/vnd.android.package-archive=apkscanner.desktop;
EOF
fi
if [ -e ~/.p4qt/ApplicationSettings.xml ]; then
cat ~/.p4qt/ApplicationSettings.xml | sed '/EditorMappings/,/StringList/{/<String>apk/d; /<String>ppk/d; s/.*<\/StringList>.*/ <String>apk\|default\|\/opt\/APKScanner\/APKScanner\.sh<\/String>\n <String>ppk\|default\|\/opt\/APKScanner\/APKScanner\.sh<\/String>\n <\/StringList>/}' > .ApplicationSettings.xml
chmod 666 .ApplicationSettings.xml
mv .ApplicationSettings.xml ~/.p4qt/ApplicationSettings.xml
fi
echo end postinst
POST_EOF
chmod 775 ./debian/DEBIAN/postinst
##############################
# build
##############################
dpkg-deb --build debian
mv ./debian.deb ./APKScanner.deb
rm -rf ./debian