forked from smarek/android-unbound-dns
-
Notifications
You must be signed in to change notification settings - Fork 2
/
package.sh
executable file
·52 lines (42 loc) · 1.65 KB
/
package.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
#!/bin/bash
source _setenv_android.bash
# Will fail on default OSX, use gsed provided by Homebrew or edit first line manually to be #!/system/bin/sh
_SED=sed
# remove old files
rm -rf package.zip
rm -rf package
mkdir package
# copy over all built binaries and support files
rsync -aqP $_EXPAT_NAME/build/ package/
rsync -aqP $_LIBEVENT_NAME/build/ package/
rsync -aqP $_OPENSSL_NAME/build/ package/
rsync -aqP $_UNBOUND_NAME/build/ package/
# normalize binary paths
mv package/sbin/* package/bin/
# delete unnecessary stuff
rm -rf package/share/
rm -rf package/lib/pkgconfig/
rm -rf package/ssl/man/
rm -rf package/sbin
rm -rf package/include
rm -f package/bin/c_rehash
find package -name '*.a' -exec rm -f {} \;
find package -name '*.la' -exec rm -f {} \;
find package -name '*.py' -exec rm -f {} \;
# move ssl support folder to bin folder for sake of usability
mv package/ssl package/bin/
# put custom unbound.conf instead of default ones
cp unbound.conf package/bin/unbound.conf.default
cp env.sh package/bin/
# replace default shell with /system/bin/sh available android-wide
$_SED -i "1s/.*/#\!\/system\/bin\/sh/" package/bin/unbound-control-setup
$_SED -i "1s/.*/#\!\/system\/bin\/sh/" package/bin/ssl/misc/c_hash
$_SED -i "1s/.*/#\!\/system\/bin\/sh/" package/bin/ssl/misc/c_info
$_SED -i "1s/.*/#\!\/system\/bin\/sh/" package/bin/ssl/misc/c_issuer
$_SED -i "1s/.*/#\!\/system\/bin\/sh/" package/bin/ssl/misc/c_name
# Set binaries executable
chmod +x package/bin/*
# Create ZIP distribution package
zip -rq package.zip package
# Copy ZIP over old one within Android sources
test -d Android/app/src/main/assets && cp package.zip Android/app/src/main/assets/package.zip