-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbuildmistify
executable file
·871 lines (814 loc) · 25.1 KB
/
buildmistify
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
#!/bin/bash
#+
# Use this script to initialize a Buildroot based build environment for Mistify.
#
# The intent is to use a copy of the Buildroot build envirnment for Buildroot
# unmodified and using an external project directory.
#-
source scripts/mistify-functions.sh
timestampfile=/tmp/buildmistify-ts
usage () {
cat << EOF
Usage: ./buildmistify [options] [target]
This script must be run from within the project directory. It uses the
Buildroot build environment to build Mistify-OS using Buildroot.
If the Buildroot build environment is not present then it is first cloned from
the Mistify repository.
Buildroot is configured to use an external toolchain. If the external
toolchain is not present then it is installed before starting Buildroot.
Any of the options can be reset to their default value by passing "default"
as the parameter.
Options:
==== external toolchain ====
--tcuri <uri>
The repository from which to clone Buildroot. This is saved in the file
$statedir/tcuri.
[tcuri=`cat $statedir/tcuri`]
--toolchaindir <dir>
Where the toolchain is to be installed and defaults to:
<builddir>/toolchain. Using this option simplifies using a single
toolchain install for multiple projects OR using different toolchain
versions for different projects. This is saved in the file
$statedir/toolchaindir.
[toolchaindir=`cat $statedir/toolchaindir`]
--toolchainprefix <prefix>
This is the toolchain prefix to use to identify the intended target
architecture of the toolchain. This is saved in the file
$statedir/toolchainprefix
[toolchainprefix=`cat $statedir/toolchainprefix`]
--toolchainversion <version>
Checkout the toolchain using a specified version. This can be a branch
or tag name or even a commit ID. This is used to build the path to where
the toolchain is cloned. This is saved in the file
$statedir/toolchainversion.
[toolchainversion=`cat $statedir/toolchainversion`]
--toolchaininstallprefix <dir>
Where the toolchain should be installed. This is saved in the file
$statedir/toolchaininstallprefix
[toolchaininstallprefix=`cat $statedir/toolchaininstallprefix`]
--tcartifacturi <uri>
The server on which pre-built toolchains are stored. This is used when
a pre-built toolchain is either copied to the server or installed from
the server. This is saved in the file
$statedir/tcartifacturi.
[tcartifacturi=`cat $statedir/tcartifacturi`]
--toolchainreset
Reset the toolchain related options to their defaults and force a
rebuild of the toolchain. NOTE: Resetting the toolchain will force a
complete build.
[toolchainreset=$toolchainreset]
==== go ====
--godir <dir>
Where the GO source code is cloned to before building. This is saved in
the file $statedir/godir.
[godir=`cat $statedir/godir`]
--gouri <uri>
The repository from which to clone the GO source code.
This is saved in the file $statedir/gouri.
[gouri=`cat $statedir/gouri`]
--gotag <tag>
The tag to use when fetching the GO source code from the repository.
This is saved in the file $statedir/gotag.
[gotag=`cat $statedir/gotag`]
--gobootstraptag <tag>
The tag to use when fetching the GO source code from the repository for.
the version of go to use to bootstrap go 1.5 and latere.
This is saved in the file $statedir/gobootstraptag.
[gobootstraptag=`cat $statedir/gobootstraptag`]
--goreset
Reset the GO related options to their default values and force a fresh
build of the GO tools.
[goreset=$goreset]
==== buildroot ====
--buildrooturi <uri>
The repository from which to clone Buildroot. This is saved in the file
$statedir/buildrooturi.
[buildrooturi=`cat $statedir/buildrooturi`]
--buildrootdir <dir>
Where Buildroot is to be installed. Using this option simplifies using a
single Buildroot install for multiple projects OR using different
versions of Buildroot for different projects. This is saved in the file
$statedir/buildrootdir.
[buildrootdir=`cat $statedir/buildrootdir`]
--buildrootversion <version>
Checkout Buildroot using a specified version. This can be a branch
or tag name or even a commit ID. The version information is saved in the
file $statedir/buildrootversion.
[buildrootversion=`cat $statedir/buildrootversion`]
--buildrootreset
Reset the Buildroot options to their defaults and force a fresh copy
of buildroot.
[buildrootreset=$buildrootreset]
==== build ====
-b|--builddir <dir>
Where to put the build targets and output. This location is saved in the
file $statedir/builddir.
[builddir=`cat $statedir/builddir`]
-d|--downloaddir <dir>
Where the downloaded source files are stored. Use this directory instead
of downloading a new set. This helps avoid downloading new files when
changing one of the other directories.
WARNING: This overrides the Buildroot configuration option.
[downloaddir=`cat $statedir/downloaddir`]
--resetmasters
Some packages may be configured to always pull from the master branch.
This can result in stale copies in the download cache being used for the
build. This option causes these files to be removed before starting the
build.
==== configuration ====
--variant <variant>
Use a configuration variant. The variant is always based upon the
base configuration files indicated by the --config, --kconfig,
--bbconfig and --tcconfig options. Because variants can also have
differing requirements for the toolchain the variant name is also used
to name the toolchain, go directory and the buildroot directory.
The active variant name is saved in the file
$statedir/variant.
[variant=`cat $statedir/variant`]
-c|--mconfig <configfile>
Use this config file. The config file is copied to the build directory
before running the buildroot make. The file name is saved in the file
$statedir/mconfig.
[mconfig=`cat $statedir/mconfig`]
-k|--kconfig <configfile>
Use this kernel config file. The config file is copied to the build
directory before running the buildroot make. The file name is saved in
the file
$statedir/kconfig.
[kconfig=`cat $statedir/kconfig`]
--bbconfig <configfile>
Use this Busybox config file. The config file is copied to the build
directory before running the buildroot make. The file name is saved in
the file $statedir/bbconfig.
[bbconfig=`cat $statedir/bbconfig 2>/dev/null || echo \\`]
--tcconfig <configfile>
Use this toolchain config file. The config file is copied to the
toolchain build directory before running the toolchain build. The file
name is saved in the file $statedir/tcconfig.
[tcconfig=`cat $statedir/tcconfig 2>/dev/null || echo \\`]
==== other ====
--resetdefaults
Reset all options back to their default values.
[resetdefaults=$resetdefaults]
--noupdate
Do not attempt to update buildroot or the toolchain from the repo.
[noupdate=$noupdate]
--verbose
Enble verbose output from this script.
[verbose=$verbose]
-l|--logfile
Use this log file name instead of the generated log file name.
[logfile=$logfile]
--viewlog
If the Buildroot make returns an error then view the log file.
[viewlog=$viewlog]
--dryrun
Just showing what will happen with this script without running the
Buildroot make.
[dryrun=$dryrun]
--useartifacts
Downloads/Extracts dependent artifacts instead of building from source.
Currently supports toolchain ONLY.
[useartifacts=$useartifacts]
--showoptions
Display the current options settings.
[showoptions=$showoptions]
-h|--help
Display this usage.
==== special targets ====
toolchain-menuconfig
Run the toolchain configuration utility.
menuconfig
Run the Buildroot configuration utility.
busybox-menuconfig
Run the Busybox configuration utility.
linux-menuconfig
Run the Linux kernel configuration utility.
toolchain-build
Run the toolchain build
NOTE: This script maintains state in $statedir.
The targets toolchain-menuconfig, menuconfig, busybox-menuconfig and
linux-menuconfig exit immediately after exiting the corresponding
configuration utilities.
Custom environment variables:
MISTIFY_DIR Points to the directory in which buildmistify resides. This
can then be used in the buildroot config to specify locations of files such
as the config file.
EOF
}
display-options() {
echo "$(usage)" | grep =
}
#+
# TODO: Add some quick checks to verify required tools are installed.
#-
#+
# Handle the command line options.
#-
a=`getopt -l "\
tcuri:,\
toolchaindir:,\
toolchainprefix:,\
toolchaininstallprefix:,\
toolchainversion:,\
tcartifacturi:,\
toolchainreset,\
gouri:,\
godir:,\
gotag:,\
gobootstraptag:,\
goreset,\
buildrooturi:,\
buildrootdir:,\
buildrootversion:,\
buildrootreset,\
builddir:,\
variant:,\
mconfig:,\
kconfig:,\
bbconfig:,\
tcconfig:,\
dryrun,\
useartifacts,\
downloaddir:,\
resetmasters,\
resetdefaults,\
noupdate,\
verbose,\
logfile:,\
viewlog,\
showoptions,\
help" \
-o "c:k:b:t:l:d:h" -- "$@"`
if [ $? -gt 0 ]; then
usage
exit 1
fi
eval set -- $a
while [ $# -ge 1 ]; do
case "$1" in
--)
shift
break
;;
--tcuri)
tcuri=$2
shift
;;
--toolchaindir)
toolchaindir=`readlink -f $2`
shift
;;
--toolchainprefix)
toolchainprefix=$2
shift
;;
--toolchaininstallprefix)
toolchaininstallprefix=$2
shift
;;
--toolchainversion)
toolchainversion=$2
shift
;;
--tcartifacturi)
tcartifacturi=$2
shift
;;
--toolchainreset)
toolchainreset=y
;;
--gouri)
gouri=$2
shift
;;
--godir)
godir=`readlink -m $2`
shift
;;
--gotag)
gotag=$2
shift
;;
--gobootstraptag)
gobootstraptag=$2
shift
;;
--goreset)
goreset=y
;;
--buildrooturi)
buildrooturi=$2
shift
;;
--buildrootdir)
buildrootdir=`readlink -m $2`
shift
;;
--buildrootversion)
buildrootversion=$2
shift
;;
--buildrootreset)
buildrootreset=y
;;
-b|--builddir)
builddir=`readlink -m $2`
shift
;;
-d|--downloaddir)
downloaddir=`readlink -m $2`
shift
;;
--resetmasters)
resetmasters=y
;;
--variant)
variant=$2
# This variable helps handle the case where the variant is being
# reset to the base ('').
variantset=y
shift
;;
-c|--mconfig)
mconfig=$2
shift
;;
-k|--kconfig)
kconfig=$2
shift
;;
--bbconfig)
bbconfig=$2
shift
;;
--tcconfig)
tcconfig=$2
shift
;;
--resetdefaults)
resetdefaults=y
;;
--noupdate)
noupdate=y
;;
--verbose)
verbose=y
;;
-l|--logfile)
logfilename=$2
shift
;;
--viewlog)
viewlog=y
;;
--dryrun)
dryrun=y
;;
--useartifacts)
useartifacts=y
;;
--showoptions)
showoptions=y
;;
-h|--help)
showusage=y
;;
# using getopt should avoid needing this catchall but just in case...
*)
error "Invalid option: $1"
usage
exit 1
;;
esac
shift
done
defaults=(
[email protected]:mistifyio/crosstool-ng.git
toolchaindir=$PWD/toolchain
toolchainprefix=x86_64-unknown-linux-gnu
toolchaininstallprefix=target-toolchain
toolchainversion=glibc-multilib-sdk
tcartifacturi=https://s3.amazonaws.com/omniti-mystify-artifacts/toolchain-artifacts
[email protected]:golang/go.git
godir=$PWD/go
gotag=go1.6
gobootstraptag=go1.4.2
variant=base
[email protected]:mistifyio/buildroot.git
buildrootdir=$PWD/build/buildroot
buildrootversion=master
builddir=$PWD/build/mistify
downloaddir=$PWD/downloads
mconfig=$PWD/configs/mistify_defconfig
kconfig=$PWD/configs/mistify-kernel.config
bbconfig=$PWD/configs/mistify-busybox.config
tcconfig=$PWD/configs/mistify-tc-multilib.config
)
#+
# These resets are done here so that command line arguments can be used to set
# them at the same time.
#-
if [ -n "$toolchainreset" ]; then
for d in \
tcconfig tcuri toolchaindir \
toolchainprefix toolchainversion \
tcartifacturi
do
verbose Resetting default: $d
reset_build_default $d
done
#+
# Because buildroot and go can be affected when using a different toolchain
# they need to be reset as well.
#-
buildrootreset=y
goreset=y
fi
if [ -n "$buildrootreset" ]; then
for d in \
buildrooturi buildrootdir buildrootversion
do
verbose Resetting default: $d
reset_build_default $d
done
fi
if [ -n "$goreset" ]; then
for d in \
gouri godir gotag gobootstraptag
do
verbose Resetting default: $d
reset_build_default $d
done
fi
for v in "${defaults[@]}"
do
if [ ! -z "$resetdefaults" ]; then
clear_build_variable $v
fi
init_build_variable $v
done
if [ -n "$showoptions" ]; then
display-options
exit 0
fi
if [ -n "$showusage" ]; then
usage
exit 0
fi
variantbuilddir=$builddir/$variant
message "The variant build directory is: $variantbuilddir"
# Save the variant builddir so testmistify can know which build to test.
set_build_default variantbuilddir $variantbuilddir
source scripts/install-toolchain.sh
source scripts/install-go.sh
source scripts/variants.sh
#+
# Be sure the toolchain is installed.
#-
install-toolchain
# install-toolchain sets forcebuild if the toolchain was either installed or
# built.
if [ -n "$forcebuild" ]; then
goreset=y
rm -rf $buildrootvariantdir
rm -rf $variantbuilddir
fi
install-go
if [[ $# -ge 1 ]]; then
target="$@"
message "Building target: $target"
# Any other arguments are passed to buildroot.
else
t=""
fi
message "Using Buildroot located at: $buildrootvariantdir"
#+
# Determine the configuration variant to use.
# If variant is null but was set on the command line then reset to the base.
#-
if [ -z "$variant" ]; then
if [ "$variantset" == "y" ]; then
reset_build_default variant
fi
variantdefault=$(get_build_default variant base)
variant=$variantdefault
else
set_build_default variant $variant
fi
message "Using $variant configuration."
export MISTIFY_VARIANT="$variant"
mkdir -p $builddir
message "Build output directory is: $builddir"
logdir=$variantbuilddir/logs
mkdir -p $logdir
message "The Buildroot repository is: $buildrooturi"
message "The Buildroot version is: $buildrootversion"
if [ -z "$logfilename" ]; then
logfilename=buildroot-`date +%y%m%d%H%M%S`.log
fi
if [ "$target" == "toolchain-build" ]; then
install-toolchain
exit $?
fi
buildrootvariantdir=$buildrootdir/$variant
verbose The buildroot variant directory is: $buildrootvariantdir
if [ -n "$buildrootreset" ]; then
warning Removing buildroot directory.
rm -rf $buildrootvariantdir
fi
if [ ! -f $buildrootvariantdir/README ]; then
message "Cloning Buildroot from the Buildroot project repository."
git clone $buildrooturi $buildrootvariantdir
#+
# TODO: It is possible that the previous clone failed. Might want to use
# git again to update just in case.
#-
if [ $? -gt 0 ]; then
die "Cloning Buildroot encountered an error."
fi
fi
cd $buildrootvariantdir
if [ -n "$noupdate" ]; then
warning Not fetching branches for buildroot.
else
message "Fetching Buildroot update from the remote repository."
run git fetch
fi
run git checkout $buildrootversion
if [ $? -ne 0 ]; then
die "Attempted to checkout Buildroot using an invalid ID: $buildrootversion"
fi
#+
# If on a branch then pull the latest changes.
#-
run_ignore git symbolic-ref --short HEAD
if [ $? -eq 0 ]; then
if [ -n "$noupdate" ]; then
warning Not updating buildroot.
else
message Updating from branch: $buildrootversion
run git pull
fi
else
message Buildroot version $buildrootversion is not a branch. Not updating.
fi
message "Buildroot synced to: $buildrootversion"
set_build_default buildrootversion $buildrootversion
cd $projectdir
buildrootkernelheaders=`grep BR2_LINUX_KERNEL_VERSION $mconfig | cut -d \" -f 2`
message "The Buildroot config file is: $mconfig"
message "The kernel headers version is: $buildrootkernelheaders"
brc=$variantbuilddir/.config
if [ -f $mconfig ]; then
verbose "Base config: $mconfig"
verbose "Target file: $brc"
verbose "Variant: $variant"
use_variant $mconfig $brc $variant
if [ $? -gt 0 ]; then
die "Could not copy the Buildroot config file."
fi
message "Config file $mconfig copied to $brc"
set_build_default mconfig $mconfig
else
case "$target" in
"menuconfig" | "nconfig")
;;
*)
die "The config file doesn't exist. Run $0 menuconfig."
;;
esac
fi
#+
# Setup the correct kernel config file.
# TODO: Add a check to verify the kernel config file exists.
#
message "The Buildroot kernel config file is: $kconfig"
brkc=$variantbuilddir/build/linux-`grep BR2_LINUX_KERNEL_VERSION $brc | cut -d "\"" -f 2`/.config
verbose "Kernel configuration file: $brkc"
if [ -f $brkc ]; then
if [ -f $kconfig ]; then
use_variant $kconfig $brkc $variant
if [ $? -gt 0 ]; then
die "Could not copy the kernel config file."
fi
message "Config file $kconfig copied to $brkc"
set_build_default kconfig $kconfig
else
if [[ "$target" != "linux-menuconfig" ]]; then
die "The kernel config file doesn't exist. Run ./buildmistify linux-menuconfig."
fi
fi
fi
#+
# Setup the correct busybox config file.
#
message "The Buildroot BusyBox config file is: $bbconfig"
bbc=`ls -d $variantbuilddir/build/busybox-*`/.config
if [ -f $bbc ]; then
if [ -f $bbconfig ]; then
use_variant $bbconfig $bbc $variant
if [ $? -gt 0 ]; then
warning "Busybox hasn't been built yet."
fi
message "Config file $bbconfig copied to $bbc"
set_build_default bbconfig $bbconfig
else
if [[ "$target" != "busybox-menuconfig" ]]; then
error "The BusyBox config file doesn't exist."
die "Run ./buildmistify busybox-menuconfig."
fi
fi
fi
set_build_default downloaddir $downloaddir
message "The Buildroot download directory is: $downloaddir"
#+
# Some packages may be configured to always pull from the head of a master
# branch. This results in cached download files matching the pattern *master*.
# Because of this stale verisions could actually be used because buildroot
# uses the version in the name to indicate whether the cached file exists
# or not. In the case of using "master" the version doesn't change so Buildroot
# will be mislead into thinking the cached file is current when in fact it's not.
# So, remove such files to force a fresh pull.
#-
if [ -n "$resetmasters" ]; then
if [ -d $downloaddir ]; then
p=$downloaddir/*-master.tar*
if ls $p 1> /dev/null 2>&1; then
for f in `ls $p`; do
warning "Removing cached master branch file: $f"
rm $f
done
fi
fi
fi
message "Project dir: $projectdir"
#+
# Now run the build.
#-
export MISTIFY_DIR=$projectdir
makecommand="\
make O=$variantbuilddir \
TOOLCHAIN_PATH=`toolchain-dir` TOOLCHAIN_PREFIX=$toolchainprefix \
BR2_CCACHE_DIR=$builddir/.buildroot_ccache \
BR2_DL_DIR=$downloaddir BR2_EXTERNAL=$projectdir \
BR2_DEFAULT_KERNEL_HEADERS=$buildrootkernelheaders \
GOROOT=$GOROOT -C $buildrootvariantdir \
$target"
#+
# Don't run the build if changing configurations.
#-
case "$target" in
"menuconfig" | "nconfig")
touch $timestampfile
verbose "Current directory is: $PWD"
$makecommand
if [[ ! -f $mconfig || $brc -nt $timestampfile ]]; then
#+
# NOTE: The buildroot config option BR2_DEFCONFIG
# needs to point to the config file so that buildroot will copy the correct
# file on the first build.
#-
update_variant $brc $mconfig $variant
if [ $? -gt 0 ]; then
error "Failed to save $mconfig"
exit 1
fi
tip "Use $0 to build Mistify using the new configuration."
if [ -z "$variant" ]; then
message "New config file at $brc saved to $mconfig"
else
message "The configuration variant saved to $variant"
fi
fi
rm -f $timestampfile
exit
;;
"xconfig" | "gconfig")
error "Configuration tool $target is not supported."
exit 1
;;
"linux-menuconfig")
#+
# NOTE: The buildroot config option BR2_LINUX_KERNEL_CUSTOM_CONFIG_FILE
# needs to point to the config file so that buildroot will copy the correct
# file on the first build.
#-
touch $timestampfile
$makecommand
if [[ ! -f $kconfig || $brkc -nt $timestampfile ]]; then
update_variant $brkc $kconfig $variant
if [ $? -gt 0 ]; then
error "Failed to save $kconfig"
exit 1
fi
tip "Use $0 to build Mistify using the new configuration."
if [ -z "$variant" ]; then
message "New kernel config file at $brkc saved to $kconfig"
else
message "The kernel configuration variant saved to $variant"
fi
fi
rm -f $timestampfile
exit
;;
"busybox-menuconfig")
#+
# NOTE: The buildroot config option BR2_PACKAGE_BUSYBOX_CONFIG
# needs to point to the config file so that buildroot will copy the correct
# file on the first build.
#-
touch $timestampfile
$makecommand
# NOTE: May want to use grep instead of a timestamp compare.
if [[ ! -f $bbconfig || $bbc -nt $timestampfile ]]; then
update_variant $bbc $bbconfig $variant
if [ $? -gt 0 ]; then
error "Failed to save $bbconfig"
exit 1
fi
tip "Use $0 to build Mistify using the new configuration."
if [ -z "$variant" ]; then
message "New BusyBox config file $bbc saved to $bbconfig"
else
message "The BusyBox configuration variant saved to $variant"
fi
fi
rm -f $timestampfile
exit
;;
*)
;;
esac
#+
# Setup the build log file.
#-
logfile=$logdir/$logfilename
message "Logging the build output to: $logfile"
#+
# Run buildroot.
#-
if [ -n "$dryrun" ]; then
message "Just a dry run -- not running make."
verbose $makecommand
exit 0
else
#+
# Run the buildroot make.
#-
cd $buildrootvariantdir
ln -sf $logfilename $logdir/buildroot.log
_envvars=`env | sort`
cat << EOF | tee $logfile
++++
$id: Running make command:
$makecommand
$id: Environment:
$_envvars
$id: Buildroot dir is: $buildrootvariantdir
----
EOF
time $makecommand 2>&1 | tee -a $logfile
rc=${PIPESTATUS[0]}
message "The Mistify-OS build is complete."
message "The log file is: $logfile"
if [ $rc -gt 0 ]; then
error "Make complained about a build problem (see $logfile)."
if [ -n "$viewlog" ]; then
less $logfile
fi
exit 1
fi
fi
#+
# Prepare the "official" images and generate corresponding sha1s.
# WARNING: This requires the corresponding images be enabled in the Buildroot
# configuration file ($mconfig).
#-
imagedir=$variantbuilddir/images
cd $imagedir
if [ -f rootfs.cpio.bz2 ]; then
ln -sf rootfs.cpio.bz2 initrd.mistify
sha1sum initrd.mistify >initrd.mistify.sha1
else
warning "The initrd doesn't exist."
fi
if [ -f bzImage ]; then
ln -sf bzImage bzImage.mistify
sha1sum bzImage.mistify >bzImage.mistify.sha1
else
warning "The kernel image doesn't exist."
fi
if [ -f rootfs.iso9660 ]; then
ln -sf rootfs.iso9660 mistify.iso
sha1sum mistify.iso >mistify.iso.sha1
else
warning "The ISO image doesn't exist."
fi
cd -
message "Images are in $imagedir and can be uploaded to the server."
message "bzImage.buildroot: The kernel image."
message "initrd.buildroot: The RAM disk."
if [ -e $imagedir ]; then
ls -l $imagedir
fi