-
Notifications
You must be signed in to change notification settings - Fork 1
/
x64-root-setup.sh
executable file
·1475 lines (1261 loc) · 37.2 KB
/
x64-root-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
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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#sudo apt-get install autoconf libgcrypt-dev xsltproc docbook-utils gtk-doc-tools ncurses-dev bison libglib2.0-dev autogen ctags cscope protobuf-c-compiler
check_success()
{
if [ $? -ne 0 ]
then
echo Failed
exit 1
fi
echo Done
}
isget="$2"
InstallCoreUtils()
{
if [ "$isget" = "get" ]
then
rm -rfv ./coreutils
#git clone git://git.sv.gnu.org/coreutils
wget -c "http://ftp.gnu.org/gnu/coreutils/coreutils-8.24.tar.xz"
tar -Jxf coreutils-8.24.tar.xz
rm coreutils-8.24.tar.xz
fi
cd coreutils-8.24
./configure --prefix=/ --host=$HOST --build=x86_64-linux-gnu
patch ./Makefile < ../dummymake.patch
patch ./man/dummy-man < ../dummyman.patch
sed -i -e 's|#cu_install_program = ${INSTALL}|cu_install_program = ${INSTALL}|g' Makefile
sed -i -e 's|cu_install_program = src/ginstall|#cu_install_program = src/ginstall|g' Makefile
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallBash()
{
if [ "$isget" = "get" ]
then
wget -c "http://ftp.gnu.org/gnu/bash/bash-4.3.30.tar.gz"
tar -xvf bash-4.3.30.tar.gz
rm bash-4.3.30.tar.gz
fi
cd bash-4.3.30
make V=0 clean
./configure --without-bash-malloc --prefix=/ --host=$HOST #--enable-static-link
#patch execute_cmd.c < ../bashjobcontrol.patch
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
cd $SYSROOT
ln -sf ./lib ./lib64
cd -
cd $SYSROOT/bin
ln -sf bash sh
cd -
check_success
cd ..
}
InstallInetUtils()
{
if [ "$isget" = "get" ]
then
wget -c "http://ftp.gnu.org/gnu/inetutils/inetutils-1.9.4.tar.gz"
tar -xvf inetutils-1.9.4.tar.gz
rm inetutils-1.9.4.tar.gz
fi
cd inetutils-1.9.4
make V=0 clean
./configure --prefix=/ --host=$HOST CFLAGS="-I$SYSROOT/include/ -O2" \
--disable-rlogind \
--disable-rshd \331
--disable-syslogd \
--disable-talkd \
--disable-telnetd \
--disable-tftpd \
--disable-uucpd \
--disable-ftp \
--disable-dnsdomainname \
--disable-rcp \
--disable-rexec \
--disable-rlogin \
--disable-rsh \
--disable-logger \
--disable-talk \
--disable-telnet \
--disable-tftp \
--disable-ifconfig
patch ./ifconfig/system/linux.c < ../inetutilpathprocspath.patch
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallIproute2()
{
if [ "$isget" = "get" ]
then
rm -rfv ./iprout*
git clone git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git
fi
cd iproute2
make V=0 clean
./configure --prefix=/ --host=$HOST
sed -i '/^TARGETS/s@arpd@@g' misc/Makefile
sed -i -e 's|PREFIX?=/usr|PREFIX=/|g' ./Makefile
make V=0 -j 9
check_success
#make V=0 install DESTDIR=$SYSROOT
make V=0 install DESTDIR="/home/andrew/Desktop/iproute2/"
check_success
cd ..
}
InstallBridge()
{
if [ "$isget" = "get" ]
then
rm -rfv ./bridge-utils*
git clone git://git.kernel.org/pub/scm/linux/kernel/git/shemminger/bridge-utils.git
fi
cd bridge-utils
autoconf
./configure --prefix=/ --host=$HOST
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallZlib()
{
if [ "$isget" = "get" ]
then
wget -c "http://zlib.net/zlib-1.2.8.tar.gz"
tar -xf zlib-1.2.8.tar.gz
rm zlib-1.2.8.tar.gz
fi
cd zlib-1.2.8
make V=0 clean
./configure --prefix=/
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallOpenSSl()
{
if [ "$isget" = "get" ]
then
wget -c "http://www.openssl.org/source/openssl-1.0.2d.tar.gz"
tar -xf openssl-1.0.2d.tar.gz
rm openssl-1.0.2d.tar.gz
fi
#cp 1.0.1g-docfixes-diff.patch ./openssl-1.0.1g
cd openssl-1.0.2d
#patch -p1 <1.0.1g-docfixes-diff.patch
make V=0 clean
./Configure linux-elf --prefix=/ no-asm -fPIC --openssldir=/etc/ssl
make -j 9
check_success
make install INSTALL_PREFIX=$SYSROOT
check_success
cd ..
}
InstallOpenSSH()
{
if [ "$isget" = "get" ]
then
wget -c "http://mirror.yandex.ru/pub/OpenBSD/OpenSSH/portable/openssh-7.1p1.tar.gz"
tar -xf openssh-7.1p1.tar.gz
rm openssh-7.1p1.tar.gz
fi
cd openssh-7.1p1
make V=0 clean
./configure --prefix=/ --host=$HOST --sysconfdir=/etc/ssh --with-pam
#
make V=0 LDFLAGS="-dynamic-linker /lib64/ld-linux-x86-64.so.2 $SYSROOT/lib/crt1.o $SYSROOT/lib/crti.o $SYSROOT/lib/crtn.o -L. -Lopenbsd-compat/ -L$SYSROOT/lib -lc -lgcc_s" CFLAGS="-DHAVE_SETLOGIN -UHAVE_PROC_PID -fPIC -g -O2 -Wall -Wpointer-arith -Wuninitialized -Wsign-compare -Wformat-security -Wsizeof-pointer-memaccess -Wno-pointer-sign -Wno-unused-result -fno-strict-aliasing -D_FORTIFY_SOURCE=2 -fno-builtin-memset -fstack-protector-all" -j 3
check_success -j 9
make V=0 DESTDIR=$SYSROOT STRIP_OPT="--strip-program=x86_64-media-linux-gnu-strip" install-nokeys
check_success
mkdir -p -v "$SYSROOT/etc/ssh/"
cat > "$SYSROOT/etc/ssh/sshd_config" << "EOF"
AuthorizedKeysFile .ssh/authorized_keys
GatewayPorts yes
PasswordAuthentication yes
PermitRootLogin yes
UsePAM yes
X11Forwarding yes
UsePrivilegeSeparation no # Default for new installations.
Subsystem sftp /libexec/sftp-server
EOF
ssh-keygen -t rsa -q -f "$SYSROOT/etc/ssh/ssh_host_rsa_key"
ssh-keygen -t dsa -q -f "$SYSROOT/etc/ssh/ssh_host_dsa_key"
ssh-keygen -t ecdsa -q -f "$SYSROOT/etc/ssh/ssh_host_ecdsa_key"
cat > "$SYSROOT/lib/systemd/system/ssh.service" << "EOF"
[Unit]
Description=OpenBSD Secure Shell server
After=network.target
[Service]
ExecStartPre=/bin/mkdir -p /var/run/sshd
ExecStart=/sbin/sshd -D
KillMode=process
Restart=always
[Install]
WantedBy=multi-user.target
EOF
ln -s -v "/lib/systemd/system/ssh.service" "$SYSROOT/etc/systemd/system/multi-user.target.wants/ssh.service"
cd ..
}
InstallCurl()
{
if [ "$isget" = "get" ]
then
wget -c "http://curl.haxx.se/download/curl-7.42.0.tar.gz"
tar -xf curl-7.42.0.tar.gz
rm curl-7.42.0.tar.gz
#wget -c "http://ftp.de.debian.org/debian/pool/main/c/curl/curl_7.37.0.orig.tar.gz"
#tar -xf curl_7.37.0.orig.tar.gz
#rm curl_7.37.0.orig.tar.gz
fi
cd curl-7.42.0
make V=0 clean
./configure --prefix=/ --host=$HOST
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallLibEvent()
{
if [ "$isget" = "get" ]
then
wget -c "https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz"
tar -xf libevent-2.0.21-stable.tar.gz
rm libevent-2.0.21-stable.tar.gz
fi
cd libevent-2.0.21-stable
make V=0 clean
./configure --prefix=/ --host=$HOST
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallDhcp()
{
if [ "$isget" = "get" ]
then
rm -rf ./dnsmasq
git clone "git://thekelleys.org.uk/dnsmasq.git"
fi
cd dnsmasq
./configure --prefix=/ --host=$HOST
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallNftables()
{
if [ "$isget" = "get" ]
then
rm -rf ./nftables
git clone "http://git.kernel.org/pub/scm/linux/kernel/git/pablo/nftables.git"
fi
cd nftables
sh autogen.sh
./configure --prefix=/ --host=$HOST
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallTransmission()
{
if [ "$isget" = "get" ]
then
rm -rfv Transmission
svn co svn://svn.transmissionbt.com/Transmission/trunk Transmission
#wget -c "http://download-origin.transmissionbt.com/files/transmission-2.84.tar.xz"
#tar -xf transmission-2.84.tar.xz
fi
cd Transmission
./autogen.sh
make V=0 clean
with_ssl=$SYSROOT CFLAGS="-w -O2" \
LIBEVENT_CFLAGS="-I$SYSROOT/include/curl" LIBEVENT_LIBS="-L$SYSROOT/lib/ -levent" \
LIBCURL_CFLAGS="-I$SYSROOT/include/" LIBCURL_LIBS="-L$SYSROOT/lib/ -lcurl" \
LDFLAGS="-L$SYSROOT/lib/ -lssl -ldl" \
./configure --prefix=/ --host=$HOST --disable-gtk --disable-cli --disable-libnotify --disable-nls --disable-mac --disable-wx --disable-beos
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallNcurses()
{
if [ "$isget" = "get" ]
then
rm -rfv ./ncurses
git clone git://ncurses.scripts.mit.edu/ncurses.git
fi
cd ncurses
make V=0 clean
./configure --prefix=/ --host=$HOST --mandir="/share"
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallNano()
{
if [ "$isget" = "get" ]
then
rm -rfv ./nano*
svn co svn://svn.savannah.gnu.org/nano/trunk/nano
#wget -c "http://www.nano-editor.org/dist/v2.3/nano-2.3.5.tar.gz"
#tar -xf nano-2.3.5.tar.gz
#rm nano-2.3.5.tar.gz
fi
cd nano
./autogen.sh
mkdir buidnano
cd buidnano
rm -rfv ./*
make V=0 clean
../configure --prefix=/ --host=$HOST CFLAGS="-I$SYSROOT/include/ncurses -DENABLE_UTF8 -O2" --datadir="/share/"
make V=0 -j 9
check_success
make install DESTDIR=$SYSROOT
check_success
cd ..
cd ..
}
InstallHtop()
{
if [ "$isget" = "get" ]
then
rm -rfv ./htop
git clone https://github.com/hishamhm/htop
fi
cd htop
aclocal -I m4
autoconf
autoheader
libtoolize --copy --force
automake --add-missing --copy
check_success
./configure --prefix=/ --host=$HOST --disable-unicode CFLAGS="-I$SYSROOT/include/ -O2"
make -j 9
check_success
make install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallReadline()
{
if [ "$isget" = "get" ]
then
wget -c "http://ftp.gnu.org/gnu/readline/readline-6.3.tar.gz"
tar -xf readline-6.3.tar.gz
rm readline-6.3.tar.gz
fi
cd readline-6.3
make V=0 clean
./configure --prefix=/ bash_cv_wcwidth_broken=yes --host=$HOST
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
SoftEtherVpn()
{
if [ "$isget" = "get" ]
then
rm -rfv ./SoftEtherVPN
git clone https://github.com/SoftEtherVPN/SoftEtherVPN.git
fi
cp ./Makefile ./SoftEtherVPN/
cd SoftEtherVPN
make V=0 clean
./configure --prefix=/ --host=$HOST --build=x86_64-linux-gnu
make V=0 CC=gcc \
OPTIONS_COMPILE_RELEASE="-DNDEBUG -DVPN_SPEED -DUNIX -DUNIX_LINUX -DCPU_64 -D_REENTRANT -DREENTRANT -D_THREAD_SAFE -D_THREADSAFE -DTHREAD_SAFE -DTHREADSAFE -D_FILE_OFFSET_BITS=64 -I./src/ -I./src/Cedar/ -I$SYSROOT/include -I$SYSROOT/include -I./src/Mayaqua/ -O2 -fsigned-char -m64" \
OPTIONS_LINK_RELEASE="-O2 -fsigned-char -m64 -lm -ldl -lrt -lpthread -lssl -lcrypto -lreadline -lncurses -lz"
#make V=0 CC=x86_64-media-linux-gnu-gcc \
#OPTIONS_COMPILE_RELEASE="-DNDEBUG -DVPN_SPEED -DUNIX -DUNIX_LINUX -DCPU_64 -D_REENTRANT -DREENTRANT -D_THREAD_SAFE -#D_THREADSAFE -DTHREAD_SAFE -DTHREADSAFE -D_FILE_OFFSET_BITS=64 -I./src/ -I./src/Cedar/ -I$SYSROOT/include -I$SYSROOT/#include -I./src/Mayaqua/ -O2 -fsigned-char -m64" \
#OPTIONS_LINK_RELEASE="-O2 -fsigned-char -m64 -lm -ldl -lrt -lpthread -lssl -lcrypto -lreadline -lncurses -lz"
check_success
make V=0 \
INSTALL_BINDIR=$SYSROOT/bin/ \
INSTALL_VPNSERVER_DIR=$SYSROOT/bin/binvpnserver/ \
INSTALL_VPNBRIDGE_DIR=$SYSROOT/bin/binvpnbridge/ \
INSTALL_VPNCLIENT_DIR=$SYSROOT/bin/binvpnclient/ \
INSTALL_VPNCMD_DIR=$SYSROOT/bin/binvpncmd/ \
install
sed -i -e 's|'$SYSROOT'||g' $SYSROOT/bin/vpnbridge
sed -i -e 's|'$SYSROOT'||g' $SYSROOT/bin/vpnclient
sed -i -e 's|'$SYSROOT'||g' $SYSROOT/bin/vpncmd
sed -i -e 's|'$SYSROOT'||g' $SYSROOT/bin/vpnserver
check_success
#check_success undefined reference to `EVP_MD_size'
cd ..
}
InstallStrongSwan()
{
if [ "$isget" = "get" ]
then
rm -rfv ./strongswan
git clone git://git.strongswan.org/strongswan.git
fi
cd strongswan
./autogen.sh
make V=0 clean
./configure --prefix=/ --host=$HOST --enable-unity --build=x86_64-linux-gnu --enable-openssl --enable-gmp=no --enable-integrity-test --sysconfdir=/etc
check_success
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallNettle()
{
if [ "$isget" = "get" ]
then
rm -rfv ./nettle*
git clone https://git.lysator.liu.se/nettle/nettle.git
#wget -c http://ftp.gnu.org/gnu/nettle/nettle-2.7.1.tar.gz
#//tar -xvf nettle-2.7.1.tar.gz
fi
cd nettle
autoreconf
./configure --prefix=/ --host=$HOST --disable-openssl --enable-mini-gmp
check_success
make V=0 -j 9 LDFLAGS="-ldl"
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallGnutls()
{
if [ "$isget" = "get" ]
then
rm -rfv ./gnutls*
git clone https://gitlab.com/gnutls/gnutls.git
#wget -c ftp://ftp.gnutls.org/gcrypt/gnutls/v3.3/gnutls-3.3.8.tar.xz
#tar -xf gnutls-3.3.8.tar.xz
fi
cd gnutls
make bootstrap
check_success
#sed -i -e 's|"x$crywrap" != "xno"|"x$crywrap" == "xno"|g' ./configure
./configure --prefix=/ --host=$HOST NETTLE_CFLAGS="-I$SYSROOT/include" NETTLE_LIBS="-L$SYSROOT/lib -lnettle" \
HOGWEED_CFLAGS="-I$SYSROOT/include" HOGWEED_LIBS="-L$SYSROOT/lib -lhogweed" --disable-nls \
--with-included-libtasn1 --disable-doc --disable-openssl-compatibility \
--with-default-trust-store-file="/etc/ssl/ca-bundle.crt" --enable-local-libopts=yes --without-p11-kit
check_success
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallOpenConnect()
{
if [ "$isget" = "get" ]
then
rm -rfv ./ocserv*
git clone git://git.infradead.org/ocserv.git
#wget -c ftp://ftp.infradead.org/pub/ocserv/ocserv-0.8.6.tar.xz
#tar -xvf ocserv-0.8.6.tar.xz
fi
cd ocserv
sed -i -e 's|SUBDIRS += src doc tests|SUBDIRS += src tests|g' ./Makefile.am
make autoreconf
chmod +x ./autogen.sh
./autogen.sh
#mkdir ./src/google/protobuf-c/ -pv
#cp -rfv ./src/protobuf/protobuf-c/* ./src/google/protobuf-c/
./configure --prefix=/ --host=$HOST LIBGNUTLS_CFLAGS="-I$SYSROOT/include" LIBGNUTLS_LIBS="-L$SYSROOT/lib -lgnutls" \
LIBREADLINE_CFLAGS="-I$SYSROOT/include/readline" LIBREADLINE_LIBS="-L$SYSROOT/lib -lreadline -lncurses" \
--enable-local-libopts=yes --disable-systemd --without-protobuf
check_success
make AUTOGEN="autogen" -j 9
check_success
sed -i -e 's|/bin/true|autogen|g' ./doc/Makefile
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallGmp()
{
if [ "$isget" = "get" ]
then
rm -rfv ./gmp-6.0.0a
wget -c "https://gmplib.org/download/gmp/gmp-6.0.0a.tar.bz2"
tar -xf ./gmp-6.0.0a.tar.bz2
fi
cd gmp-6.0.0
make V=0 clean
./configure --prefix=/ --host=$HOST
check_success
make V=0 -j 9
check_success
rm -v ./doc/Makefile
touch ./doc/Makefile
make V=0 install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallLinux()
{
if [ "$isget" = "get" ]
then
wget -c "https://www.kernel.org/pub/linux/kernel/v4.x/linux-$LINUX_VERSION.tar.gz"
tar -xf linux-$LINUX_VERSION.tar.gz
rm linux-$LINUX_VERSION.tar.gz
fi
cp ./.config ./linux-$LINUX_VERSION
cd linux-$LINUX_VERSION
make V=0 clean
export CXX="g++"
export LD="ld"
export CC="gcc"
export AR="ar"
export RANLIB="ranlib"
export STRIP="strip"
make V=0 ARCH=x86 CROSS_COMPILE="$CLFS/bin/x86_64-media-linux-gnu-" menuconfig -j 9
make V=0 ARCH=x86 CROSS_COMPILE="$CLFS/bin/x86_64-media-linux-gnu-" bzImage -j 3
check_success
export CXX="x86_64-media-linux-gnu-g++"
export LD="x86_64-media-linux-gnu-ld"
export CC="x86_64-media-linux-gnu-gcc"
export AR="x86_64-media-linux-gnu-ar"
export RANLIB="x86_64-media-linux-gnu-ranlib"
export STRIP="x86_64-media-linux-gnu-strip"
mkdir -pv $SYSROOT/boot/
cp ./arch/x86_64/boot/bzImage $SYSROOT/boot
cd ..
}
InstallInitram()
{
cd linux-$LINUX_VERSION
mkdir -p ./initramfs
cd ./initramfs
wget -c "http://www.busybox.net/downloads/binaries/latest/busybox-x86_64" && mv busybox-x86_64 busybox
cp -v busybox $SYSROOT/bin
chmod +x busybox
touch init.conf
cat > init.conf << "EOF"
dir /dev 0755 0 0
dir /root 0700 0 0
dir /bin 0755 0 0
dir /sbin 0755 0 0
dir /sys 0755 0 0
dir /proc 0755 0 0
dir /tmp 0700 0 0
dir /var 0700 0 0
dir /run 0700 0 0
dir /usr/bin 0755 0 0
dir /usr/sbin 0755 0 0
file /bin/busybox ./busybox 0755 0 0
slink /bin/sh /bin/busybox 0755 0 0
file /init ./init 0755 0 0
EOF
touch init
cat > init << "EOF"
#!/bin/sh
export PATH=/bin:/sbin:
export LD_LIBRARY_PATH=/lib:
/bin/busybox mount -n -t devtmpfs devtmpfs /dev
/bin/busybox mount -n -t proc proc /proc
/bin/busybox mount -n -t sysfs sysfs /sys
/bin/busybox mount -t tmpfs -o size=128m tmpfs /tmp
/bin/busybox mkdir /newroot
init="/lib/systemd/systemd"
newroot="/dev/sda1"
/bin/busybox mount "${newroot}" /newroot
exec /bin/busybox switch_root /newroot "${init}"
EOF
cd ../usr/
gcc gen_init_cpio.c -o gen_init_cpio
cd -
../usr/gen_init_cpio ./init.conf > initramfs
#cd $SYSROOT/..
#mv -v ./root ./realroot
#find ./ -depth -print | cpio -o --append -H newc -F initramfs
#mv -v ./realroot ./root
#cd -
cp -v initramfs $SYSROOT/boot/
cd ..
cd ..
}
InstallLibAttr()
{
if [ "$isget" = "get" ]
then
wget -c "http://ftp.mirrorservice.org/sites/download.savannah.gnu.org/releases/attr/attr-2.4.47.src.tar.gz"
tar -xf attr-2.4.47.src.tar.gz
rm attr-2.4.47.src.tar.gz
fi
cd attr-2.4.47
make V=0 clean
./configure --prefix=/ --host=$HOST
make V=0 -j 9
check_success
make install-dev DESTDIR=$SYSROOT
check_success
cd ..
}
InstallLibCap()
{
if [ "$isget" = "get" ]
then
wget -c "https://www.kernel.org/pub/linux/libs/security/linux-privs/libcap2/libcap-2.24.tar.gz"
tar -xf libcap-2.24.tar.gz
rm libcap-2.24.tar.gz
fi
cd libcap-2.24
gcc ./libcap/_makenames.c -o ./libcap/_makenames -I./libcap/include/ -v
make V=0 CC="x86_64-media-linux-gnu-gcc"
check_success
make V=0 install DESTDIR=$SYSROOT RAISE_SETFCAP=no LIBDIR="$SYSROOT/lib" INCDIR="$SYSROOT/include" PKGCONFIGDIR="$SYSROOT/lib"
check_success
cp -rfv $SYSROOT/usr/share/* $SYSROOT/share/*
rm -rfv $SYSROOT/usr
cd ..
}
InstallUtillinux()
{
if [ "$isget" = "get" ]
then
wget -c "https://www.kernel.org/pub/linux/utils/util-linux/v2.27/util-linux-2.27.tar.gz"
tar -xf util-linux-2.27.tar.gz
rm util-linux-2.27.tar.gz
fi
cd util-linux-2.27
make V=0 clean
./configure --prefix=/ --host=$HOST CFLAGS="-I$SYSROOT/include/ -I$SYSROOT/include/ncurses/ -O2" --with-ncurses --disable-makeinstall-chown --without-python
sed -i -e 's|-ltinfo|-lncurses|g' Makefile
make V=0 -j 9
check_success
make V=0 install DESTDIR=$SYSROOT bashcompletiondir="/share/utilbashcomp"
check_success
cd ..
}
AddScratch()
{
mkdir -pv "$SYSROOT/root/"
cat > "$SYSROOT/etc/systemd/network/network" << "EOF"
[Match]
Name=*
[Network]
DHCP=yes
EOF
mv "$SYSROOT/etc/systemd/network/network" "$SYSROOT/etc/systemd/network/20-dhcp.network"
cat > "$SYSROOT/etc/passwd" << "EOF"
root:0BX.JrA2D99/6:0:0:root:/root:/bin/bash
systemd-network:!:1000:1000::/home/systemd-network:/bin/bash
EOF
cat > "$SYSROOT/etc/group" << "EOF"
root:x:0:
systemd-network:!:1000:
tty:x:1001:
dialout:x:1002:
kmem:x:1003:
input:x:1004:
video:x:1005:
audio:x:1006:
lp:x:1007:
disk:x:1008:
cdrom:x:1009:
tape:x:1010:
EOF
cat > "$SYSROOT/etc/protocols" << "EOF"
# Internet (IP) protocols
#
# Updated from http://www.iana.org/assignments/protocol-numbers and other
# sources.
# New protocols will be added on request if they have been officially
# assigned by IANA and are not historical.--without-libdl-prefix
# If you need a huge list of used numbers please install the nmap package.
ip 0 IP # internet protocol, pseudo protocol number
#hopopt 0 HOPOPT # IPv6 Hop-by-Hop Option [RFC1883]
icmp 1 ICMP # internet control message protocol
igmp 2 IGMP # Internet Group Management
ggp 3 GGP # gateway-gateway protocol
ipencap 4 IP-ENCAP # IP encapsulated in IP (officially ``IP'')
st 5 ST # ST datagram mode
tcp 6 TCP # transmission control protocol
egp 8 EGP # exterior gateway protocol
igp 9 IGP # any private interior gateway (Cisco)
pup 12 PUP # PARC universal packet protocol
udp 17 UDP # user datagram protocol
hmp 20 HMP # host monitoring protocol
xns-idp 22 XNS-IDP # Xerox NS IDP
rdp 27 RDP # "reliable datagram" protocol
iso-tp4 29 ISO-TP4 # ISO Transport Protocol class 4 [RFC905]
dccp 33 DCCP # Datagram Congestion Control Prot. [RFC4340]
xtp 36 XTP # Xpress Transfer Protocol
ddp 37 DDP # Datagram Delivery Protocol
idpr-cmtp 38 IDPR-CMTP # IDPR Control Message Transport
ipv6 41 IPv6 # Internet Protocol, version 6
ipv6-route 43 IPv6-Route # Routing Header for IPv6
ipv6-frag 44 IPv6-Frag # Fragment Header for IPv6
idrp 45 IDRP # Inter-Domain Routing Protocol
rsvp 46 RSVP # Reservation Protocol
gre 47 GRE # General Routing Encapsulation
esp 50 IPSEC-ESP # Encap Security Payload [RFC2406]
ah 51 IPSEC-AH # Authentication Header [RFC2402]
skip 57 SKIP # SKIP
ipv6-icmp 58 IPv6-ICMP # ICMP for IPv6
ipv6-nonxt 59 IPv6-NoNxt # No Next Header for IPv6
ipv6-opts 60 IPv6-Opts # Destination Options for IPv6
rspf 73 RSPF CPHB # Radio Shortest Path First (officially CPHB)
vmtp 81 VMTP # Versatile Message Transport
eigrp 88 EIGRP # Enhanced Interior Routing Protocol (Cisco)
ospf 89 OSPFIGP # Open Shortest Path First IGP
ospf 89 OSPFIGP # Open Shortest Path First IGP
ax.25 93 AX.25 # AX.25 frames
ipip 94 IPIP # IP-within-IP Encapsulation Protocol
etherip 97 ETHERIP # Ethernet-within-IP Encapsulation [RFC3378]
encap 98 ENCAP # Yet Another IP encapsulation [RFC1241]
# 99 # any private encryption scheme
pim 103 PIM # Protocol Independent Multicast
ipcomp 108 IPCOMP # IP Payload Compression Protocol
vrrp 112 VRRP # Virtual Router Redundancy Protocol [RFC5798]
l2tp 115 L2TP # Layer Two Tunneling Protocol [RFC2661]
isis 124 ISIS # IS-IS over IPv4
sctp 132 SCTP # Stream Control Transmission Protocol
fc 133 FC # Fibre Channel
mobility-header 135 Mobility-Header # Mobility Support for IPv6 [RFC3775]
udplite 136 UDPLite # UDP-Lite [RFC3828]
mpls-in-ip 137 MPLS-in-IP # MPLS-in-IP [RFC4023]
manet 138 # MANET Protocols [RFC5498]
hip 139 HIP # Host Identity Protocol
shim6 140 Shim6 # Shim6 Protocol [RFC5533]
wesp 141 WESP # Wrapped Encapsulating Security Payload
rohc 142 ROHC # Robust Header Compression
EOF
cat > "$SYSROOT/etc/resolv.conf" << "EOF"
nameserver 8.8.8.8
EOF
#mkdir -p "$SYSROOT/etc/systemd/system/[email protected]"
#cat > "$SYSROOT/etc/systemd/system/[email protected]/autologin.conf" << "EOF"
#[Service]
#ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux
#EOF
cat > "$SYSROOT/root/.bash_profile" << "EOF"
export LD_LIBRARY_PATH=/lib
export PATH=/sbin:/bin:/libexec
#exec /bin/bash
#if [ -z "$DISPLAY" ] && [ $(tty) == /dev/tty1 ]; then
# exec /opt/startx.sh
#fi
EOF
cat > "$SYSROOT/root/fixall.sh" << "EOF"
#!/bin/bash
export LD_LIBRARY_PATH=/lib:
rm -rfv /lib/systemd/system/systemd-update-done.service
rm -rfv /lib/udev/rules.d/60-persistent-storage.rules
rm -rfv /lib/systemd/system/systemd-sysctl.service
rm -rfv /lib/systemd/system/sysinit.target.wants/systemd-update-done.service
rm -rfv /lib/systemd/system/sysinit.target.wants/systemd-sysctl.service
EOF
chmod +x $SYSROOT/root/fixall.sh
}
InstallXz()
{
#GTK-Doc-tools need install coreutils newest
#sudo apt-get install libgcrypt-dev xsltproc docbook-utils gtk-doc-tools
if [ "$isget" = "get" ]
then
rm -rf ./xz
git clone http://git.tukaani.org/xz.git
fi
cd xz
./autogen.sh
make V=0 clean
./configure --prefix=/ --host=$HOST
make V=0 -j 9
check_success
make install DESTDIR=$SYSROOT
check_success
cd ..
}
InstallSystemD()
{
#GTK-Doc-tools need install coreutils newest
#sudo apt-get install libgcrypt-dev xsltproc docbook-utils gtk-doc-tools
if [ "$isget" = "get" ]
then
rm -rf ./systemd
git clone "git://anongit.freedesktop.org/systemd/systemd"
fi
cd systemd
./autogen.sh
make V=0 clean
#patch ./configure < ../kmodsystemd.patch
./configure --prefix=/ --exec-prefix=/ --host="$HOST" \
--disable-gtk-doc --disable-seccomp --disable-selinux --disable-xattr \
--disable-apparmor --disable-xz --disable-zlib --disable-pam --without-python \
--disable-acl --disable-smack --disable-gcrypt --disable-audit --disable-gudev \
--disable-elfutils --disable-libcryptsetup --disable-qrencode \
--disable-microhttpd --disable-gnutls --disable-libcurl \
--disable-libidn --disable-quotacheck --disable-vconsole \
--disable-logind --disable-machined --disable-importd \
--disable-hostnamed --disable-timedated --disable-localed \
--disable-polkit --disable-resolved --disable-efi \
--disable-manpages --disable-hibernate --disable-tests --disable-nls \
--disable-python-devel --disable-utmp --disable-xkbcommon \
--disable-ima --disable-blkid --disable-binfmt --disable-tmpfiles \
--disable-sysusers --disable-firstboot --disable-randomseed \
--disable-backlight --disable-rfkill --disable-timesyncd \
--disable-coredump --disable-myhostname --disable-ldconfig \
-disable-dbus \
--disable-utmp \
--disable-kmod \
--disable-xkbcommon \
--disable-blkid \
--disable-seccomp \
--disable-ima \
--disable-selinux \
--disable-apparmor \
--disable-xz \
--disable-zlib \
--enable-bzip2 \
--disable-pam \
--disable-acl \
--disable-smack \
--disable-gcrypt \
--disable-audit \
--disable-elfutils \
--disable-libcryptsetup \
--disable-qrencode \
--disable-microhttpd \
--disable-gnutls \
--disable-libcurl \
--disable-libidn \
--disable-libiptc \