-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·738 lines (635 loc) · 18.2 KB
/
configure
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
#!/bin/bash
env_clean(){
for i in DIR MAJOR MINOR OS RELEASE FIRST_DIGIT SECOND_DIGIT EXTRA_DIGIT CONCURRENCY_LEVEL FFDECSA_EXTRA FFFAIL CX23885 VERSION CONFIG
do
if ! [ -z ${i+x} ]; then
unset $i
fi
done
}
die(){
echo -en "
\E[1;33;44m$1, aborting...\E[0m
"
env_clean
exit 1
}
die_unknown(){
echo -en "
\E[1;33;44mUnknown option \"$1\".
run ./configure --help for valid options\E[0m
"
env_clean
exit 1
}
_patch(){
if ! [ "$?" -eq 0 ]; then
echo "
Could not apply the patch.
Aborting...
"
env_clean
exit 1
fi
}
confirmno(){
# call with a prompt string or use a default
read -r -p "${1:-Are you sure? [y/N]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
*)
false
;;
esac
}
confirmyes(){
# call with a prompt string or use a default
read -r -p "${1:-Continue? [Y/n]} " response
case $response in
[yY][eE][sS]|[yY])
true
;;
[nN][oO]|[nN])
false
;;
*)
true
;;
esac
}
show_help(){
echo " Usage: ./configure --opt1=<opt> --opt2=<opt>"
echo " "
echo " Options: [default], if any, in brackets after option."
echo " "
echo " --help Print this message"
echo " "
echo " --vanilla=<bool> Specify a the vanilla kernel version you"
echo " want to compile. Like --vanilla=4.1.8"
echo " This disables the --stock= flag."
echo " "
echo " --headers=<opt> [yes] no: do not install kernel headers package(s)."
echo " "
echo " --adapters=<opt> [16] Set max number of adapters that are allowed,"
echo " twice the number of your physical adapters is needed."
echo " "
echo " --update=<opt> [yes] no: don't auto-update or clean this repo."
echo " "
echo " "
echo " --debug=<opt> [no] yes: pause to review (almost) each and every step."
echo " "
echo " --firmware=<opt> [yes] no: don't install the included firmware files."
echo " "
echo " --clean=<opt> [no] yes: just clean and update the repo and exit."
echo " "
echo " --user=<opt> [tycho] state your username."
echo " "
echo " --big=<opt> [no] do localmodconfig, yes=compile a full blown kernel."
echo " "
echo " --saa=<opt> [yes] no=build without saa716x driver."
echo " "
exit 0
}
stock_opt="yes"
vanilla_opt=""
headers_opt="yes"
adapters_opt="16"
update_opt="yes"
debug_opt="no"
firmware_opt="yes"
clean_opt="no"
user_opt="tycho"
next_opt="no"
big_opt="no"
saa_opt="yes"
for opt do
optval="${opt#*=}"
case "$opt" in
--help) show_help
;;
--vanilla=*) stock_opt="no"; vanilla_opt="$optval"
;;
--headers=*) headers_opt="$optval"
;;
--adapters=*) adapters_opt="$optval"
;;
--update=*) update_opt="$optval"
;;
--debug=*) debug_opt="$optval"
;;
--firmware=*) firmware_opt="$optval"
;;
--clean=*) clean_opt="$optval"
;;
--user=*) user_opt="$optval"
;;
--big=*) big_opt="$optval"
;;
--saa*) saa_opt="$optval"
;;
*)
die_unknown $opt
;;
esac
done
DIR=`pwd`
# Check git status
if [ "x$update_opt" = "xyes" ]; then
rm -rf linux* > /dev/null 2>&1
rm -rf media* > /dev/null 2>&1
rm -rf descrambler > /dev/null 2>&1
git clean -xfd > /dev/null
git reset --hard HEAD > /dev/null
git remote update > /dev/null 2>&1
if ! [ "$?" -eq 0 ]; then
echo -en "
\E[1;33;44m
###################################
Error(s) encountered while updating
the status from remote git repo.
Aborting...
####################################
\E[0m
"
env_clean
exit 1
fi
LOCAL=$(git rev-parse @{0})
REMOTE=$(git rev-parse @{u})
BASE=$(git merge-base @{0} @{u})
if [ $LOCAL = $REMOTE ]; then
GITSTATUS="0" # "Up-to-date"
elif [ $LOCAL = $BASE ]; then
GITSTATUS="1" # "Need to pull"
elif [ $REMOTE = $BASE ]; then
GITSTATUS="2" # "Need to push"
else
GITSTATUS="3" # "Diverged"
fi
if [ "$GITSTATUS" -eq "0" ]; then
echo "
Your local clone is clean and up-to-date
"
if [ "x$debug_opt" = "xno" ]; then
sleep 3
else
confirmyes
if ! [ "$?" -eq 0 ]; then
env_clean
exit 0
fi
fi
elif [ "$GITSTATUS" -eq "1" ]; then
echo "
Going to sync your local clone with updated remote repo.
"
sleep 3
git pull > /dev/null
if ! [ "$?" -eq 0 ]; then
echo -en "
\E[1;33;44m
###################################
Error(s) encountered while syncing
local with remote git repo
Aborting...
####################################
\E[0m
"
env_clean
exit 1
else
echo -en "
############################################################
Synced with remote repo successfully! Please rerun
./configure to complete installation of saa716x drivers.
Arrow up and enter will get you there.
############################################################
"
env_clean
exit 0
fi
elif [ "$GITSTATUS" -eq 2 -o "$GITSTATUS" -eq 3 ]; then
echo -en "
\E[1;33;44m
######################################
Your local clone cannot be synced with
remote repo. Please get a fresh clone.
Aborting...
######################################
\E[0m
"
env_clean
exit 1
fi
fi
if [ "x$clean_opt" = "xyes" ]; then
exit 0
fi
# Make sure that we are running as root
if ! echo "$(whoami)" | grep "root" > /dev/null 2>&1; then
echo -en "
\E[1;33;44m
You should run as root.
Aborting...
\E[0m
"
env_clean
exit 0
fi
# Get info on what distro we are running
apt-get install lsb-release -y > /dev/null 2>&1
if [ -f /usr/bin/lsb_release ]; then
OS=$( lsb_release -si )
RELEASE=$( lsb_release -sc )
fi
# Check for a supported kernelversion
if ! [ "x$vanilla_opt" = "x" ]; then
FIRST_DIGIT=$(echo "$vanilla_opt" | awk -F/ '{print $NF}' | grep -o '[[:digit:]]\+' | head -n1 | awk 'NR==1')
SECOND_DIGIT=$(echo "$vanilla_opt" | awk -F/ '{print $NF}' | grep -o '[[:digit:]]\+' | head -n2 | awk 'NR==2')
EXTRA_DIGIT="0"
VERSION="$FIRST_DIGIT$SECOND_DIGIT"
chars=`echo -n $SECOND_DIGIT | wc -c`
if ! [ "$chars" -eq 2 ]; then
VERSION="$FIRST_DIGIT$EXTRA_DIGIT$SECOND_DIGIT"
fi
fi
if [ "$VERSION" -lt 510 ]; then
echo -en "
You requested a build for a $vanilla_opt kernel.
Minimum supported kernelseries is 5.10.x
Aborting...
"
env_clean
exit 0
fi
# Check for proper use of --stock= flag
if ! [ "$OS" = "Debian" ]; then
if [ "x$stock_opt" = "xyes" ]; then
echo "
Compiling a distro's stock kernel is supported
in Debian only. You can compile the
v4l tree or a vanilla kernel. Aborting....
"
env_clean
exit 0
fi
fi
# Get build-deps, Debian only.
if [ "$OS" = "Debian" -o "$OS" = "Devuan" ]; then
if ! dpkg-query -l build-essential | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency build-essential, marking for installation.
"
apt-get install build-essential -y || die "Error installing dependency build-essential"
fi
if ! dpkg-query -l asciidoc | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency asciidoc, marking for installation.
"
apt-get install asciidoc --no-install-recommends -y || die "Error installing dependency asciidoc"
fi
if ! dpkg-query -l binutils-dev | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency binutils-dev, marking for installation.
"
apt-get install binutils-dev --no-install-recommends -y || die "Error installing dependency binutils-dev"
fi
if ! dpkg-query -l bison | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency bison, marking for installation.
"
apt-get install bison --no-install-recommends -y || die "Error installing dependency bison"
fi
if ! dpkg-query -l bc | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency bc, marking for installation.
"
apt-get install bc --no-install-recommends -y || die "Error installing dependency bc"
fi
if ! dpkg-query -l devscripts | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency devscripts, marking for installation.
"
apt-get install devscripts --no-install-recommends -y || die "Error installing dependency devscripts"
fi
if ! dpkg-query -l libelf-dev | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency libelf-dev, marking for installation.
"
apt-get install libelf-dev --no-install-recommends -y || die "Error installing dependency libelf-dev"
fi
if ! dpkg-query -l fakeroot | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency fakeroot, marking for installation.
"
apt-get install fakeroot --no-install-recommends -y || die "Error installing dependency fakeroot"
fi
if ! dpkg-query -l flex | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency flex, marking for installation.
"
apt-get install flex --no-install-recommends -y || die "Error installing dependency flex"
fi
if ! dpkg-query -l initramfs-tools | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency initramfs-tools, marking for installation.
"
apt-get install initramfs-tools --no-install-recommends -y || die "Error installing dependency initramfs-tools"
fi
if ! dpkg-query -l kernel-wedge | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency kernel-wedge, marking for installation.
"
apt-get install kernel-wedge --no-install-recommends -y || die "Error installing dependency kernel-wedge"
if [ "$OS" = "Debian" -o "$OS" = "Devuan" ]; then
apt-get -t $RELEASE-backports install kernel-wedge --no-install-recommends -y > /dev/null 2>&1
apt-get -t $RELEASE-backports install linux-base --no-install-recommends -y > /dev/null 2>&1
apt-get -t $RELEASE-backports install irqbalance --no-install-recommends -y > /dev/null 2>&1
apt-get -t $RELEASE-backports install firmware-linux-free --no-install-recommends -y > /dev/null 2>&1
fi
else
if [ "$OS" = "Debian" -o "$OS" = "Devuan" ]; then
apt-get -t $RELEASE-backports install kernel-wedge --no-install-recommends -y > /dev/null 2>&1
fi
fi
if ! dpkg-query -l libdigest-sha-perl | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency libdigest-sha-perl, marking for installation.
"
apt-get install libdigest-sha-perl --no-install-recommends -y || die "Error installing dependency libdigest-sha-perl"
fi
if ! dpkg-query -l libfile-fcntllock-perl | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency libfile-fcntllock-perl, marking for installation.
"
apt-get install libfile-fcntllock-perl --no-install-recommends -y || die "Error installing dependency libfile-fcntllock-perl"
fi
if ! dpkg-query -l libproc-processtable-perl | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency libproc-processtable-perl, marking for installation.
"
apt-get install libproc-processtable-perl --no-install-recommends -y || die "Error installing dependency libproc-processtable-perl"
fi
if ! dpkg-query -l bin86 | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency bin86, marking for installation.
"
apt-get install bin86 --no-install-recommends -y || die "Error installing dependency bin86"
fi
if ! dpkg-query -l makedumpfile | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency makedumpfile, marking for installation.
"
apt-get install makedumpfile --no-install-recommends -y || die "Error installing dependency makedumpfile"
fi
if ! dpkg-query -l libncurses5 | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency libncurses5, marking for installation.
"
apt-get install libncurses5 --no-install-recommends -y || die "Error installing dependency libncurses5"
fi
if ! dpkg-query -l libncurses5-dev | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency libncurses5-dev, marking for installation.
"
apt-get install libncurses5-dev --no-install-recommends -y || die "Error installing dependency libncurses5-dev"
fi
if ! dpkg-query -l patch | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency patch, marking for installation.
"
apt-get install patch --no-install-recommends -y || die "Error installing dependency patch"
fi
if ! dpkg-query -l patchutils | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency patchutils, marking for installation.
"
apt-get install patchutils --no-install-recommends -y || die "Error installing dependency patchutils"
fi
if ! dpkg-query -l rsync | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency rsync, marking for installation.
"
apt-get install rsync --no-install-recommends -y || die "Error installing dependency rsync"
fi
if ! dpkg-query -l kmod | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency kmod, marking for installation.
"
apt-get install kmod --no-install-recommends -y || die "Error installing dependency kmod"
fi
if ! dpkg-query -l g++ | grep "ii" > /dev/null 2>&1; then
echo "
Missing dependency g++, marking for installation.
"
apt-get install g++ --no-install-recommends -y || die "Error installing dependency g++"
fi
apt-get build-dep --no-install-recommends linux -y
if ! [ "$?" -eq 0 ]; then
echo "
Error(s) while installing build dependencies
Aborting...
"
env_clean
exit 1
fi
fi
chown $user_opt:$user_opt -R `pwd`
#
# Get the source
#
# Debian
if [ "x$stock_opt" = "xyes" ]; then
echo "
Going to download the kernel source.
"
sleep 3
su $user_opt -c "apt-get source linux -y" || die "Error(s) while fetching Debian Linux source"
cd linux-*
rm -f *.orig.tar.xz
rm -f *debian.tar.xz
rm -f *.dsc
make clean && make mrproper
FIRST_DIGIT=$(echo `pwd` | awk -F/ '{print $NF}' | grep -o '[[:digit:]]\+' | head -n1 | awk 'NR==1')
SECOND_DIGIT=$(echo `pwd` | awk -F/ '{print $NF}' | grep -o '[[:digit:]]\+' | head -n2 | awk 'NR==2')
EXTRA_DIGIT="0"
VERSION="$FIRST_DIGIT$SECOND_DIGIT"
chars=`echo -n $SECOND_DIGIT | wc -c`
if ! [ "$chars" -eq 2 ]; then
VERSION="$FIRST_DIGIT$EXTRA_DIGIT$SECOND_DIGIT"
fi
if [ "$VERSION" -lt 510 ]; then
echo "
Minimum supported kernel version is 5.10.x.
Aborting...
"
exit 1
fi
fi
# Vanilla
MAJOR=$(echo "$vanilla_opt" | cut -d'.' -f1)
if [ "x$vanilla_opt" != "x" ]; then
echo "
Going to download the kernel source.
"
sleep 3
if [ "x$next_opt" = "xno" ]; then
if echo "$vanilla_opt" | grep "rc" > /dev/null 2>&1; then
wget https://git.kernel.org/torvalds/t/linux-$vanilla_opt.tar.gz || die "Error(s) while fetching Linux source"
else
wget https://mirrors.edge.kernel.org/pub/linux/kernel/v$MAJOR.x/linux-$vanilla_opt.tar.xz || die "Error(s) while fetching Linux source"
fi
if echo "$vanilla_opt" | grep "rc" > /dev/null 2>&1; then
tar -xzf linux-$vanilla_opt.tar.gz
else
tar -xJf linux-$vanilla_opt.tar.xz
fi
cd linux-$vanilla_opt
make clean && make mrproper
if [ "x$debug_opt" = "xyes" ]; then
echo "
Source is downloaded.
"
confirmyes
if ! [ "$?" -eq 0 ]; then
env_clean
exit 0
fi
fi
fi
fi
#
# Patch the source
#
# Common (stock and vanilla kernels)
FIRST_DIGIT=$(echo `pwd` | awk -F/ '{print $NF}' | grep -o '[[:digit:]]\+' | head -n1 | awk 'NR==1')
SECOND_DIGIT=$(echo `pwd` | awk -F/ '{print $NF}' | grep -o '[[:digit:]]\+' | head -n2 | awk 'NR==2')
EXTRA_DIGIT="0"
VERSION="$FIRST_DIGIT$SECOND_DIGIT"
chars=`echo -n $SECOND_DIGIT | wc -c`
if ! [ "$chars" -eq 2 ]; then
VERSION="$FIRST_DIGIT$EXTRA_DIGIT$SECOND_DIGIT"
fi
# saa716x patch
if [ "x$saa_opt" = "xyes" ]; then
mkdir drivers/media/pci/saa716x
cp -f ../drivers/media/pci/saa716x/* drivers/media/pci/saa716x/
patch -p0 < ../Kconfig-4.10.patch
_patch
if [ "x$debug_opt" = "xyes" ]; then
echo "
saa716x added, Kconfig patched for saa716x.
"
confirmyes
if ! [ "$?" -eq 0 ]; then
env_clean
exit 0
fi
fi
patch -p0 < ../Makefile-4.2.patch
_patch
if [ "x$debug_opt" = "xyes" ]; then
echo "
Makefile is patched for saa716x.
"
confirmyes
if ! [ "$?" -eq 0 ]; then
env_clean
exit 0
fi
fi
fi
patch -p0 < ../bootlog.patch
_patch
if [ "x$debug_opt" = "xyes" ]; then
echo "
bootlog is fixed for ACPI errrors
"
confirmyes
if ! [ "$?" -eq 0 ]; then
env_clean
exit 0
fi
fi
#
# Configure the source
#
# Vanilla and Stock
echo -en "
Going to configure your kernel.
"
if [ "x$big_opt" = "xyes" ]; then
make oldconfig
else
make localmodconfig
fi
ADAPTERS=$(cat .config | grep "CONFIG_DVB_MAX_ADAPTERS" | grep -o '[[:digit:]]\+')
if ! [ "$ADAPTERS" = "$adapters_opt" ]; then
sed -i "s/CONFIG_DVB_MAX_ADAPTERS=$ADAPTERS/CONFIG_DVB_MAX_ADAPTERS=$adapters_opt/" .config
fi
sed -i 's/CONFIG_DEBUG_INFO=y/# CONFIG_DEBUG_INFO is not set/' .config
sed -i "s/debian\/certs\/debian-uefi-certs.pem/\"\"/" .config
sed -i "s/CONFIG_MODULE_SIG_KEY=\".*\"/CONFIG_MODULE_SIG_KEY=\"certs\/signing_key.pem\"/" .config
sed -i 's/CONFIG_BUILD_SALT=\".*\"/CONFIG_BUILD_SALT=\"\"/' .config
if [ "x$debug_opt" = "xyes" ]; then
echo "
Kernel configured.
"
confirmyes
if ! [ "$?" -eq 0 ]; then
env_clean
exit 0
fi
fi
#
# Compile the source
#
make -j3 deb-pkg LOCALVERSION=-custom | tee ../buildlog_vanilla_$vanilla_opt
#
# Install the result
#
if [ "x$debug_opt" = "xyes" ]; then
echo "
Going to install your kernel.
"
confirmyes
if ! [ "$?" -eq 0 ]; then
env_clean
exit 0
fi
fi
cd $DIR
if [ "x$headers_opt" = "xno" ] ; then
dpkg -i linux-image-* && sleep 2
else
dpkg -i linux-image* linux-headers* linux-libc-dev*
fi
if [ "$?" -eq 0 ]; then
if [ "x$headers_opt" = "xyes" ]; then
echo -en "
Your kernel and headers are installed.
"
else
echo -en "
Your kernel is installed.
"
fi
fi
if [ "x$firmware_opt" = "xyes" ]; then
# Install the firmware
if ! [ -f /lib/firmware/dvb-tuner-si2158-a20-01.fw ] > /dev/null 2>&1; then
echo "
Do you want to install included firmware into /lib/firmware?
"
confirmyes "Yes, please do. [Y/n]"
if [ "$?" -eq 0 ]; then
if [ ! -d /lib/firmware ]; then
mkdir /lib/firmware
fi
cp -f firmware/* /lib/firmware/
fi
fi
fi
env_clean