forked from ezdiy/pbjb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
256 lines (223 loc) · 9.95 KB
/
Makefile
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
HOST=arm-buildroot-linux-musleabihf
cc=$(HOST)-cc
cc5=arm-obreey-linux-gnueabi-gcc
cxx5=arm-obreey-linux-gnueabi-g++
strip=$(HOST)-strip
ver=$(shell git describe --tags)
# These are made by the cross compiler
svcbins=svc/bin/dropbear svc/bin/smbd svc/bin/ntlmhash svc/bin/proftpd svc/bin/iptables svc/bin/rsync svc/bin/lighttpd svc/bin/sftp-server svc/bin/htop svc/bin/powertop svc/bin/nano svc/bin/lftp
mods=svc/etc/mod/3.10.65+
proftpd=proftpd-1.3.5e
iptables=iptables-1.8.3
samba=samba-3.6.25
rsync=rsync-3.2.3
lighttpd=lighttpd-1.4.54
openssh=openssh-8.1p1
powertop=powertop-v2.10
htop=htop-2.2.0
nano=nano-4.6
# TODO
#openvpn=openvpn-2.4.8
lftp=lftp-4.8.4
common_configure=./configure --disable-ipv6 --localstatedir=/var/run --sharedstatedir=/var --host=arm-linux-gnueabi CC=$(cc) --prefix=/mnt/secure --enable-static --disable-shared LDFLAGS="--static -Wl,-gc-sections" CFLAGS="-DPUBKEY_RELAXED_PERMS=1 -DSFTPSERVER_PATH=\\\"/mnt/secure/bin/sftp-server\\\" -DDROPBEAR_PATH_SSH_PROGRAM=\\\"/mnt/secure/bin/ssh\\\" -D__mempcpy=mempcpy -ffunction-sections -fdata-sections" --prefix=/mnt/secure --sbindir=/mnt/secure/bin --datarootdir=/mnt/secure
common_configure5=./configure --without-gnutls --with-openssl --disable-lz4 --disable-lzo --disable-ipv6 --localstatedir=/var/run --sharedstatedir=/var --host=arm-obreey-linux-gnueabi CC=$(cc5) CXX=$(cxx5) --prefix=/mnt/secure --disable-shared --prefix=/mnt/secure --sbindir=/mnt/secure/bin --datarootdir=/mnt/secure --disable-unicode --without-included-zlib --without-included-popt
SSH_CONFIG_OPTIONS=--disable-pam --disable-syslog --disable-shadow --disable-lastlog --disable-utmp --disable-utmpx --disable-wtmp --disable-wtmpx --disable-loginfunc --disable-pututline --disable-pututxline --disable-zlib
SAMBA_CONFIGURE_VARS=\
ac_cv_lib_attr_getxattr=no \
ac_cv_search_getxattr=no \
ac_cv_file__proc_sys_kernel_core_pattern=yes \
libreplace_cv_HAVE_C99_VSNPRINTF=yes \
libreplace_cv_HAVE_GETADDRINFO=yes \
libreplace_cv_HAVE_IFACE_IFCONF=yes \
libreplace_cv_HAVE_IPV6=no \
libreplace_cv_HAVE_IPV6_V6ONLY=no \
LINUX_LFS_SUPPORT=yes \
samba_cv_CC_NEGATIVE_ENUM_VALUES=yes \
samba_cv_HAVE_GETTIMEOFDAY_TZ=yes \
samba_cv_HAVE_IFACE_IFCONF=yes \
samba_cv_HAVE_KERNEL_OPLOCKS_LINUX=yes \
samba_cv_HAVE_SECURE_MKSTEMP=yes \
samba_cv_HAVE_WRFILE_KEYTAB=no \
samba_cv_USE_SETREUID=yes \
samba_cv_USE_SETRESUID=yes \
samba_cv_have_setreuid=yes \
samba_cv_have_setresuid=yes \
ac_cv_header_libunwind_h=no \
ac_cv_header_zlib_h=no \
samba_cv_zlib_1_2_3=no \
ac_cv_path_PYTHON="" \
ac_cv_path_PYTHON_CONFIG=""
SAMBA_CONFIGURE_ARGS=\
--disable-avahi \
--disable-cups \
--disable-external-libtalloc \
--disable-external-libtdb \
--disable-external-libtevent \
--disable-pie \
--disable-relro \
--enable-static \
--disable-swat \
--disable-shared-libs \
--with-codepagedir=/mnt/secure/etc/samba \
--with-configdir=/mnt/secure/etc/samba \
--with-included-iniparser \
--with-included-popt \
--with-lockdir=/var/lock \
--with-logfilebase=/var/log \
--with-nmbdsocketdir=/var/nmbd \
--with-piddir=/var/run \
--with-privatedir=/mnt/secure/etc/samba \
--with-sendfile-support \
--without-acl-support \
--without-cluster-support \
--without-ads \
--without-krb5 \
--without-ldap \
--without-pam \
--without-winbind \
--without-libtdb \
--without-libtalloc \
--without-libnetapi \
--without-libsmbclient \
--without-libsmbsharemodes \
--without-libtevent \
--without-libaddns \
--with-shared-modules=pdb_wbc_sam,idmap_nss,nss_info_template,auth_winbind,auth_wbc,auth_domain,rpc_lsarpc,rpc_samr,rpc_winreg,rpc_initshutdown,rpc_dssetup,rpc_wkssvc,rpc_svcctl,rpc_ntsvcs,rpc_netlogon,rpc_netdfs,rpc_srvsvc,rpc_spoolss,rpc_eventlog,auth_unix,auth_winbind,auth_wbc
RSYNC_CONFIGURE_ARGS=\
--disable-xxhash \
--disable-zstd \
--disable-simd
# When running just "make", package the .app files and .zip release, don't bother to track dependencies for shell sript stuff.
all: pbjb-$(ver).zip
pbjb-$(ver).zip: Jailbreak.app Services.app
zip pbjb-$(ver).zip *.app
purge: clean
rm -rf $(proftpd) $(samba) $(iptables) $(proftpd).tar.gz $(samba).tar.gz $(iptables).tar.bz2
clean:
rm -f Jailbreak.app Services.app pbjb.zip $(svcbins)
make -C $(proftpd) clean || true
make -C $(samba) clean || true
make -C $(samba)/source3 clean || true
rm -f $(samba)/auth/*.o $(samba)/source3/multi.o || true
make -C $(iptables) clean || true
make -C dropbear-hacks/src clean || true
make -C $(htop) clean || true
make -C $(openssh) clean || true
make -C $(powertop) clean || true
rm -rf $(mods)
$(mods):
make -j`nproc` -C linux-pine64 ARCH=arm CROSS_COMPILE=arm-linux-gnueabihf- modules
cd linux-pine64 && ./sortmods.sh
mkdir -p $(mods)
cp -R linux-pine64/mod/* $(mods)
su: su.c
$(cc) -s -static $< -o $@
jailbreak: jailbreak.c
$(cc) -s -static $< -o $@
Jailbreak.app: su jailbreak jailbreak-installer.sh
cat jailbreak-installer.sh | sed "s/PKGVER=.*/PKGVER=$(ver)/" > Jailbreak.app
tar --owner=0 --group=0 -cvzf - su jailbreak | tee Jailbreak.tgz >> Jailbreak.app
ctest.app: ctest.c
$(cc) -s -static $< -o $@
svc/bin/suspendd: suspendd.c
$(cc5) -s -linkview -Wall $< -o $@
Services.app: $(mods) FORCE svc
cat services-installer.sh | sed "s/PKGVER=.*/PKGVER=$(ver)/" > Services.app
tar --owner=0 --group=0 -cvzf - -C svc . | tee Services.tgz >> Services.app
#tar cvf test.tar -C svc .
svc: $(svcbins)
echo Cross-compiled service binaries
# Retrieve source codes for binaries we compile statically with musl (smaller / more portable)
$(openssh):
wget -4 -c https://cdn.openbsd.org/pub/OpenBSD/OpenSSH/portable/$(openssh).tar.gz
tar -xvzf $(openssh).tar.gz
$(lighttpd):
wget -4 -c https://download.lighttpd.net/lighttpd/releases-1.4.x/$(lighttpd).tar.gz
tar -xvzf $(lighttpd).tar.gz
$(proftpd):
wget -4 -c ftp://ftp.proftpd.org/distrib/source/$(proftpd).tar.gz
tar -xvzf $(proftpd).tar.gz
$(samba):
wget -4 -c https://download.samba.org/pub/samba/stable/$(samba).tar.gz
tar -xvzf $(samba).tar.gz
cd $(samba) && for p in ../samba-patches/*; do patch -p1 < $$p || exit 1; done
$(iptables):
wget -4 -c https://netfilter.org/projects/iptables/files/$(iptables).tar.bz2
tar -xvjf $(iptables).tar.bz2
$(rsync):
wget -4 -c https://download.samba.org/pub/rsync/src/$(rsync).tar.gz
tar -xvzf $(rsync).tar.gz
# These depend on cc5 sdk, as they need ncurses or openssl (static musl would become too big)
$(htop):
wget -4 -c https://github.com/htop-dev/htop/archive/2.2.0.tar.gz -O $(htop).tar.gz
tar -xvzf $(htop).tar.gz
$(nano):
wget -4 -c https://www.nano-editor.org/dist/v4/$(nano).tar.gz
tar -xvzf $(nano).tar.gz
#$(openvpn):
# wget -c https://swupdate.openvpn.org/community/releases/$(openvpn).tar.gz
# tar -xvzf $(openvpn).tar.gz
$(powertop):
wget -4 -c https://01.org/sites/default/files/downloads/$(powertop).tar.gz
tar -xvzf $(powertop).tar.gz
$(lftp):
wget -4 -c http://lftp.yar.ru/ftp/$(lftp).tar.gz
tar -xvzf $(lftp).tar.gz
# each of svcbin
svc/bin/dropbear: dropbear-hacks
(cd dropbear-hacks/src && $(common_configure) --verbose $(SSH_CONFIG_OPTIONS))
make -C dropbear-hacks/src PROGRAMS="dropbear dbclient scp" MULTI=1 STATIC=1
$(strip) dropbear-hacks/src/dropbearmulti -o $@
svc/bin/smbd: $(samba)
(cd $(samba)/source3 && $(common_configure) $(SAMBA_CONFIGURE_VARS) $(SAMBA_CONFIGURE_ARGS) LDFLAGS="-static -Lbin -Wl,--gc-sections")
make -C $(samba)/source3 MODULES= PICFLAG= DYNEXP=
$(strip) $(samba)/source3/bin/samba_multicall -o $@
svc/bin/ntlmhash: ntlmhash.c
$(cc) -static -s $< -o $@
# The following are linked with sdk (may not work on slightly older firmware)
svc/bin/iptables: $(iptables)
(cd $(iptables) && $(common_configure5) --disable-devel --disable-nftables --with-xt-lock-name=/var/run/xtables.lock)
make -C $(iptables)
$(strip) $(iptables)/iptables/xtables-legacy-multi -o $@
svc/bin/proftpd: $(proftpd)
(cd $(proftpd) && $(common_configure5) --disable-autoshadow --without-pic --disable-auth-pam --disable-cap --disable-facl --disable-dso --disable-trace)
make -C $(proftpd)
$(strip) $(proftpd)/proftpd -o $@
svc/bin/rsync: $(rsync)
(cd $(rsync) && $(common_configure5) $(RSYNC_CONFIGURE_ARGS) )
make -C $(rsync)
$(strip) $(rsync)/rsync -o $@
lighty_flags=--with-pic= --without-pic --with-pcre=yes --with-openssl=yes PCRE_LIB=-lpcre SSL_LIB="-lssl -lcrypto"
# --without-zlib --without-bzip2
# no_build="mod_accesslog mod_compress mod_deflate mod_evhost mod_extforward mod_fastcgi mod_flv_streaming mod_proxy mod_rrdtool mod_secdownload mod_scgi mod_sockproxy mod_userdir mod_usertrack mod_vhostddb mod_wstunnel"
svc/bin/lighttpd: $(lighttpd)
cp -f plugin-static.h $(lighttpd)/src
(cd $(lighttpd) && LIGHTTPD_STATIC=yes CPPFLAGS=-DLIGHTTPD_STATIC $(common_configure5) $(lighty_flags))
make -C $(lighttpd) lighttpd_LDFLAGS="-Wl,-gc-sections"
#LDFLAGS="-static" lighttpd_LDFLAGS="--static -Wl,-gc-sections"
$(strip) $(lighttpd)/src/lighttpd -o $@
svc/bin/htop: $(htop)
(cd $(htop) && ./autogen.sh && $(common_configure5) ac_cv_lib_ncurses_refresh=yes LIBS=-lncurses HTOP_NCURSES_CONFIG_SCRIPT=/bin/false)
make -C $(htop)
$(strip) $(htop)/htop -o $@
svc/bin/nano: $(nano)
(cd $(nano) && $(common_configure5) ac_cv_lib_ncurses_refresh=yes LIBS=-lncurses HTOP_NCURSES_CONFIG_SCRIPT=/bin/false)
make -C $(nano)
$(strip) $(nano)/src/nano -o $@
#svc/bin/openvpn: $(openvpn)
# (cd $(openvpn) && $(common_configure5) --disable-plugin-auth-pam --disable-plugin-down-root)
# make -C $(openvpn)
# $(strip) $(openvpn)/src/openvpn/openvpn -o $@
svc/bin/powertop: $(powertop)
(cd $(powertop) && $(common_configure5) NCURSES_CFLAGS=" " LIBNL_CFLAGS=" " LIBNL_LIBS="-lnl -lnl-genl" ac_cv_func_malloc_0_nonnull=yes ac_cv_func_realloc_0_nonnull=yes)
make -C $(powertop)
$(strip) $(powertop)/src/powertop -o $@
svc/bin/lftp: $(lftp)
(cd $(lftp) && LIBS=-lz $(common_configure5) ac_cv_func_fallocate=no --without-zlib zlib_cv_libz=yes zlib_cv_zlib_h=yes ac_cv_header_zlib_h=yes ac_cv_lib_z_inflateEnd=yes)
make -C $(lftp)
$(strip) $(lftp)/src/lftp -o $@
svc/bin/sftp-server: $(openssh)
(cd $(openssh) && $(common_configure5))
make -C $(openssh) sftp-server
$(strip) $(openssh)/sftp-server -o svc/bin/sftp-server
FORCE: