forked from pelya/debian-noroot
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sh
executable file
·124 lines (108 loc) · 4.19 KB
/
build.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
#!/bin/sh
fail() { echo "Compilation failed!" ; exit 1; }
false && { # ===== Do not compile libfakechroot and libfakedns, they are not used anymore =====
cd fakechroot
[ -e configure ] || ./autogen.sh || fail
[ -e config.h ] || ./configure --host=arm-linux-gnueabihf --prefix=/usr || fail
[ -e ../libfakechroot.so ] || {
make -j4 CFLAGS="-march=armv7-a -fpic" LDFLAGS="-march=armv7-a" V=1 && \
cp -f src/.libs/libfakechroot.so .. && \
arm-linux-gnueabihf-strip ../libfakechroot.so || fail
} || fail
cd ..
cd c-ares
[ -e ares_config.h ] || LIBS=-Wl,--version-script=exports.txt \
./configure --enable-shared --host=arm-linux-gnueabihf --prefix=/usr || fail
[ -e ../libfakedns.so ] || {
make -j4 CFLAGS="-march=armv7-a -fpic" LDFLAGS="-march=armv7-a" libcares.la && \
cp -f .libs/libcares.so ../libfakedns.so && \
arm-linux-gnueabihf-strip ../libfakedns.so || fail
} || fail
cd ..
[ -e libfakedns.so ] || {
arm-linux-gnueabihf-gcc -march=armv7-a -shared -fpic fakedns/*.c -I c-ares c-ares/.libs/libcares.a -o libfakedns.so && \
arm-linux-gnueabihf-strip libfakedns.so || fail
} || fail
} # ===== libfakechroot and libfakedns =====
[ -e dist/libdisableselinux.so ] || {
arm-linux-gnueabihf-gcc -march=armv7-a -shared -fpic disableselinux/*.c -o dist/libdisableselinux.so && \
arm-linux-gnueabihf-strip dist/libdisableselinux.so || fail
} || fail
[ -e dist/libandroid-shmem.so ] || {
[ -e android-shmem/LICENSE ] || {
cd ..
git submodule update --init android/android-shmem || fail
cd $BUILDDIR
} || exit 1
[ -e android-shmem/libancillary/ancillary.h ] || {
cd android-shmem
git submodule update --init libancillary || fail
cd ..
} || exit 1
cd android-shmem
arm-linux-gnueabihf-gcc -march=armv7-a -shared -fpic -std=gnu99 -flto *.c -I . -I libancillary \
-o ../dist/libandroid-shmem.so -Wl,--version-script=exports.txt -lc -lpthread && \
arm-linux-gnueabihf-strip ../dist/libandroid-shmem.so || fail
cd ..
} || fail
[ -e libtalloc.a ] || {
[ -e talloc-2.1.0 ] || curl -L http://www.samba.org/ftp/talloc/talloc-2.1.0.tar.gz | tar xvz || fail
cd talloc-2.1.0
make clean
env CC=arm-linux-gnueabihf-gcc CFLAGS="-flto -fpic" LD=arm-linux-gnueabihf-gcc LDFLAGS="-flto" ./configure build --cross-compile --cross-execute='qemu-arm-static /usr/arm-linux-gnueabihf/lib/ld-linux.so.3 --library-path /usr/arm-linux-gnueabihf/lib' || fail
#cp -f libtalloc.so ../libtalloc.so || fail
ar rcs ../libtalloc.a bin/default/talloc*.o # bin/default/lib/replace/replace*.o
cd ..
} || fail
[ -e dist/proot ] || {
cd proot-src
git clean -f -d -x
git checkout -f
patch -p1 < ../proot-android.patch || fail
cd src
ln -sf `which arm-linux-gnueabihf-strip` strip
ln -sf `which arm-linux-gnueabihf-objcopy` objcopy
ln -sf `which arm-linux-gnueabihf-objdump` objdump
env PATH=`pwd`:$PATH CC=arm-linux-gnueabihf-gcc \
CFLAGS="-I../../talloc-2.1.0 -Wall -Wextra -O2 -flto -fpic" \
LDFLAGS="-L../.. -ltalloc -static -flto" \
V=1 make -e || fail
rm -f strip objcopy objdump
cp proot ../../dist/
cd ../..
arm-linux-gnueabihf-strip dist/proot
} || fail
CFLAGSx86="-march=i686 -mtune=atom -mstackrealign -msse3 -mfpmath=sse -m32 -flto -fpic"
[ -e dist-x86/libdisableselinux.so ] || {
gcc $CFLAGSx86 -shared -fpic disableselinux/*.c -o dist-x86/libdisableselinux.so && \
strip dist-x86/libdisableselinux.so || fail
} || fail
[ -e dist-x86/libandroid-shmem.so ] || {
cd android-shmem
gcc $CFLAGSx86 -shared -fpic -std=gnu99 *.c -I . -I libancillary \
-o ../dist-x86/libandroid-shmem.so -Wl,--version-script=exports.txt -lc -lpthread && \
strip ../dist-x86/libandroid-shmem.so || fail
cd ..
} || fail
[ -e libtalloc-x86.a ] || {
cd talloc-2.1.0
make clean
env CC=gcc CFLAGS="$CFLAGSx86 -fno-lto" LD=gcc LDFLAGS="$CFLAGSx86 -fno-lto" ./configure build || fail
#cp -f libtalloc.so ../libtalloc.so || fail
ar rcs ../libtalloc-x86.a bin/default/talloc*.o # bin/default/lib/replace/replace*.o
cd ..
} || fail
[ -e dist-x86/proot ] || {
cd proot-src
git clean -f -d -x
git checkout -f
patch -p1 < ../proot-android.patch || fail
cd src
env CC="gcc $CFLAGSx86" \
CFLAGS="-I../../talloc-2.1.0 -Wall -Wextra -O2" \
LDFLAGS="-L../.. -ltalloc-x86 -static" \
V=1 make -e || fail
cp proot ../../dist-x86/
cd ../..
strip dist-x86/proot
} || fail