-
Notifications
You must be signed in to change notification settings - Fork 0
/
create.sh
412 lines (384 loc) · 11.9 KB
/
create.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
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
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
#!/bin/sh
set -e
set -x
#FETCH NEEDED TOOLS
apt-get install -y gcc-8-aarch64-linux-gnu gcc-8-arm-linux-gnueabihf gawk bison wget patch build-essential u-boot-tools bc vboot-kernel-utils libncurses5-dev g++-arm-linux-gnueabihf flex texinfo unzip help2man libtool-bin python3 git nano kmod pkg-config
#CREATE DIR STRUCTURE
rm -fr /opt/sysroot/*
cp -rv /opt/linux.base/sysroot/* /opt/sysroot
#KERNEL:
cd /opt
git clone git://git.kernel.org/pub/scm/linux/kernel/git/linville/wireless-regdb.git
ln -s /usr/bin/aarch64-linux-gnu-gcc-8 /usr/bin/aarch64-linux-gnu-gcc
export ARCH=arm64
export CROSS_COMPILE=aarch64-linux-gnu-
export WIFIVERSION=
if [ ! -d "/opt/kernel" ]; then
wget -O /opt/kernel.tar.gz https://chromium.googlesource.com/chromiumos/third_party/kernel/+archive/86596f58eadf.tar.gz
mkdir /opt/kernel
tar xfv /opt/kernel.tar.gz -C /opt/kernel
fi
cd /opt/kernel
patch -p1 < /opt/linux.base/log2.patch
cat /opt/linux.base/config.chromeos /opt/linux.base/config.chromeos.extra > .config
cp include/linux/compiler-gcc5.h include/linux/compiler-gcc8.h
cp /opt/wireless-regdb/db.txt /opt/kernel/net/wireless
make oldconfig
make prepare
make CFLAGS="-O2 -s" -j$(nproc) Image
make CFLAGS="-O2 -s" -j$(nproc) modules
make dtbs
make CFLAGS="-O2 -s" -j$(nproc)
make INSTALL_MOD_PATH="/opt/sysroot" modules_install
make INSTALL_DTBS_PATH="/opt/sysroot/boot/dtbs" dtbs_install
rm -f /opt/sysroot/lib/modules/*/{source,build}
cp /opt/linux.base/kernel.its .
mkimage -D "-I dts -O dtb -p 2048" -f kernel.its vmlinux.uimg
dd if=/dev/zero of=bootloader.bin bs=512 count=1
#echo "console=tty1 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd quiet loglevel=0" > cmdline
echo "console=tty1 init=/sbin/init root=PARTUUID=%U/PARTNROFF=1 rootwait rw noinitrd" > cmdline
vbutil_kernel --pack vmlinux.kpart --version 1 --vmlinuz vmlinux.uimg --arch aarch64 --keyblock /opt/linux.base/kernel.keyblock --signprivate /opt/linux.base/kernel_data_key.vbprivk --config cmdline --bootloader bootloader.bin
cp vmlinux.kpart /opt/sysroot/boot/
depmod -b /opt/sysroot -F System.map "3.18.0-19095-g86596f58eadf"
make mrproper
make ARCH=arm headers_check
make ARCH=arm INSTALL_HDR_PATH="/opt/sysroot/usr" headers_install
find /opt/sysroot/usr/include \( -name .install -o -name ..install.cmd \) -delete
#BUSYBOX:
export ARCH=arm
export CROSS_COMPILE=arm-linux-gnueabihf-
cd /opt
wget https://busybox.net/downloads/busybox-1.30.1.tar.bz2
tar xfv busybox-1.30.1.tar.bz2
cd busybox-1.30.1
cp /opt/linux.base/config.busybox .config
make CFLAGS="-O2 -s" -j$(nproc)
make install
#GLIBC
cd /opt
wget https://ftp.gnu.org/gnu/glibc/glibc-2.29.tar.xz
tar xfv glibc-2.29.tar.xz
cd glibc-2.29
mkdir build
cd build
#FIND OUT WHY IT STILL BUILDS STATIC LIBS!!!
../configure \
CFLAGS="-O2 -s" \
--host=arm-linux-gnueabihf \
--prefix= \
--includedir=/usr/include \
--libexecdir=/usr/libexec \
--datarootdir=/tmp \
--localstatedir=/tmp \
--with-__thread \
--with-tls \
--with-fp \
--with-headers=/opt/sysroot/usr/include \
--without-cvs \
--without-gd \
--enable-kernel=3.18.0 \
--enable-stack-protector=strong \
--enable-shared \
--enable-add-ons=no \
--enable-obsolete-rpc \
--disable-profile \
--disable-debug \
--disable-sanity-checks \
--disable-static \
--disable-werror
make -j$(nproc)
make install DESTDIR=/opt/sysroot
rm -rf /opt/sysroot/tmp/*
#BINUTILS
cd /opt
wget https://ftp.yzu.edu.tw/gnu/binutils/binutils-2.32.tar.xz
tar xfv binutils-2.32.tar.xz
cd binutils-2.32
./configure \
CFLAGS="-O2 -s" \
--host=arm-linux-gnueabihf \
--prefix=/opt/sysroot/usr \
--with-sysroot=/ \
--with-float=hard \
--datarootdir=/tmp \
--disable-werror \
--disable-multilib \
--disable-sim \
--disable-gdb \
--disable-nls \
--disable-static \
--enable-ld=default \
--enable-gold=yes \
--enable-threads \
--enable-plugins
make tooldir=/opt/sysroot/usr -j$(nproc)
make tooldir=/opt/sysroot/usr install
#GCC
cd /opt
wget http://ftp.tsukuba.wide.ad.jp/software/gcc/releases/gcc-8.3.0/gcc-8.3.0.tar.xz
tar xfv gcc-8.3.0.tar.xz
cd gcc-8.3.0
./contrib/download_prerequisites
mkdir build
cd build
../configure \
CFLAGS="-O2 -s" \
--host=arm-linux-gnueabihf \
--target=arm-linux-gnueabihf \
--prefix=/opt/sysroot/usr \
--with-sysroot=/ \
--with-float=hard \
--datarootdir=/tmp \
--enable-threads=posix \
--enable-languages=c,c++ \
--enable-__cxa_atexit \
--disable-libmudflap \
--disable-libssp \
--disable-libgomp \
--disable-libstdcxx-pch \
--disable-nls \
--disable-multilib \
--disable-libquadmath \
--disable-libquadmath-support \
--disable-libsanitizer \
--disable-libmpx \
--disable-gold \
--enable-long-long \
--disable-static
make -j$(nproc)
make install
ln -s arm-linux-gnueabihf-gcc /opt/sysroot/usr/bin/cc
#bison
cd /opt
wget http://ftp.twaren.net/Unix/GNU/gnu/bison/bison-3.4.1.tar.xz
tar xfv bison-3.4.1.tar.xz
cd bison-3.4.1
./configure \
CFLAGS="-O2 -s --sysroot=/opt/sysroot" \
--host=arm-linux-gnueabihf \
--prefix=/usr \
--disable-yacc \
--disable-nls \
--infodir=/tmp \
--localedir=/tmp \
--mandir=/tmp \
--docdir=/tmp
make -j1
make DESTDIR=/opt/sysroot install
rm -fr /opt/sysroot/tmp/*
#flex
cd /opt
wget https://github.com/westes/flex/files/981163/flex-2.6.4.tar.gz
tar xfv flex-2.6.4.tar.gz
cd flex-2.6.4
sed -i "/math.h/a #include <malloc.h>" src/flexdef.h
./configure \
CFLAGS="-O2 -s --sysroot=/opt/sysroot" \
--host=arm-linux-gnueabihf \
--prefix=/usr \
--datarootdir=/tmp \
--disable-static
make -j$(nproc)
make DESTDIR=/opt/sysroot install
rm -fr /opt/sysroot/tmp/*
#make
cd /opt
wget http://ftp.twaren.net/Unix/GNU/gnu/make/make-4.2.1.tar.gz
tar xfv make-4.2.1.tar.gz
cd make-4.2.1
sed -i '211,217 d; 219,229 d; 232 d' glob/glob.c
./configure \
CFLAGS="-O2 -s --sysroot=/opt/sysroot" \
--host=arm-linux-gnueabihf \
--prefix=/usr \
--datarootdir=/tmp
make -j$(nproc)
make DESTDIR=/opt/sysroot install
rm -fr /opt/sysroot/tmp/*
#m4
cd /opt
wget https://ftp.gnu.org/gnu/m4/m4-1.4.18.tar.xz
tar xfv m4-1.4.18.tar.xz
cd m4-1.4.18
sed -i 's/IO_ftrylockfile/IO_EOF_SEEN/' lib/*.c
echo "#define _IO_IN_BACKUP 0x100" >> lib/stdio-impl.h
./configure \
CFLAGS="-O2 -s --sysroot=/opt/sysroot" \
--host=arm-linux-gnueabihf \
--prefix=/usr \
--datarootdir=/tmp
make -j$(nproc)
make DESTDIR=/opt/sysroot install
rm -fr /opt/sysroot/tmp/*
#pkg-config
cd /opt
wget https://pkgconfig.freedesktop.org/releases/pkg-config-0.29.2.tar.gz
tar xfv pkg-config-0.29.2.tar.gz
cd pkg-config-0.29.2
./configure \
CFLAGS="-O2 -s --sysroot=/opt/sysroot" \
--host=arm-linux-gnueabihf \
--prefix=/usr \
--with-internal-glib \
--disable-host-tool \
--mandir=/tmp \
--docdir=/tmp \
glib_cv_stack_grows=yes \
glib_cv_uscore=no \
ac_cv_func_posix_getpwuid_r=yes \
ac_cv_func_posix_getgrgid_r=yes
make -j$(nproc)
make DESTDIR=/opt/sysroot install
rm -fr /opt/sysroot/tmp/*
#libnl (netlink)
cd /opt
wget https://github.com/thom311/libnl/releases/download/libnl3_4_0/libnl-3.4.0.tar.gz
tar xfv libnl-3.4.0.tar.gz
cd libnl-3.4.0
./configure \
CFLAGS="-O2 -s --sysroot=/opt/sysroot" \
--host=arm-linux-gnueabihf \
--prefix=/usr \
--sysconfdir=/etc \
--disable-cli \
--datarootdir=/tmp \
--disable-static
make -j$(nproc)
make DESTDIR=/opt/sysroot install
rm -fr /opt/sysroot/tmp/*
#iw (tools for wifi)
cd /opt
wget https://www.kernel.org/pub/software/network/iw/iw-5.0.1.tar.xz
tar xfv iw-5.0.1.tar.xz
cd iw-5.0.1
CC="arm-linux-gnueabihf-gcc --sysroot=/opt/sysroot" \
PKG_CONFIG_PATH=/opt/sysroot/lib/pkgconfig \
CFLAGS="--sysroot=/opt/sysroot -O2 -s -I/opt/sysroot/usr/include/libnl3" \
LDFLAGS="-L/opt/sysroot/usr/lib -lnl-3" \
make
PKG_CONFIG_PATH=/opt/sysroot/lib/pkgconfig make DESTDIR=/tmp/iw install
cp -rv /tmp/iw/usr/sbin /opt/sysroot/usr
rm -fr /tmp/iw
#zlib
cd /opt
wget https://zlib.net/zlib-1.2.11.tar.gz
tar xfv zlib-1.2.11.tar.gz
cd zlib-1.2.11
./configure \
--prefix=/usr \
--shared
make CC="arm-linux-gnueabihf-gcc --sysroot=/opt/sysroot" CFLAGS="-O2 -s" LDSHARED="arm-linux-gnueabihf-gcc -shared -Wl,-soname,libz.so.1,--version-script,zlib.map"
make prefix=/usr DESTDIR=/tmp/zlib install
cp -rv /tmp/zlib/usr/include /opt/sysroot/usr
cp -rv /tmp/zlib/usr/lib /opt/sysroot/usr
rm /opt/sysroot/usr/lib/libz.a
rm -fr /tmp/libz
#openssl
cd /opt
wget https://www.openssl.org/source/openssl-1.1.1c.tar.gz
tar xfv openssl-1.1.1c.tar.gz
cd openssl-1.1.1c
./Configure \
-DL_ENDIAN \
shared \
zlib-dynamic \
--prefix=/usr \
--openssldir=/etc/ssl \
--libdir=lib \
linux-armv4
make \
CC="arm-linux-gnueabihf-gcc --sysroot=/opt/sysroot" \
PROCESSOR=ARM
make DESTDIR=/tmp/openssl install
cp -rv /tmp/openssl/etc /opt/sysroot
rm -rf /tmp/openssl/usr/share
rm /tmp/openssl/usr/lib/libcrypto.a /tmp/openssl/usr/lib/libssl.a
cp -rv /tmp/openssl/usr /opt/sysroot
rm -fr /tmp/openssl
#readline
#cd /opt
#wget https://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz
#tar xfv readline-6.3.tar.gz
#cd readline-6.3
#wget https://ftp.gnu.org/gnu/readline/readline-6.3-patches/readline63-001
#wget https://ftp.gnu.org/gnu/readline/readline-6.3-patches/readline63-002
#wget https://ftp.gnu.org/gnu/readline/readline-6.3-patches/readline63-003
#wget https://ftp.gnu.org/gnu/readline/readline-6.3-patches/readline63-004
#wget https://ftp.gnu.org/gnu/readline/readline-6.3-patches/readline63-005
#wget https://ftp.gnu.org/gnu/readline/readline-6.3-patches/readline63-006
#wget https://ftp.gnu.org/gnu/readline/readline-6.3-patches/readline63-007
#wget https://ftp.gnu.org/gnu/readline/readline-6.3-patches/readline63-008
#patch -p0 < readline63-001
#patch -p0 < readline63-002
#patch -p0 < readline63-003
#patch -p0 < readline63-004
#patch -p0 < readline63-005
#patch -p0 < readline63-006
#patch -p0 < readline63-007
#patch -p0 < readline63-008
#./configure \
# CFLAGS="-O2 -s --sysroot=/opt/sysroot" \
# --host=arm-linux-gnueabihf \
# --prefix=/usr \
# --datarootdir=/tmp \
# --enable-static=no \
# bash_cv_wcwidth_broken=yes
#make -j$(nproc)
#make DESTDIR=/opt/sysroot install
#rm -rf /opt/sysroot/tmp/*
#ncurses
cd /opt
wget https://ftp.gnu.org/pub/gnu/ncurses/ncurses-6.1.tar.gz
tar xfv ncurses-6.1.tar.gz
cd ncurses-6.1
./configure \
CFLAGS="-O2 -s --sysroot=/opt/sysroot" \
--host=arm-linux-gnueabihf \
--prefix=/usr \
--with-shared \
--without-debug \
--disable-stripping \
--without-manpages \
--enable-static=no \
--without-ada
make -j$(nproc)
make DESTDIR=/opt/sysroot install
unlink /opt/sysroot/usr/lib/libcurses.a
rm /opt/sysroot/usr/lib/{libform.a,libmenu.a,libncurses.a,libpanel.a,libncurses++.a}
#wpa_supplicant
cd /opt
wget https://w1.fi/releases/wpa_supplicant-2.8.tar.gz
tar xfv wpa_supplicant-2.8.tar.gz
cd wpa_supplicant-2.8/wpa_supplicant
#cp /opt/linux.base/config.wpa_supplicant .config
cp defconfig .config
sed -i '/CONFIG_CTRL_IFACE_DBUS_NEW=y/d' .config
sed -i '/CONFIG_CTRL_IFACE_DBUS_INTRO=y/d' .config
CC="arm-linux-gnueabihf-gcc --sysroot=/opt/sysroot" \
PKG_CONFIG_PATH=/opt/sysroot/lib/pkgconfig \
CFLAGS="--sysroot=/opt/sysroot -O2 -s -I/opt/sysroot/usr/include/libnl3" \
LDFLAGS="-L/opt/sysroot/usr/lib" \
make BINDIR=/sbin LIBDIR=/lib
install -v -m755 wpa_{cli,passphrase,supplicant} /opt/sysroot/usr/sbin/
#dhcpcd
#cd /opt
#wget https://roy.marples.name/downloads/dhcpcd/dhcpcd-7.2.3.tar.xz
#tar xfv dhcpcd-7.2.3.tar.xz
#cd dhcpcd-7.2.3
#./configure \
# CFLAGS="-O2 -s --sysroot=/opt/sysroot" \
# --host=arm-linux-gnueabihf \
# --libexecdir=/usr/libexec/dhcpcd \
# --mandir=/tmp \
# --dbdir=/var/dhcpcd
#make -j$(nproc)
#make DESTDIR=/opt/sysroot install
#rm -fr /opt/sysroot/tmp/*
#FINALIZE
find /opt/sysroot/usr/bin -executable -type f | xargs arm-linux-gnueabihf-strip -s || true
find /opt/sysroot/usr/sbin -executable -type f | xargs arm-linux-gnueabihf-strip -s || true
find /opt/sysroot/usr/libexec -executable -type f | xargs arm-linux-gnueabihf-strip -s || true
#find /opt/sysroot/usr/lib -type f | xargs arm-linux-gnueabihf-strip -s || true
echo -n "Congratulations! If you can read this text, it means that your system is finished. You can safely ignore any errors above."
echo -n
echo "The system is located at /opt/sysroot"