forked from buildroot/buildroot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenrandconfig
executable file
·837 lines (713 loc) · 37.9 KB
/
genrandconfig
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
#!/usr/bin/env python3
# Copyright (C) 2014 by Thomas Petazzoni <[email protected]>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# This script generates a random configuration for testing Buildroot.
from binascii import hexlify
import asyncio
import csv
import os
from random import randint
import sys
import traceback
from distutils.version import StrictVersion
import platform
if sys.version_info < (3, 8):
from asyncio import coroutine
else:
from types import coroutine
class SystemInfo:
DEFAULT_NEEDED_PROGS = ["make", "git", "gcc", "timeout"]
DEFAULT_OPTIONAL_PROGS = ["bzr", "java", "javac", "jar", "diffoscope"]
def __init__(self):
self.needed_progs = list(self.__class__.DEFAULT_NEEDED_PROGS)
self.optional_progs = list(self.__class__.DEFAULT_OPTIONAL_PROGS)
self.progs = {}
def find_prog(self, name, flags=os.X_OK, env=os.environ):
if not name or name[0] == os.sep:
raise ValueError(name)
prog_path = env.get("PATH", None)
# for windows compatibility, we'd need to take PATHEXT into account
if prog_path:
for prog_dir in filter(None, prog_path.split(os.pathsep)):
# os.join() not necessary: non-empty prog_dir
# and name[0] != os.sep
prog = prog_dir + os.sep + name
if os.access(prog, flags):
return prog
# --
return None
@coroutine
def has(self, prog):
"""Checks whether a program is available.
Lazily evaluates missing entries.
Returns: None if prog not found, else path to the program [evaluates
to True]
"""
try:
return self.progs[prog]
except KeyError:
pass
have_it = self.find_prog(prog)
# java[c] needs special care
if have_it and prog in ('java', 'javac'):
proc = yield from asyncio.create_subprocess_shell(
"%s -version | grep gcj" % prog,
stdout=asyncio.subprocess.DEVNULL,
stderr=asyncio.subprocess.DEVNULL)
ret = yield from proc.wait()
if ret != 1:
have_it = False
# --
self.progs[prog] = have_it
return have_it
def check_requirements(self):
"""Checks program dependencies.
Returns: True if all mandatory programs are present, else False.
"""
do_check_has_prog = self.has
missing_requirements = False
for prog in self.needed_progs:
if not do_check_has_prog(prog):
print("ERROR: your system lacks the '%s' program" % prog)
missing_requirements = True
# check optional programs here,
# else they'd get checked by each worker instance
for prog in self.optional_progs:
do_check_has_prog(prog)
return not missing_requirements
def get_toolchain_configs(toolchains_csv, buildrootdir):
"""Fetch and return the possible toolchain configurations
This function returns an array of toolchain configurations. Each
toolchain configuration is itself an array of lines of the defconfig.
"""
with open(toolchains_csv) as r:
# filter empty lines and comments
lines = [t for t in r.readlines() if len(t.strip()) > 0 and t[0] != '#']
toolchains = lines
configs = []
(_, _, _, _, hostarch) = os.uname()
# ~2015 distros report x86 when on a 32bit install
if hostarch == 'i686' or hostarch == 'i386' or hostarch == 'x86':
hostarch = 'x86'
for row in csv.reader(toolchains):
config = {}
configfile = row[0]
config_hostarch = row[1]
keep = False
# Keep all toolchain configs that work regardless of the host
# architecture
if config_hostarch == "any":
keep = True
# Keep all toolchain configs that can work on the current host
# architecture
if hostarch == config_hostarch:
keep = True
# Assume that x86 32 bits toolchains work on x86_64 build
# machines
if hostarch == 'x86_64' and config_hostarch == "x86":
keep = True
if not keep:
continue
if not os.path.isabs(configfile):
configfile = os.path.join(buildrootdir, configfile)
with open(configfile) as r:
config = r.readlines()
configs.append(config)
return configs
@coroutine
def is_toolchain_usable(configfile, config):
"""Check if the toolchain is actually usable."""
with open(configfile) as configf:
configlines = configf.readlines()
# Check that the toolchain configuration is still present
for toolchainline in config:
if toolchainline not in configlines:
print("WARN: toolchain can't be used", file=sys.stderr)
print(" Missing: %s" % toolchainline.strip(), file=sys.stderr)
return False
# The latest Linaro toolchains on x86-64 hosts requires glibc
# 2.14+ on the host.
if platform.machine() == 'x86_64':
if 'BR2_TOOLCHAIN_EXTERNAL_LINARO_ARM=y\n' in configlines or \
'BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64=y\n' in configlines or \
'BR2_TOOLCHAIN_EXTERNAL_LINARO_AARCH64_BE=y\n' in configlines or \
'BR2_TOOLCHAIN_EXTERNAL_LINARO_ARMEB=y\n' in configlines:
proc = yield from asyncio.create_subprocess_exec(
'ldd', '--version', stdout=asyncio.subprocess.PIPE)
ldd_version_output, _ = yield from proc.communicate()
if proc.returncode:
return False
glibc_version = ldd_version_output.decode().splitlines()[0].split()[-1]
if StrictVersion('2.14') > StrictVersion(glibc_version):
print("WARN: ignoring the Linaro ARM toolchains because too old host glibc", file=sys.stderr)
return False
return True
@coroutine
def fixup_config(sysinfo, configfile):
"""Finalize the configuration and reject any problematic combinations
This function returns 'True' when the configuration has been
accepted, and 'False' when the configuration has not been accepted because
it is known to fail (in which case another random configuration will be
generated).
"""
with open(configfile) as configf:
configlines = configf.readlines()
ROOTFS_SIZE = '5G'
BR2_TOOLCHAIN_EXTERNAL_URL = 'BR2_TOOLCHAIN_EXTERNAL_URL="http://autobuild.buildroot.org/toolchains/tarballs/'
has_java = yield from sysinfo.has("java")
if "BR2_NEEDS_HOST_JAVA=y\n" in configlines and not has_java:
return False
# The ctng toolchain is affected by PR58854
if 'BR2_PACKAGE_LTTNG_TOOLS=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'armv5-ctng-linux-gnueabi.tar.xz"\n' in configlines:
return False
# The ctng toolchain tigger an assembler error with guile package when compiled with -Os (same issue as for CS ARM 2014.05-29)
if 'BR2_PACKAGE_GUILE=y\n' in configlines and \
'BR2_OPTIMIZE_S=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'armv5-ctng-linux-gnueabi.tar.xz"\n' in configlines:
return False
# The ctng toolchain is affected by PR58854
if 'BR2_PACKAGE_LTTNG_TOOLS=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'armv6-ctng-linux-uclibcgnueabi.tar.xz"\n' in configlines:
return False
# The ctng toolchain is affected by PR58854
if 'BR2_PACKAGE_LTTNG_TOOLS=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'armv7-ctng-linux-gnueabihf.tar.xz"\n' in configlines:
return False
# The ctng toolchain is affected by PR60155
if 'BR2_PACKAGE_SDL=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'powerpc-ctng-linux-uclibc.tar.xz"\n' in configlines:
return False
# The ctng toolchain is affected by PR60155
if 'BR2_PACKAGE_LIBMPEG2=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'powerpc-ctng-linux-uclibc.tar.xz"\n' in configlines:
return False
# This MIPS toolchain uses eglibc-2.18 which lacks SYS_getdents64
if 'BR2_PACKAGE_STRONGSWAN=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'mips64el-ctng_n64-linux-gnu.tar.xz"\n' in configlines:
return False
# This MIPS toolchain uses eglibc-2.18 which lacks SYS_getdents64
if 'BR2_PACKAGE_PYTHON3=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'mips64el-ctng_n64-linux-gnu.tar.xz"\n' in configlines:
return False
# libffi not available on ARMv7-M, but propagating libffi arch
# dependencies in Buildroot is really too much work, so we handle
# this here.
if 'BR2_ARM_CPU_ARMV7M=y\n' in configlines and \
'BR2_PACKAGE_LIBFFI=y\n' in configlines:
return False
# libopenssl needs atomic, but propagating this dependency in
# Buildroot is really too much work, so we handle this here.
if 'BR2_PACKAGE_LIBOPENSSL=y\n' in configlines and \
'BR2_TOOLCHAIN_HAS_ATOMIC=y\n' not in configlines:
return False
if 'BR2_PACKAGE_SUNXI_BOARDS=y\n' in configlines:
configlines.remove('BR2_PACKAGE_SUNXI_BOARDS_FEX_FILE=""\n')
configlines.append('BR2_PACKAGE_SUNXI_BOARDS_FEX_FILE="a10/hackberry.fex"\n')
# This MIPS uClibc toolchain fails to build the gdb package
if 'BR2_PACKAGE_GDB=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'mipsel-ctng-linux-uclibc.tar.xz"\n' in configlines:
return False
# This MIPS uClibc toolchain fails to build the rt-tests package
if 'BR2_PACKAGE_RT_TESTS=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'mipsel-ctng-linux-uclibc.tar.xz"\n' in configlines:
return False
# This MIPS uClibc toolchain fails to build the civetweb package
if 'BR2_PACKAGE_CIVETWEB=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'mipsel-ctng-linux-uclibc.tar.xz"\n' in configlines:
return False
# This MIPS ctng toolchain fails to build the python3 package
if 'BR2_PACKAGE_PYTHON3=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'mips64el-ctng_n64-linux-gnu.tar.xz"\n' in configlines:
return False
# This MIPS uClibc toolchain fails to build the strace package
if 'BR2_PACKAGE_STRACE=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'mipsel-ctng-linux-uclibc.tar.xz"\n' in configlines:
return False
# This MIPS uClibc toolchain fails to build the cdrkit package
if 'BR2_PACKAGE_CDRKIT=y\n' in configlines and \
'BR2_STATIC_LIBS=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'mipsel-ctng-linux-uclibc.tar.xz"\n' in configlines:
return False
# uClibc vfork static linking issue
if 'BR2_PACKAGE_ALSA_LIB=y\n' in configlines and \
'BR2_STATIC_LIBS=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'i486-ctng-linux-uclibc.tar.xz"\n' in configlines:
return False
# This MIPS uClibc toolchain fails to build the weston package
if 'BR2_PACKAGE_WESTON=y\n' in configlines and \
BR2_TOOLCHAIN_EXTERNAL_URL + 'mipsel-ctng-linux-uclibc.tar.xz"\n' in configlines:
return False
# No C library for internal toolchain
if 'BR2_TOOLCHAIN_BUILDROOT_NONE=y' in configlines:
return False
# Xtensa custom cores require an overlay file with internal
# toolchains
if 'BR2_XTENSA_CUSTOM=y' in configlines and \
'BR2_TOOLCHAIN_BUILDROOT=y' in configlines:
return False
if 'BR2_TOOLCHAIN_BARE_METAL_BUILDROOT=y\n' in configlines:
configlines.remove('BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH=""\n')
configlines.append('BR2_TOOLCHAIN_BARE_METAL_BUILDROOT_ARCH="microblazeel-xilinx-elf"\n')
if 'BR2_PACKAGE_AUFS_UTIL=y\n' in configlines and \
'BR2_PACKAGE_AUFS_UTIL_VERSION=""\n' in configlines:
return False
if 'BR2_PACKAGE_A10DISP=y\n' in configlines:
return False
if 'BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE=y\n' in configlines and \
'BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SOURCE=""\n' in configlines and \
'BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SIZE=""\n' in configlines:
bootenv = os.path.join(args.outputdir, "boot_env.txt")
with open(bootenv, "w+") as bootenvf:
bootenvf.write("prop=value")
configlines.remove('BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SOURCE=""\n')
configlines.append('BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SOURCE="%s"\n' % bootenv)
configlines.remove('BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SIZE=""\n')
configlines.append('BR2_PACKAGE_HOST_UBOOT_TOOLS_ENVIMAGE_SIZE="0x1000"\n')
if 'BR2_PACKAGE_HOST_UBOOT_TOOLS_BOOT_SCRIPT=y\n' in configlines and \
'BR2_PACKAGE_HOST_UBOOT_TOOLS_BOOT_SCRIPT_SOURCE=""\n' in configlines:
bootscr = os.path.join(args.outputdir, "boot_script.txt")
with open(bootscr, "w+") as bootscrf:
bootscrf.write("prop=value")
configlines.remove('BR2_PACKAGE_HOST_UBOOT_TOOLS_BOOT_SCRIPT_SOURCE=""\n')
configlines.append('BR2_PACKAGE_HOST_UBOOT_TOOLS_BOOT_SCRIPT_SOURCE="%s"\n' % bootscr)
if 'BR2_ROOTFS_SKELETON_CUSTOM=y\n' in configlines and \
'BR2_ROOTFS_SKELETON_CUSTOM_PATH=""\n' in configlines:
configlines.remove('BR2_ROOTFS_SKELETON_CUSTOM=y\n')
configlines.remove('BR2_ROOTFS_SKELETON_CUSTOM_PATH=""\n')
if 'BR2_LINUX_KERNEL=y\n' in configlines and \
'BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=""\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_USE_CUSTOM_CONFIG=y\n')
configlines.append('BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y\n')
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE=""\n')
if 'BR2_LINUX_KERNEL=y\n' in configlines and \
'BR2_LINUX_KERNEL_USE_DEFCONFIG=y\n' in configlines and \
'BR2_LINUX_KERNEL_DEFCONFIG=""\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_USE_DEFCONFIG=y\n')
configlines.append('BR2_LINUX_KERNEL_USE_ARCH_DEFAULT_CONFIG=y\n')
configlines.remove('BR2_LINUX_KERNEL_DEFCONFIG=""\n')
if 'BR2_LINUX_KERNEL=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_GIT=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_REPO_URL=""\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_GIT=y\n')
configlines.append('BR2_LINUX_KERNEL_LATEST_VERSION=y\n')
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_REPO_URL=""\n')
if 'BR2_LINUX_KERNEL=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_HG=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_REPO_URL=""\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_HG=y\n')
configlines.append('BR2_LINUX_KERNEL_LATEST_VERSION=y\n')
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_REPO_URL=""\n')
if 'BR2_LINUX_KERNEL=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_SVN=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_REPO_URL=""\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_SVN=y\n')
configlines.append('BR2_LINUX_KERNEL_LATEST_VERSION=y\n')
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_REPO_URL=""\n')
if 'BR2_LINUX_KERNEL=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_TARBALL=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION=""\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_TARBALL=y\n')
configlines.append('BR2_LINUX_KERNEL_LATEST_VERSION=y\n')
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_TARBALL_LOCATION=""\n')
if 'BR2_LINUX_KERNEL=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_VERSION=y\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE=""\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_VERSION=y\n')
configlines.append('BR2_LINUX_KERNEL_LATEST_VERSION=y\n')
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_VERSION_VALUE=""\n')
if 'BR2_LINUX_KERNEL=y\n' in configlines and \
'BR2_LINUX_KERNEL_DTS_SUPPORT=y\n' in configlines and \
'BR2_LINUX_KERNEL_INTREE_DTS_NAME=""\n' in configlines and \
'BR2_LINUX_KERNEL_CUSTOM_DTS_PATH=""\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_DTS_SUPPORT=y\n')
configlines.remove('BR2_LINUX_KERNEL_INTREE_DTS_NAME=""\n')
configlines.remove('BR2_LINUX_KERNEL_CUSTOM_DTS_PATH=""\n')
if 'BR2_LINUX_KERNEL_APPENDED_UIMAGE=y\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_APPENDED_UIMAGE=y\n')
configlines.append('BR2_LINUX_KERNEL_UIMAGE=y\n')
if 'BR2_LINUX_KERNEL_APPENDED_ZIMAGE=y\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_APPENDED_ZIMAGE=y\n')
configlines.append('BR2_LINUX_KERNEL_ZIMAGE=y\n')
if 'BR2_LINUX_KERNEL_CUIMAGE=y\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_CUIMAGE=y\n')
configlines.append('BR2_LINUX_KERNEL_UIMAGE=y\n')
if 'BR2_LINUX_KERNEL_SIMPLEIMAGE=y\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_SIMPLEIMAGE=y\n')
configlines.append('BR2_LINUX_KERNEL_VMLINUX=y\n')
if 'BR2_LINUX_KERNEL_EXT_AUFS=y\n' in configlines and \
'BR2_LINUX_KERNEL_EXT_AUFS_VERSION=""\n' in configlines:
configlines.remove('BR2_LINUX_KERNEL_EXT_AUFS=y\n')
configlines.remove('BR2_LINUX_KERNEL_EXT_AUFS_VERSION=""\n')
if 'BR2_PACKAGE_LINUX_BACKPORTS=y\n' in configlines and \
'BR2_PACKAGE_LINUX_BACKPORTS_USE_CUSTOM_CONFIG=y\n' in configlines and \
'BR2_PACKAGE_LINUX_BACKPORTS_CUSTOM_CONFIG_FILE=""\n' in configlines:
configlines.remove('BR2_PACKAGE_LINUX_BACKPORTS=y\n')
configlines.remove('BR2_PACKAGE_LINUX_BACKPORTS_USE_CUSTOM_CONFIG=y\n')
configlines.remove('BR2_PACKAGE_LINUX_BACKPORTS_CUSTOM_CONFIG_FILE=""\n')
if 'BR2_PACKAGE_LINUX_BACKPORTS=y\n' in configlines and \
'BR2_PACKAGE_LINUX_BACKPORTS_USE_DEFCONFIG=y\n' in configlines and \
'BR2_PACKAGE_LINUX_BACKPORTS_DEFCONFIG=""\n' in configlines:
configlines.remove('BR2_PACKAGE_LINUX_BACKPORTS=y\n')
configlines.remove('BR2_PACKAGE_LINUX_BACKPORTS_USE_DEFCONFIG=y\n')
configlines.remove('BR2_PACKAGE_LINUX_BACKPORTS_DEFCONFIG=""\n')
if 'BR2_KERNEL_HEADERS_VERSION=y\n' in configlines and \
'BR2_DEFAULT_KERNEL_VERSION=""\n' in configlines:
configlines.remove('BR2_KERNEL_HEADERS_VERSION=y\n')
configlines.remove('BR2_DEFAULT_KERNEL_VERSION=""\n')
if 'BR2_KERNEL_HEADERS_CUSTOM_GIT=y\n' in configlines and \
'BR2_KERNEL_HEADERS_CUSTOM_REPO_URL=""\n':
configlines.remove('BR2_KERNEL_HEADERS_CUSTOM_GIT=y\n')
configlines.remove('BR2_KERNEL_HEADERS_CUSTOM_REPO_URL=""\n')
if 'BR2_KERNEL_HEADERS_CUSTOM_TARBALL=y\n' in configlines and \
'BR2_KERNEL_HEADERS_CUSTOM_TARBALL_LOCATION=""\n' in configlines:
configlines.remove('BR2_KERNEL_HEADERS_CUSTOM_TARBALL=y\n')
configlines.remove('BR2_KERNEL_HEADERS_CUSTOM_TARBALL_LOCATION=""\n')
if 'BR2_TARGET_ARM_TRUSTED_FIRMWARE=y\n' in configlines and \
'BR2_TARGET_ARM_TRUSTED_FIRMWARE_PLATFORM=""\n' in configlines:
return False
if 'BR2_TARGET_ARM_TRUSTED_FIRMWARE=y\n' in configlines and \
'BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION=y\n' in configlines and \
'BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE=""\n' in configlines:
configlines.remove('BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION=y\n')
configlines.append('BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION=y\n')
configlines.remove('BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_VERSION_VALUE=""\n')
if 'BR2_TARGET_ARM_TRUSTED_FIRMWARE=y\n' in configlines and \
'BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL=y\n' in configlines and \
'BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL_LOCATION=""\n' in configlines:
configlines.remove('BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL=y\n')
configlines.append('BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION=y\n')
configlines.remove('BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_TARBALL_LOCATION=""\n')
if 'BR2_TARGET_ARM_TRUSTED_FIRMWARE=y\n' in configlines and \
'BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_GIT=y\n' in configlines and \
'BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_URL=""\n' in configlines:
configlines.remove('BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_GIT=y\n')
configlines.append('BR2_TARGET_ARM_TRUSTED_FIRMWARE_LATEST_VERSION=y\n')
configlines.remove('BR2_TARGET_ARM_TRUSTED_FIRMWARE_CUSTOM_REPO_URL=""\n')
if 'BR2_TARGET_AT91BOOTSTRAP3=y\n' in configlines and \
'BR2_TARGET_AT91BOOTSTRAP3_DEFCONFIG=""\n' in configlines:
configlines.remove('BR2_TARGET_AT91BOOTSTRAP3=y\n')
configlines.remove('BR2_TARGET_AT91BOOTSTRAP3_DEFCONFIG=""\n')
if 'BR2_TARGET_BAREBOX=y\n' in configlines and \
'BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG=y\n' in configlines and \
'BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE=""\n' in configlines:
configlines.remove('BR2_TARGET_BAREBOX=y\n')
configlines.remove('BR2_TARGET_BAREBOX_USE_CUSTOM_CONFIG=y\n')
configlines.remove('BR2_TARGET_BAREBOX_CUSTOM_CONFIG_FILE=""\n')
if 'BR2_TARGET_BAREBOX=y\n' in configlines and \
'BR2_TARGET_BAREBOX_USE_DEFCONFIG=y\n' in configlines and \
'BR2_TARGET_BAREBOX_BOARD_DEFCONFIG=""\n' in configlines:
configlines.remove('BR2_TARGET_BAREBOX=y\n')
configlines.remove('BR2_TARGET_BAREBOX_USE_DEFCONFIG=y\n')
configlines.remove('BR2_TARGET_BAREBOX_BOARD_DEFCONFIG=""\n')
if 'BR2_TARGET_BOOT_WRAPPER_AARCH64=y\n' in configlines and \
'BR2_TARGET_BOOT_WRAPPER_AARCH64_DTS=""\n' in configlines:
return False
if 'BR2_TARGET_OPTEE_OS=y\n' in configlines and \
'BR2_TARGET_OPTEE_OS_CUSTOM_TARBALL=y\n' in configlines and \
'BR2_TARGET_OPTEE_OS_CUSTOM_TARBALL_LOCATION=""\n' in configlines:
configlines.remove('BR2_TARGET_OPTEE_OS_CUSTOM_TARBALL=y\n')
configlines.append('BR2_TARGET_OPTEE_OS_LATEST=y\n')
configlines.remove('BR2_TARGET_OPTEE_OS_CUSTOM_TARBALL_LOCATION=""\n')
if 'BR2_TARGET_OPTEE_OS=y\n' in configlines and \
'BR2_TARGET_OPTEE_OS_PLATFORM=""\n' in configlines:
configlines.remove('BR2_TARGET_OPTEE_OS=y\n')
configlines.remove('BR2_TARGET_OPTEE_OS_PLATFORM=""\n')
if 'BR2_TARGET_ROOTFS_CRAMFS=y\n' in configlines:
configlines.remove('BR2_TARGET_ROOTFS_CRAMFS=y\n')
if 'BR2_TARGET_ROOTFS_EXT2=y\n' in configlines and \
'BR2_TARGET_ROOTFS_EXT2_SIZE="60M"\n' in configlines:
configlines.remove('BR2_TARGET_ROOTFS_EXT2_SIZE="60M"\n')
configlines.append('BR2_TARGET_ROOTFS_EXT2_SIZE="%s"\n' % ROOTFS_SIZE)
if 'BR2_TARGET_ROOTFS_F2FS=y\n' in configlines and \
'BR2_TARGET_ROOTFS_F2FS_SIZE="100M"\n' in configlines:
configlines.remove('BR2_TARGET_ROOTFS_F2FS_SIZE="100M"\n')
configlines.append('BR2_TARGET_ROOTFS_F2FS_SIZE="%s"\n' % ROOTFS_SIZE)
if 'BR2_TARGET_ROOTFS_UBIFS=y\n' in configlines and \
'BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT=2048\n' in configlines:
configlines.remove('BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT=2048\n')
configlines.append('BR2_TARGET_ROOTFS_UBIFS_MAXLEBCNT=41610\n')
if 'BR2_TARGET_ROOTFS_UBI=y\n' in configlines and \
'BR2_TARGET_ROOTFS_UBI_USE_CUSTOM_CONFIG=y\n' in configlines and \
'BR2_TARGET_ROOTFS_UBI_CUSTOM_CONFIG_FILE=""\n' in configlines:
configlines.remove('BR2_TARGET_ROOTFS_UBI_USE_CUSTOM_CONFIG=y\n')
configlines.remove('BR2_TARGET_ROOTFS_UBI_CUSTOM_CONFIG_FILE=""\n')
if 'BR2_TARGET_S500_BOOTLOADER=y\n' in configlines and \
'BR2_TARGET_S500_BOOTLOADER_BOARD=""\n' in configlines:
configlines.remove('BR2_TARGET_S500_BOOTLOADER=y\n')
configlines.remove('BR2_TARGET_S500_BOOTLOADER_BOARD=""\n')
if 'BR2_TARGET_TI_K3_R5_LOADER=y\n' in configlines and \
'BR2_TARGET_TI_K3_R5_LOADER_USE_DEFCONFIG=y\n' in configlines and \
'BR2_TARGET_TI_K3_R5_LOADER_BOARD_DEFCONFIG=""\n' in configlines:
return False
if 'BR2_TARGET_UBOOT=y\n' in configlines and \
'BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y\n' in configlines and \
'BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG=y\n' in configlines and \
'BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE=""\n' in configlines:
configlines.remove('BR2_TARGET_UBOOT=y\n')
configlines.remove('BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y\n')
configlines.remove('BR2_TARGET_UBOOT_USE_CUSTOM_CONFIG=y\n')
configlines.remove('BR2_TARGET_UBOOT_CUSTOM_CONFIG_FILE=""\n')
if 'BR2_TARGET_UBOOT=y\n' in configlines and \
'BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y\n' in configlines and \
'BR2_TARGET_UBOOT_USE_DEFCONFIG=y\n' in configlines and \
'BR2_TARGET_UBOOT_BOARD_DEFCONFIG=""\n' in configlines:
configlines.remove('BR2_TARGET_UBOOT=y\n')
configlines.remove('BR2_TARGET_UBOOT_BUILD_SYSTEM_KCONFIG=y\n')
configlines.remove('BR2_TARGET_UBOOT_USE_DEFCONFIG=y\n')
configlines.remove('BR2_TARGET_UBOOT_BOARD_DEFCONFIG=""\n')
if 'BR2_TARGET_UBOOT=y\n' in configlines and \
'BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY=y\n' in configlines and \
'BR2_TARGET_UBOOT_BOARDNAME=""\n' in configlines:
configlines.remove('BR2_TARGET_UBOOT=y\n')
configlines.remove('BR2_TARGET_UBOOT_BUILD_SYSTEM_LEGACY=y\n')
configlines.remove('BR2_TARGET_UBOOT_BOARDNAME=""\n')
if 'BR2_TOOLCHAIN_EXTERNAL=y\n' in configlines and \
'BR2_TOOLCHAIN_EXTERNAL_PREINSTALLED=y\n' in configlines and \
'BR2_TOOLCHAIN_EXTERNAL_PATH=""\n' in configlines:
configlines.remove('BR2_TOOLCHAIN_EXTERNAL=y\n')
configlines.remove('BR2_TOOLCHAIN_EXTERNAL_PREINSTALLED=y\n')
configlines.remove('BR2_TOOLCHAIN_EXTERNAL_PATH=""\n')
if 'BR2_ARCH_HAS_NO_TOOLCHAIN_BUILDROOT=y\n' in configlines:
return False
if 'BR2_TOOLCHAIN_EXTERNAL=y\n' in configlines and \
'BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y\n' in configlines and \
'BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y\n' in configlines and \
'BR2_TOOLCHAIN_EXTERNAL_URL=""\n' in configlines:
configlines.remove('BR2_TOOLCHAIN_EXTERNAL=y\n')
configlines.remove('BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y\n')
configlines.remove('BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y\n')
configlines.remove('BR2_TOOLCHAIN_EXTERNAL_URL=""\n')
if 'BR2_ARCH_HAS_NO_TOOLCHAIN_BUILDROOT=y\n' in configlines:
return False
if 'BR2_TARGET_MXS_BOOTLETS=y\n' in configlines and \
'BR2_TARGET_MXS_BOOTLETS_CUSTOM_BOARD=y\n' in configlines and \
'BR2_TARGET_MXS_BOOTLETS_CUSTOM_BOARD_NAME=""\n' in configlines:
configlines.remove('BR2_TARGET_MXS_BOOTLETS_CUSTOM_BOARD=y\n')
configlines.append('BR2_TARGET_MXS_BOOTLETS_STMP37xx=y\n')
configlines.remove('BR2_TARGET_MXS_BOOTLETS_CUSTOM_BOARD_NAME=""\n')
if 'BR2_TARGET_MXS_BOOTLETS=y\n' in configlines and \
'BR2_TARGET_MXS_BOOTLETS_CUSTOM_GIT=y\n' in configlines and \
'BR2_TARGET_MXS_BOOTLETS_CUSTOM_GIT_URL=""\n' in configlines:
configlines.remove('BR2_TARGET_MXS_BOOTLETS_CUSTOM_GIT=y\n')
configlines.append('BR2_TARGET_MXS_BOOTLETS_FREESCALE=y\n')
configlines.remove('BR2_TARGET_MXS_BOOTLETS_CUSTOM_GIT_URL=""\n')
if 'BR2_TARGET_MXS_BOOTLETS=y\n' in configlines and \
'BR2_TARGET_MXS_BOOTLETS_CUSTOM_TARBALL=y\n' in configlines and \
'BR2_TARGET_MXS_BOOTLETS_CUSTOM_TARBALL_URL=""\n' in configlines:
configlines.remove('BR2_TARGET_MXS_BOOTLETS_CUSTOM_TARBALL=y\n')
configlines.append('BR2_TARGET_MXS_BOOTLETS_FREESCALE=y\n')
configlines.remove('BR2_TARGET_MXS_BOOTLETS_CUSTOM_TARBALL_URL=""\n')
if 'BR2_TARGET_OPENSBI=y\n' in configlines and \
'BR2_TARGET_OPENSBI_CUSTOM_GIT=y\n' in configlines and \
'BR2_TARGET_OPENSBI_CUSTOM_REPO_URL=""\n' in configlines:
configlines.remove('BR2_TARGET_OPENSBI_CUSTOM_GIT=y\n')
configlines.append('BR2_TARGET_OPENSBI_LATEST_VERSION=y\n')
configlines.remove('BR2_TARGET_OPENSBI_CUSTOM_REPO_URL=""\n')
if 'BR2_TARGET_OPENSBI=y\n' in configlines and \
'BR2_TARGET_OPENSBI_CUSTOM_TARBALL=y\n' in configlines and \
'BR2_TARGET_OPENSBI_CUSTOM_TARBALL_LOCATION=""\n' in configlines:
configlines.remove('BR2_TARGET_OPENSBI_CUSTOM_TARBALL=y\n')
configlines.append('BR2_TARGET_OPENSBI_LATEST_VERSION=y\n')
configlines.remove('BR2_TARGET_OPENSBI_CUSTOM_TARBALL_LOCATION=""\n')
if 'BR2_TARGET_OPENSBI=y\n' in configlines and \
'BR2_TARGET_OPENSBI_CUSTOM_VERSION=y\n' in configlines and \
'BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE=""\n' in configlines:
configlines.remove('BR2_TARGET_OPENSBI_CUSTOM_VERSION=y\n')
configlines.append('BR2_TARGET_OPENSBI_LATEST_VERSION=y\n')
configlines.remove('BR2_TARGET_OPENSBI_CUSTOM_VERSION_VALUE=""\n')
if 'BR2_PACKAGE_REFPOLICY=y\n' in configlines and \
'BR2_PACKAGE_REFPOLICY_CUSTOM_GIT=y\n' in configlines and \
'BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_URL=""\n' in configlines:
configlines.remove('BR2_PACKAGE_REFPOLICY_CUSTOM_GIT=y\n')
configlines.append('BR2_PACKAGE_REFPOLICY_UPSTREAM_VERSION=y\n')
configlines.remove('BR2_PACKAGE_REFPOLICY_CUSTOM_REPO_URL=""\n')
if 'BR2_PACKAGE_XENOMAI=y\n' in configlines and \
'BR2_PACKAGE_XENOMAI_CUSTOM_GIT=y\n' in configlines and \
'BR2_PACKAGE_XENOMAI_REPOSITORY=""\n' in configlines:
configlines.remove('BR2_PACKAGE_XENOMAI_CUSTOM_GIT=y\n')
configlines.append('BR2_PACKAGE_XENOMAI_LATEST_VERSION=y\n')
configlines.remove('BR2_PACKAGE_XENOMAI_REPOSITORY=""\n')
if 'BR2_PACKAGE_XENOMAI=y\n' in configlines and \
'BR2_PACKAGE_XENOMAI_CUSTOM_TARBALL=y\n' in configlines and \
'BR2_PACKAGE_XENOMAI_CUSTOM_TARBALL_URL=""\n' in configlines:
configlines.remove('BR2_PACKAGE_XENOMAI_CUSTOM_TARBALL=y\n')
configlines.append('BR2_PACKAGE_XENOMAI_LATEST_VERSION=y\n')
configlines.remove('BR2_PACKAGE_XENOMAI_CUSTOM_TARBALL_URL=""\n')
if 'BR2_PACKAGE_XENOMAI=y\n' in configlines and \
'BR2_PACKAGE_XENOMAI_CUSTOM_VERSION=y\n' in configlines and \
'BR2_PACKAGE_XENOMAI_CUSTOM_VERSION_VALUE=""\n' in configlines:
configlines.remove('BR2_PACKAGE_XENOMAI_CUSTOM_VERSION=y\n')
configlines.append('BR2_PACKAGE_XENOMAI_LATEST_VERSION=y\n')
configlines.remove('BR2_PACKAGE_XENOMAI_CUSTOM_VERSION_VALUE=""\n')
if 'BR2_PACKAGE_XVISOR=y\n' in configlines and \
'BR2_PACKAGE_XVISOR_USE_CUSTOM_CONFIG=y\n' in configlines and \
'BR2_PACKAGE_XVISOR_CUSTOM_CONFIG_FILE=""\n' in configlines:
configlines.remove('BR2_PACKAGE_XVISOR_USE_CUSTOM_CONFIG=y\n')
configlines.append('BR2_PACKAGE_XVISOR_USE_DEFCONFIG=y\n')
configlines.remove('BR2_PACKAGE_XVISOR_CUSTOM_CONFIG_FILE=""\n')
# Don't build igh-ethercat driver as they are highly
# kernel-version specific
for opt in ['8139TOO', 'E100', 'E1000', 'E1000E', 'R8169']:
optstr = 'BR2_PACKAGE_IGH_ETHERCAT_%s=y\n' % opt
if optstr in configlines:
configlines.remove(optstr)
with open(configfile, "w+") as configf:
configf.writelines(configlines)
return True
@coroutine
def gen_config(args):
"""Generate a new random configuration
This function generates the configuration, by choosing a random
toolchain configuration and then generating a random selection of
packages.
"""
sysinfo = SystemInfo()
if args.toolchains_csv:
# Select a random toolchain configuration
configs = get_toolchain_configs(args.toolchains_csv, args.buildrootdir)
i = randint(0, len(configs) - 1)
toolchainconfig = configs[i]
else:
toolchainconfig = []
configlines = list(toolchainconfig)
# Combine with the minimal configuration
minimalconfigfile = os.path.join(args.buildrootdir,
'support/config-fragments/minimal.config')
with open(minimalconfigfile) as minimalf:
configlines += minimalf.readlines()
# Allow hosts with old certificates to download over https
configlines.append("BR2_WGET=\"wget --passive-ftp -nd -t 3 --no-check-certificate\"\n")
# Per-package folder
if randint(0, 15) == 0:
configlines.append("BR2_PER_PACKAGE_DIRECTORIES=y\n")
# Amend the configuration with a few things.
if randint(0, 20) == 0:
configlines.append("BR2_ENABLE_DEBUG=y\n")
if randint(0, 20) == 0:
configlines.append("BR2_ENABLE_RUNTIME_DEBUG=y\n")
if randint(0, 1) == 0:
configlines.append("BR2_INIT_BUSYBOX=y\n")
elif randint(0, 15) == 0:
configlines.append("BR2_INIT_SYSTEMD=y\n")
elif randint(0, 10) == 0:
configlines.append("BR2_ROOTFS_DEVICE_CREATION_DYNAMIC_EUDEV=y\n")
if randint(0, 20) == 0:
configlines.append("BR2_STATIC_LIBS=y\n")
if randint(0, 20) == 0:
configlines.append("BR2_PACKAGE_PYTHON3_PY_ONLY=y\n")
if randint(0, 5) == 0:
configlines.append("BR2_OPTIMIZE_2=y\n")
if randint(0, 4) == 0:
configlines.append("BR2_SYSTEM_ENABLE_NLS=y\n")
if randint(0, 4) == 0:
configlines.append("BR2_FORTIFY_SOURCE_2=y\n")
# Randomly enable BR2_REPRODUCIBLE 10% of times
# also enable tar filesystem images for testing
has_diffoscope = yield from sysinfo.has("diffoscope")
if has_diffoscope and randint(0, 10) == 0:
configlines.append("BR2_REPRODUCIBLE=y\n")
configlines.append("BR2_TARGET_ROOTFS_TAR=y\n")
# Write out the configuration file
if not os.path.exists(args.outputdir):
os.makedirs(args.outputdir)
if args.outputdir == os.path.abspath(os.path.join(args.buildrootdir, "output")):
configfile = os.path.join(args.buildrootdir, ".config")
else:
configfile = os.path.join(args.outputdir, ".config")
with open(configfile, "w+") as configf:
configf.writelines(configlines)
proc = yield from asyncio.create_subprocess_exec(
"make", "O=%s" % args.outputdir, "-C", args.buildrootdir, "olddefconfig")
ret = yield from proc.wait()
if ret:
return ret
toolchain_usable = yield from is_toolchain_usable(configfile, toolchainconfig)
if not toolchain_usable:
return 2
# Now, generate the random selection of packages, and fixup
# things if needed.
# Safe-guard, in case we can not quickly come to a valid
# configuration: allow at most 100 (arbitrary) iterations.
bounded_loop = 100
while True:
if bounded_loop == 0:
print("ERROR: cannot generate random configuration after 100 iterations",
file=sys.stderr)
return 1
bounded_loop -= 1
make_rand = [
"make", "O=%s" % args.outputdir, "-C", args.buildrootdir,
"KCONFIG_SEED=0x%s" % hexlify(os.urandom(4)).decode("ascii").upper(),
"KCONFIG_PROBABILITY=%d" % randint(1, 20),
"randpackageconfig" if args.toolchains_csv else "randconfig"
]
proc = yield from asyncio.create_subprocess_exec(*make_rand)
ret = yield from proc.wait()
if ret:
return ret
ret = yield from fixup_config(sysinfo, configfile)
if ret:
break
proc = yield from asyncio.create_subprocess_exec(
"make", "O=%s" % args.outputdir, "-C", args.buildrootdir, "olddefconfig")
ret = yield from proc.wait()
if ret:
return ret
proc = yield from asyncio.create_subprocess_exec(
"make", "O=%s" % args.outputdir, "-C", args.buildrootdir, "savedefconfig")
ret = yield from proc.wait()
if ret:
return ret
proc = yield from asyncio.create_subprocess_exec(
"make", "O=%s" % args.outputdir, "-C", args.buildrootdir, "dependencies")
ret = yield from proc.wait()
return ret
if __name__ == '__main__':
import argparse
parser = argparse.ArgumentParser(description="Generate a random configuration")
parser.add_argument("--outputdir", "-o",
help="Output directory (relative to current directory)",
type=str, default='output')
parser.add_argument("--buildrootdir", "-b",
help="Buildroot directory (relative to current directory)",
type=str, default='.')
toolchains_csv = parser.add_mutually_exclusive_group(required=False)
toolchains_csv.add_argument("--toolchains-csv",
dest="toolchains_csv",
help="Path of the toolchain configuration file",
type=str)
toolchains_csv.add_argument("--no-toolchains-csv",
dest="toolchains_csv",
help="Generate random toolchain configuration",
action='store_false')
parser.set_defaults(toolchains_csv="support/config-fragments/autobuild/toolchain-configs.csv")
args = parser.parse_args()
# We need the absolute path to use with O=, because the relative
# path to the output directory here is not relative to the
# Buildroot sources, but to the current directory.
args.outputdir = os.path.abspath(args.outputdir)
try:
if sys.version_info < (3, 7):
loop = asyncio.get_event_loop()
ret = loop.run_until_complete(gen_config(args))
else:
ret = asyncio.run(gen_config(args))
except Exception:
traceback.print_exc()
parser.exit(1)
parser.exit(ret)