-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkernelseeds
More file actions
executable file
·690 lines (623 loc) · 30.3 KB
/
Copy pathkernelseeds
File metadata and controls
executable file
·690 lines (623 loc) · 30.3 KB
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
#!/usr/bin/env bash
NAME="Kernel Seeds"
CODENAME="kernelseeds"
COPYRIGHT="Copyright (C) 2013 Nathan Shearer"
LICENSE="GNU General Public License 2.0"
VERSION="4.0.1.0"
# The kernel config has menu options which hide or unhide additional options
# The menuconfig options do not add any code to the kernel
# Disabled menuconfig options prevents compilation of subsidiary modules
# This function searches for and enables all menuconfig options
# $1 The kernel source path
function kernelseeds_enable_all_menuconfig
{
local KERNEL_SOURCE_PATH="$1"
for OPTION in $(find "$KERNEL_SOURCE_PATH" -name Kconfig -exec grep menuconfig {} \; | sed -e 's/menuconfig //'); do
# attempt =m first then attempt =y
if ! kernelseeds_option_is_set .config "CONFIG_$OPTION"; then
kernelseeds_set_option "$KERNEL_SOURCE_PATH" "CONFIG_$OPTION" m
fi
if ! kernelseeds_option_is_set .config "CONFIG_$OPTION"; then
kernelseeds_set_option "$KERNEL_SOURCE_PATH" "CONFIG_$OPTION" y
fi
done
}
# Enable all modules
# $1 The kernel source path
function kernelseeds_enable_all_modules
{
local KERNEL_SOURCE_PATH="$1"
rm -rf "$TMP/kernelsource-allmodconfig"
cp -a "$KERNEL_SOURCE_PATH" "$TMP/kernelsource-allmodconfig"
kernelseeds_quiet make -C "$TMP/kernelsource-allmodconfig" clean mrproper
kernelseeds_quiet make -C "$TMP/kernelsource-allmodconfig" allmodconfig
grep -E '^[^#].+=m$' "$TMP/kernelsource-allmodconfig/.config" > "$TMP/allmod.config"
rm -rf "$TMP/kernelsource-allmodconfig"
kernelseeds_set_options "$KERNEL_SOURCE_PATH" "$TMP/allmod.config"
}
# \brief Generate a default config if .config does not exist
# $1 The kernel source path
function kernelseeds_defconfig
{
if [ ! -f "$1/.config" ]; then
echo -n "An existing config was not found at \"$1/.config\". Generating a new default config..."
#pushd "$1" > /dev/null
kernelseeds_quiet make -C "$1" defconfig
#popd > /dev/null
echo " done."
fi
}
# \brief Set a kernel option
# $1 The kernel source path
# $2 The kernel option
# $3 y|m The kernel option value
# $4 true|false Replace existing values with the new value if the option is already set. Default is false.
# $5 true|false Allow overrides during "make olddefconfig". Default is false.
function kernelseeds_set_option
{
local KERNEL_SOURCE_PATH="$1"
local OPTION="$2"
local VALUE="$3"
local OPTION_VALUE="${OPTION}=$VALUE"
local ALLOW_REPLACE="$4"; if [ "$ALLOW_REPLACE" = "" ]; then ALLOW_REPLACE=false; fi
local ALLOW_OVERRIDE="$5"; if [ "$ALLOW_OVERRIDE" = "" ]; then ALLOW_OVERRIDE=false; fi
kernelseeds_defconfig "$KERNEL_SOURCE_PATH"
if kernelseeds_option_is_set "$KERNEL_SOURCE_PATH/.config" "$OPTION"; then
if kernelseeds_option_is_set "$KERNEL_SOURCE_PATH/.config" "$OPTION" "$VALUE"; then
echo "$OPTION_VALUE is already set"
return
fi
if $ALLOW_REPLACE; then
if [ ! -d "$TMP/kernelsource" ]; then
cp -a "$KERNEL_SOURCE_PATH" "$TMP/kernelsource"
fi
sed -i -r "s/^$OPTION=.*$/$OPTION_VALUE/" "$TMP/kernelsource/.config"
fi
else
if [ ! -d "$TMP/kernelsource" ]; then
cp -a "$KERNEL_SOURCE_PATH" "$TMP/kernelsource"
fi
sed -i -r "s/^# $OPTION is not set$/$OPTION_VALUE/" "$TMP/kernelsource/.config"
fi
make -C "$TMP/kernelsource" olddefconfig > "$TMP/kernelseeds-make-olddefconfig" 2>&1
if [ $? -ne 0 ]; then
echo "$OPTION_VALUE skipped due to error during \"make olddefconfig\""
rm -rf "$TMP/kernelsource"
return 1
fi
if ! $ALLOW_OVERRIDE && grep -q override "$TMP/kernelseeds-make-olddefconfig"; then
echo "$OPTION_VALUE skipped due to override during \"make olddefconfig\""
rm -rf "$TMP/kernelsource"
return 2
fi
if $TEST && ! kernelseeds_quiet make -C "$TMP/kernelsource" -j "$THREADS"; then
echo "$OPTION_VALUE skipped due to error during kernel build test"
rm -rf "$TMP/kernelsource"
return 3
fi
if kernelseeds_option_is_set "$TMP/kernelsource/.config" "$OPTION" "$VALUE"; then
echo "$OPTION_VALUE"
elif [ "$VALUE" = "n" ]; then
# special case where =n will remove the option rather than leaving CONFIG_OPTION=n in the .config file, so it actually was set
echo "$OPTION_VALUE"
else
echo "$OPTION_VALUE was set but then later reverted by \"make olddefconfig\""
return 4
fi
cp -f "$TMP/kernelsource/.config" "$KERNEL_SOURCE_PATH/.config"
}
# \brief Set all options from $2
# $1 The kernel source path
# $2 The seed config file
# $3 true|false Replace existing values with the new value if the option is already set. Default is false.
# $4 true|false Allow overrides during "make olddefconfig". Default is false.
function kernelseeds_set_options
{
local KERNEL_SOURCE_PATH="$1"
local SEED_CONFIG="$2"
local ALLOW_REPLACE="$3"; if [ "$ALLOW_REPLACE" = "" ]; then ALLOW_REPLACE=false; fi
local ALLOW_OVERRIDE="$4"; if [ "$ALLOW_OVERRIDE" = "" ]; then ALLOW_OVERRIDE=false; fi
for OPTION_VALUE in $(grep -E "^CONFIG.*=[my]$" "$SEED_CONFIG"); do
local OPTION=$(printf "$OPTION_VALUE" | sed -r 's/^(.*)=[my]/\1/')
local VALUE=$(printf "$OPTION_VALUE" | sed -r 's/^.*=([my])/\1/')
kernelseeds_set_option "$KERNEL_SOURCE_PATH" "$OPTION" "$VALUE" "$ALLOW_REPLACE" "$ALLOW_OVERRIDE"
done
}
function kernelseeds_help
{
# 01234567890123456789012345678901234567890123456789012345678901234567890123456789
echo "Description:"
echo " Apply a set of kernel options to a new or existing kernel configuration."
echo
echo "Usage:"
echo " kernelseeds [options]"
echo
echo "Options:"
echo " -a, --architecture x86"
echo " Change ARCH when configuring the kernel."
echo " Possible architectures are defined at kernel-source/arch/*:"
echo " --enable-all-menuconfig"
echo " Enable all menu options which unhide additional options."
echo " --enable-all-modules"
echo " Enable all modules. Overrides are disabled by default."
echo " --set-active-yes"
echo " Scan this system and set active kernel options to yes."
echo " --set-common"
echo " Set common options."
echo " --set-options seed.config"
echo " Set all options from seed.config. Overrides are disabled by default."
echo " --set-raspberry-pi-2"
echo " Set options for Raspberry Pi 2 support."
echo " -h, --help"
echo " Display this help message and exit."
echo " --override-enable"
echo " Set options that would override existing options. Disabled by default."
echo " --override-disable"
echo " Do not override existing options. Disabled by default."
echo " --test-enable"
echo " Enable kernel build testing for every changed kernel option."
echo " --test-disable"
echo " Disable kernel build testing for every changed kernel option."
echo " --tmpfs"
echo " Use tmpfs to improve performance."
echo
echo "Example: Enable all possible modules:"
echo " # cd /usr/src/linux"
echo " # kernelseeds --enable-all-menuconfig --enable-all-modules"
echo " # make && make modules_install"
echo
echo "Example: Enable all possible modules with an existing distribution kernel:"
echo " # cd /usr/src/linux"
echo " # modprobe configs"
echo " # gzip -c -d /proc/config.gz > .config"
echo " # kernelseeds --enable-all-menuconfig --enable-all-modules"
echo " # make && make modules_install"
echo
echo "Example: Scan this system and set active drivers and modules to builtin:"
echo " # cd /usr/src/linux"
echo " # kernelseeds --override-enable --set-active-yes"
echo " # make && make modules_install"
echo
echo "Version:"
echo " $NAME $VERSION"
echo " $COPYRIGHT"
echo " Licensed under $LICENSE"
}
# \brief Return true if a kernel option is set
# $1 The kernel .config file
# $2 The kernel option
# $3 The kernel option value (only return true if this optional value is matched)
function kernelseeds_option_is_set
{
if [ "$3" = "" ]; then
grep -E -q "^$2=.*$" "$1"
return $?
else
grep -E -q "^$2=$3$" "$1"
return $?
fi
}
# \brief Run a command and only show output if an error occurs
# \param $@ The command and its arguments
function kernelseeds_quiet
{
local RANDOM64=$(( $RANDOM * $RANDOM * $RANDOM * $RANDOM ))
"$@" >>/tmp/.quiet.$RANDOM64 2>/tmp/.quiet.$RANDOM64
local STATUS="$?"
if [ "$STATUS" -ne 0 ]; then
cat /tmp/.quiet.$RANDOM64
fi
rm -f /tmp/.quiet.$RANDOM64
return "$STATUS"
}
# \brief Scan the running kernel and set active options to yes.
# $1 The kernel source path
function kernelseeds_set_active_yes
{
local KERNEL_SOURCE_PATH="$1"
kernelseeds_defconfig "$KERNEL_SOURCE_PATH"
LSMOD_MODULES=$(cut -d ' ' -f 1 /proc/modules | sort | uniq) # this works, but "kvm" matches too many CONFIG_ options
LSPCI_DRIVERS=$(lspci -v | grep "Kernel driver" | sed -r -e 's/.*: (.*)/\1/' | sort | uniq)
LSPCI_MODULES=$(lspci -v | grep "Kernel modules" | sed -r -e 's/.*: (.*)/\1/' | sed -r -e 's/, /\n/g' | sort | uniq)
# some modules use '-' and some use '_' in the name, so convert - to _
ALL=$(for S in $LSMOD_MODULES $LSPCI_DRIVERS $LSPCI_MODULES; do printf "$S\n"; done | tr - _ | sort | uniq)
local OPTIONS=""
for S in $ALL; do
# some modules use '-' and some use '_' in the name, so search for both
SS=$(printf "$S" | sed -r -e 's/[-_]/[-_]/g')
# search all Makefile files for matching .o then output only the CONFIG_ string
OPTION=$(find "$KERNEL_SOURCE_PATH" -name Makefile -exec grep -e "^obj.* $SS\\.o" '{}' \; | grep -E -o 'CONFIG_[A-Z0-9_]+')
if [ "$OPTION" = "" ]; then
printf "error: no kernel options found for \"$S\"\n" > /dev/stderr
continue
fi
if [ $(printf "$OPTION\n" | sort | uniq | tr -s '\n' | wc -l) -ne 1 ]; then
printf "error: more than one kernel option was found for \"$S\": " > /dev/stderr
printf "$OPTION" | sort | uniq | tr -s '\n' ' ' > /dev/stderr
printf '\n'
continue
fi
OPTIONS="$OPTIONS\n$OPTION"
done
OPTIONS=$(printf "$OPTIONS" | sort | uniq)
for S in $OPTIONS; do
kernelseeds_set_option "$KERNEL_SOURCE_PATH" "$S" y true
done
}
# Set common options
# $1 The kernel source path
function kernelseeds_set_common
{
local KERNEL_SOURCE_PATH="$1"
kernelseeds_defconfig "$KERNEL_SOURCE_PATH"
echo 'Set common options'
echo 'Enable /proc/config.gz'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_IKCONFIG m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_IKCONFIG_PROC y true true
echo 'Enable UEFI Support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EFI y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EFI_STUB y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EFI_MIXED n true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EFIVAR_FS m true true
echo 'Set the timer frequency to 1000Hz'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_HZ_1000 y true true
echo 'Enable Graphics Support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_FB y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_FRAMEBUFFER_CONSOLE y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_AMDGPU m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_CIRRUS_QEMU m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_I915 m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_QXL m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_RADEON m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_UDL m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_VBOXVIDEO m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_VIRTIO_GPU m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_VMWGFX y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_VMWGFX_FBCON y true true
#kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DRM_SIMPLEDRM y true true
#kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SYSFB_SIMPLEFB y true true
echo 'Enable SATA support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SATA_AHCI y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SATA_MV y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SATA_NV y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SATA_PROMISE y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SATA_SIL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SATA_SIS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SATA_SVW y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SATA_ULI y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SATA_VIA y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SATA_VITESSE y true true
echo 'Enable SCSI support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SCSI_MVSAS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SCSI_MVSAS_TASKLET y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SCSI_SAS_ATA y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SCSI_SAS_LIBSAS y true true
echo 'Enable NVMe support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_BLK_DEV_NVME y true true
echo 'Enable Advanced Partition Support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_BLOCK y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_PARTITION_ADVANCED y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ACORN_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ACORN_PARTITION_CUMANA y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ACORN_PARTITION_EESOX y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ACORN_PARTITION_ICS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ACORN_PARTITION_ADFS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ACORN_PARTITION_POWERTEC y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ACORN_PARTITION_RISCIX y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_AIX_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_OSF_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_AMIGA_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ATARI_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_MAC_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_BSD_DISKLABEL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_MINIX_SUBPARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SOLARIS_X86_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_UNIXWARE_DISKLABEL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_LDM_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SGI_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ULTRIX_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SUN_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_KARMA_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SYSV68_PARTITION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CMDLINE_PARTITION y true true
echo 'Enable Ext Support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EXT2_FS m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EXT2_FS_XATTR y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EXT2_FS_POSIX_ACL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EXT2_FS_SECURITY y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EXT3_FS m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EXT3_FS_POSIX_ACL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EXT3_FS_SECURITY y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EXT4_FS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EXT4_FS_POSIX_ACL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_EXT4_FS_SECURITY y true true
echo 'Enable XFS Support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_XFS_FS m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_XFS_SUPPORT_V4 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_XFS_QUOTA y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_XFS_POSIX_ACL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_XFS_RT y true true
echo 'Enable Btrfs Support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_BTRFS_FS m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_BTRFS_FS_POSIX_ACL y true true
echo 'Enable iptables support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NETFILTER y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_IP_NF_FILTER m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_IP_NF_NAT m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_IP_NF_TARGET_MASQUERADE m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_IP_NF_TARGET_NETMAP m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_IP_NF_TARGET_REDIRECT m true true
echo 'Enable Networking support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NET y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_INET y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_IP_PNP y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_IP_PNP_DHCP y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NETDEVICES y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ETHERNET y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NET_VENDOR_INTEL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_E100 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_E1000 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_E1000E y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_VMXNET3 y true true
echo 'Enable NFS support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NETWORK_FILESYSTEMS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFS_FS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFS_V2 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFS_V3 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFS_V3_ACL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFS_V4 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFS_SWAP y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFS_V4_1 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFS_V4_2 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFS_V4_1_MIGRATION y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_ROOT_NFS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFS_DISABLE_UDP_SUPPORT n true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFSD m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFSD_V3 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFSD_V3_ACL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFSD_V4 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFSD_BLOCKLAYOUT y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFSD_SCSILAYOUT y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFSD_FLEXFILELAYOUT y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NFSD_V4_SECURITY_LABEL y true true
echo 'Enable SMB Support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_NETWORK_FILESYSTEMS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CIFS m true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CIFS_ALLOW_INSECURE_LEGACY y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CIFS_WEAK_PW_HASH y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CIFS_UPCALL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CIFS_XATTR y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CIFS_POSIX y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CIFS_DFS_UPCALL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CIFS_SMB_DIRECT y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CIFS_FSCACHE y true true
echo 'Enable RAID support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_BLK_DEV_MD y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_MD_LINEAR y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_MD_RAID0 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_MD_RAID1 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_MD_RAID10 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_MD_RAID456 y true true
echo 'Enable USB support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_PCI y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_SUPPORT y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_XHCI_HCD y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_XHCI_PCI y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_XHCI_PCI_RENESAS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_EHCI_HCD y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_OHCI_HCD y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_OHCI_HCD_PCI y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_UHCI_HCD y true true
echo 'Enable USB Storage Support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_ALAUDA y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_CYPRESS_ATACB y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_DATAFAB y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_ENE_UB6250 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_FREECOM y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_ISD200 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_JUMPSHOT y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_KARMA y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_ONETOUCH y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_REALTEK y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_SDDR09 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_SDDR55 y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_STORAGE_USBAT y true true
echo 'Enable VirtIO support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_REMOTEPROC y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_VIRTIO_PCI y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_VIRTIO_BLK y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SCSI_VIRTIO y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_VIRTIO_NET y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_HW_RANDOM_VIRTIO y true true
echo 'Enable audio over HDMI support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SND_HDA_INTEL y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SND_HDA_CODEC_HDMI y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SND_HDA_GENERIC y true true
echo 'Enable VMware support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_VMWARE_PVSCSI y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SCSI_MPT2SAS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SCSI_MPT3SAS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_VMWARE_VMCI_VSOCKETS m true true
echo 'A preallocated buffer-size of 2048 (kB) or higher is recommended for the HD-audio driver'
echo 'CONFIG_SND_HDA_PREALLOC_SIZE=2048' | tee -a .config
echo 'Power management and ACPI options > CPU Frequency scaling > Default CPUFreq governor (performance)'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE y true true
echo 'Processor type and features > Preemption Model (Preemptible Kernel (Low-Latency Desktop))'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_PREEMPT y true true
echo 'Enable Control Group support'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CGROUPS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CGROUP_FREEZER y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CGROUP_PIDS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CGROUP_DEVICE y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CPUSETS y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CGROUP_CPUACCT y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_MEMCG y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_MEMCG_SWAP y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_MEMCG_KMEM y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CGROUP_HUGETLB y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CGROUP_PERF y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CGROUP_SCHED y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_FAIR_GROUP_SCHED y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CFS_BANDWIDTH y true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_BLK_CGROUP y true true
echo 'dev-libs/ell and sys-apps/keyutils require CONFIG_KEY_DH_OPERATIONS'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_KEY_DH_OPERATIONS y true true
echo 'media-libs/mesa requires CONFIG_CHECKPOINT_RESTORE'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_CHECKPOINT_RESTORE y true true
echo 'www-client/google-chrome requires CONFIG_USER_NS'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USER_NS y true true
echo 'Clear system-wide ring of truted keys and revocation certificates'
echo 'CONFIG_SYSTEM_TRUSTED_KEYS=""';
sed -i -r 's/^CONFIG_SYSTEM_TRUSTED_KEYS=".*"$/CONFIG_SYSTEM_TRUSTED_KEYS=""/' .config
echo 'CONFIG_SYSTEM_REVOCATION_KEYS=""';
sed -i -r 's/^CONFIG_SYSTEM_REVOCATION_KEYS=".*"$/CONFIG_SYSTEM_REVOCATION_KEYS=""/' .config
echo 'Disable SELinux'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_SECURITY_SELINUX n true true
echo 'Disable USB Attached SCSI since it is broken for seagate drives'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_USB_UAS n true true
echo 'Disable debug info because it requires pahole at kernel compile time'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DEBUG_INFO n true true
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DEBUG_INFO_BTF n true true
echo 'Disable "Stack utilization instrumentation" because it floods "used greatest stack depth" to system log'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_DEBUG_STACK_USAGE n true true
echo 'Disable "Event debugging" because it is autoloaded and floods the system log'
kernelseeds_set_option "$KERNEL_SOURCE_PATH" CONFIG_INPUT_EVBUG n true true
}
# Set options for Raspberry Pi 2 support
# $1 The kernel source path
function kernelseeds_set_raspberry_pi_2
{
local KERNEL_SOURCE_PATH="$1"
echo 'Set options for Raspberry Pi 2 support'
rm -rf "$TMP/kernelsource"
cp -a "$KERNEL_SOURCE_PATH" "$TMP/kernelsource"
pushd "$TMP/kernelsource" > /dev/null
echo 'Build in SD card support to enable booting off of SD cards'
echo 'CONFIG_MMC=y' | tee -a .config
echo 'CONFIG_MMC_BLOCK=y' | tee -a .config
echo 'Build in support for the Raspberry Pi SD/MMC controller'
echo 'CONFIG_MMC_SDHCI=y' | tee -a .config
echo 'MMC_SDHCI_PLTFM=y' | tee -a .config
echo 'MMC_SDHCI_BCM2835=y' | tee -a .config
echo 'Build in support for the Raspberry Pi GPU'
echo 'CONFIG_FB=y' | tee -a .config
echo 'CONFIG_FB_BCM2708=y' | tee -a .config
echo 'CONFIG_FRAMEBUFFER_CONSOLE=y' | tee -a .config
echo 'Enable support for 3D acceleration'
echo 'Note: This driver requires that "avoid_warnings=2" be present in the config.txt for the firmware, to keep it from smashing the display setup.'
echo 'CONFIG_DRM=m' | tee -a .config
echo 'CONFIG_DRM_VC4=m' | tee -a .config
echo 'Build in support for the Raspberry Pi Ethernet Chipset'
echo 'CONFIG_USB_NET_SMSC95XX=y' | tee -a .config
echo 'Disable seccomp due to compile error: "gcc: error: unrecognized command line option ‘-m32’; did you mean ‘-mbe32’?"'
echo 'CONFIG_SECCOMP=n' | tee -a .config
kernelseeds_quiet make olddefconfig
popd > /dev/null
cp -f "$TMP/kernelsource/.config" "$KERNEL_SOURCE_PATH/.config"
}
#------------------------------------------------------------------------------
# default configuration
KERNEL_SOURCE_PATH=.
OVERRIDE=false
REPLACE=false
TEST=false
TMP="/tmp/$CODENAME.$$"; mkdir -m 0700 -p "$TMP"
TMPFS=false
THREADS=$(grep -c processor /proc/cpuinfo)
#------------------------------------------------------------------------------
# command line arguments
while [ $# -gt 0 ]; do
case "$1" in
"-a"|"--architecture")
export ARCH="$2"
shift 2
;;
"--enable-all-menuconfig")
kernelseeds_enable_all_menuconfig "$KERNEL_SOURCE_PATH"
shift
;;
"--enable-all-modules")
kernelseeds_enable_all_modules "$KERNEL_SOURCE_PATH"
shift
;;
"-h"|"--help")
kernelseeds_help
exit
;;
"--override-disable")
OVERRIDE=false
shift
;;
"--override-enable")
OVERRIDE=true
shift
;;
"--replace-disable")
REPLACE=false
shift
;;
"--replace-enable")
REPLACE=true
shift
;;
"--set-active-yes")
kernelseeds_set_active_yes "$KERNEL_SOURCE_PATH"
shift
;;
"--set-common")
kernelseeds_set_common "$KERNEL_SOURCE_PATH"
shift
;;
"--set-options")
kernelseeds_set_options "$KERNEL_SOURCE_PATH" "$2" "$REPLACE" "$OVERRIDE"
shift 2
;;
"--set-raspberry-pi-2")
kernelseeds_set_raspberry_pi_2 "$KERNEL_SOURCE_PATH"
shift
;;
"--test-disable")
TEST=false
shift
;;
"--test-enable")
TEST=true
shift
;;
"--tmp")
TMP="$2"
shift 2
;;
"--tmpfs")
if ! $TMPFS; then
mkdir -m 0700 -p "$TMP.tmpfs"
mount -t tmpfs none "$TMP.tmpfs"
mv -f "$TMP"/* "$TMP.tmpfs" 2> /dev/null
rmdir "$TMP"
TMP="$TMP.tmpfs"
TMPFS=true
fi
shift
;;
*)
kernelseeds_help
exit 1
;;
esac
done
if [ ! -d "$KERNEL_SOURCE_PATH" ]; then
echo "error: the kernel_source_path at \"$KERNEL_SOURCE_PATH\" is not a directory"
exit 2
fi
if [ ! -f "$KERNEL_SOURCE_PATH/Makefile" ]; then
echo "error: the kernel_source_path at \"$KERNEL_SOURCE_PATH\" does not appear to contain a kernel Makefile"
exit 3
fi
unset ARCH
if $TMPFS; then
umount "$TMP"
fi
rm -rf --one-file-system "$TMP"