5 # This script builds LinuxBIOS images for all available targets.
7 # (C) 2004 by Stefan Reinauer <stepan@openbios.org>
8 # (C) 2006 by coresystems GmbH <info@coresystems.de>
10 # This file is subject to the terms and conditions of the GNU General
11 # Public License. See the file COPYING in the main directory of this
12 # archive for more details.
15 #set -x # Turn echo on....
17 ABUILD_DATE="October 24, 2006"
20 # Where shall we place all the build trees?
21 TARGET=$( pwd )/linuxbios-builds
22 XMLFILE=$( pwd )/abuild.xml
24 # path to payload. Should be more generic
27 # Lines of error context to be printed in FAILURE case
30 TESTSUBMISSION="http://qa.linuxbios.org/deployment/send.php"
32 # One might want to adjust these in case of cross compiling
36 # this can be changed to xml by -x
39 ARCH=`uname -m | sed -e s/i.86/i386/ -e s/sun4u/sparc64/ \
40 -e s/arm.*/arm/ -e s/sa110/arm/ -e s/x86_64/amd64/ \
41 -e "s/Power Macintosh/ppc/"`
47 printf "\n$0: execution interrupted manually.\n"
48 if [ "$mode" == "xml" ]; then
49 printf "$0: deleting incomplete xml output file.\n"
56 test "$verbose" == "true" && printf "$*\n"
61 test "$mode" == "xml" && printf "$*\n" >> $XMLFILE
66 test "$mode" == "xml" && {
77 # make this a function so we can easily select
78 # without breaking readability
79 ls -1 "$LBROOT/src/mainboard" | grep -v CVS
84 # make this a function so we can easily select
85 # without breaking readability
89 ls -1 $LBROOT/src/mainboard/$VENDOR | grep -v CVS
96 cat $LBROOT/src/mainboard/$VENDOR/$MAINBOARD/Config.lb | \
97 grep ^arch | cut -f 2 -d\
100 function create_config
104 TARCH=$( architecture $VENDOR $MAINBOARD )
105 TARGCONFIG=$LBROOT/targets/$VENDOR/$MAINBOARD/Config-abuild.lb
107 # get a working payload for the board if we have one.
108 # the --payload option expects a directory containing
109 # an executable shell script payload.sh
110 # Usage: payload.sh [VENDOR] [DEVICE]
111 # the script returns an absolute path to the payload binary.
113 if [ -x $payloads/payload.sh ]; then
114 PAYLOAD=`$payloads/payload.sh $VENDOR $MAINBOARD`
115 printf "Using payload $PAYLOAD\n"
120 if [ -f $TARGCONFIG ]; then
121 cp $TARGCONFIG $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
122 printf "Using existing test target $TARGCONFIG"
123 xml " <config>$TARGCONFIG</config>"
126 printf " Creating config file..."
127 xml " <config>autogenerated</config>"
129 # This will make a target directory of ./VENDOR_MAINBOARD
131 target VENDOR_MAINBOARD
132 mainboard VENDOR/MAINBOARD
135 option CROSS_COMPILE="CROSS_PREFIX"
136 option HOSTCC="CROSS_HOSTCC"
141 if [ "$TARCH" == i386 ] ; then
144 option USE_FALLBACK_IMAGE=0
145 option ROM_IMAGE_SIZE=0x20000
146 option LINUXBIOS_EXTRA_VERSION=".0-normal"
151 option USE_FALLBACK_IMAGE=1
152 option ROM_IMAGE_SIZE=0x20000
153 option LINUXBIOS_EXTRA_VERSION=".0-fallback"
156 buildrom ./linuxbios.rom ROM_SIZE "normal" "fallback"
161 option LINUXBIOS_EXTRA_VERSION=".0"
164 buildrom ./linuxbios.rom ROM_SIZE "only"
167 ) > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
170 if [ "`which lzma`" != "" -a "$PAYLOAD" != /dev/null ]; then
171 COMPRESSION="option CONFIG_COMPRESSED_PAYLOAD_LZMA=1"
173 COMPRESSION="# no compression"
176 sed -i.pre -e s,VENDOR,$VENDOR,g \
177 -e s,MAINBOARD,$MAINBOARD,g \
178 -e s,payload\ __PAYLOAD__,payload\ $PAYLOAD,g \
179 -e s,CROSSCC,"$CC",g \
180 -e s,CROSS_PREFIX,"$CROSS_COMPILE",g \
181 -e s,CROSS_HOSTCC,"$HOSTCC",g \
182 -e s,__COMPRESSION__,"$COMPRESSION",g \
183 $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
187 function create_builddir
192 printf " Creating builddir..."
195 config_dir=$LBROOT/util/newconfig
196 yapps2_py=$config_dir/yapps2.py
197 config_g=$config_dir/config.g
198 config_lb=Config-${VENDOR}_${MAINBOARD}.lb
202 build_dir=${VENDOR}_${MAINBOARD}
203 config_py=$build_dir/config.py
205 if [ ! -d $build_dir ] ; then
208 if [ ! -f $config_py ]; then
209 $PYTHON $yapps2_py $config_g $config_py &> $build_dir/py.log
212 # make sure config.py is up-to-date
214 export PYTHONPATH=$config_dir
215 $PYTHON $config_py $config_lb $LBROOT &> $build_dir/config.log
216 if [ $? -eq 0 ]; then
218 xml " <builddir>ok</builddir>"
222 printf "FAILED! Log excerpt:\n"
223 xml " <builddir>failed</builddir>"
225 xmlfile $build_dir/config.log
228 tail -n $CONTEXT $build_dir/config.log
233 function create_buildenv
237 create_config $VENDOR $MAINBOARD
238 create_builddir $VENDOR $MAINBOARD
241 function compile_target
246 printf " Compiling image .."
248 cd $TARGET/${VENDOR}_${MAINBOARD}
250 eval $MAKE &> make.log
253 duration=$(( $etime - $stime ))
254 if [ $ret -eq 0 ]; then
255 xml " <compile>ok</compile>"
256 xml " <compiletime>${duration}s</compiletime>"
257 printf "ok\n" > compile.status
258 printf "ok. (took ${duration}s)\n"
262 xml " <compile>failed</compile>"
263 xml " <compiletime>${duration}s</compiletime>"
268 printf "FAILED after ${duration}s! Log excerpt:\n"
269 tail -n $CONTEXT make.log
275 function built_successfully
279 if [ -d "$TARGET/${VENDOR}_${MAINBOARD}" ]; then
280 cd $TARGET/${VENDOR}_${MAINBOARD}
281 if [ -r compile.status ] ; then
282 status=`cat compile.status`
286 [ "$buildall" != "true" -a "$status" == "ok" ]
289 function build_broken
293 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/BROKEN" ] && status="no"
294 [ "$buildbroken" == "true" -o "$status" == "yes" ]
297 function build_target
301 TARCH=$( architecture $VENDOR $MAINBOARD )
304 CC='$(CROSS_COMPILE)gcc'
308 printf "Processing mainboard/$VENDOR/$MAINBOARD"
312 xml " <vendor>$VENDOR</vendor>"
313 xml " <device>$MAINBOARD</device>"
315 xml " <architecture>$TARCH</architecture>"
318 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info" ] && \
319 source $LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info
321 if [ "$ARCH" == "$TARCH" ]; then
322 printf " ($TARCH: ok)\n"
324 found_crosscompiler=false
325 if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then
327 found_crosscompiler=true
329 if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then
331 found_crosscompiler=true
333 if [ "$found_crosscompiler" == "false" -a "$TARCH" == ppc ];then
334 for prefix in powerpc-eabi- powerpc-linux- ppc_74xx- \
335 powerpc-7450-linux-gnu-; do
336 if ${prefix}gcc --version > /dev/null 2> /dev/null ; then
337 found_crosscompiler=true
338 CROSS_COMPILE=$prefix
344 # TBD: look for suitable cross compiler suite
345 # cross-$TARCH-gcc and cross-$TARCH-ld
348 if [ $found_crosscompiler == "false" ]; then
349 printf " ($TARCH: skipped, we're $ARCH)\n\n"
350 xml " <status>notbuilt</status>"
356 printf " ($TARCH: ok, we're $ARCH)\n"
358 xml " <path>`which ${CROSS_COMPILE}gcc`</path>"
359 xml " <version>`${CROSS_COMPILE}gcc --version | head -1`</version>"
365 built_successfully $VENDOR $MAINBOARD && \
367 printf " ( mainboard/$VENDOR/$MAINBOARD previously ok )\n\n"
368 xml " <status>previouslyok</status>"
374 build_broken $VENDOR $MAINBOARD || \
376 printf " ( broken mainboard/$VENDOR/$MAINBOARD skipped )\n\n"
377 xml " <status>knownbroken</status>"
383 create_buildenv $VENDOR $MAINBOARD
384 if [ $? -eq 0 ]; then
385 compile_target $VENDOR $MAINBOARD &&
386 xml " <status>ok</status>" ||
387 xml "<status>broken</status>"
401 if [ "$hwtest" != "true" ]; then
405 # image does not exist. we silently skip the patch.
406 if [ ! -r "$TARGET/${VENDOR}_${MAINBOARD}/linuxbios.rom" ]; then
410 which curl &> /dev/null
412 printf "curl is not installed but required for test submission. skipping test.\n\n"
417 if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/tested" ]; then
418 printf "Testing image for board $VENDOR $MAINBOARD skipped (previously submitted).\n\n"
421 # touch $TARGET/${VENDOR}_${MAINBOARD}/tested
423 printf "Submitting image for board $VENDOR $MAINBOARD to test system...\n"
425 curl -f -F "romfile=@$TARGET/${VENDOR}_${MAINBOARD}/linuxbios.rom" \
426 -F "mode=abuild" -F "mainboard=${VENDOR}_${MAINBOARD}" -F "submit=Upload" \
427 "http://qa.linuxbios.org/deployment/send.php"
435 printf "Usage: $0 [-v] [-a] [-b] [-t <vendor/board>] [-p <dir>] [lbroot]\n"
436 printf " $0 [-V|--version]\n"
437 printf " $0 [-h|--help]\n\n"
440 printf " [-v|--verbose] print more messages\n"
441 printf " [-a|--all] build previously succeeded ports as well\n"
442 printf " [-b|--broken] attempt to build ports that are known broken\n"
443 printf " [-t|--target <vendor/board>] attempt to build target vendor/board only\n"
444 printf " [-p|--payloads <dir>] use payloads in <dir> to build images\n"
445 printf " [-V|--version] print version number and exit\n"
446 printf " [-h|--help] print this help and exit\n"
447 printf " [-x|--xml] write xml log file \n"
448 printf " (defaults to $XMLFILE)\n"
449 printf " [-T|--test] submit image(s) to automated test system\n"
450 printf " [lbroot] absolute path to LinuxBIOS sources\n"
451 printf " (defaults to $LBROOT)\n\n"
458 LinuxBIOS autobuild v$ABUILD_VERSION ($ABUILD_DATE)
460 Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org>
461 Copyright (C) 2006 by coresystems GmbH <info@coresystems.de>
463 This program is free software; you may redistribute it under the terms
464 of the GNU General Public License. This program has absolutely no
473 LBROOT=$( cd ../..; pwd )
477 args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test Vvhat:bp:T -- "$@"`
487 -x|--xml) shift; mode=xml; rm -f $XMLFILE ;;
488 -t|--target) shift; target="$1"; shift;;
489 -a|--all) shift; buildall=true;;
490 -b|--broken) shift; buildbroken=true;;
491 -v|--verbose) shift; verbose=true;;
492 -V|--version) shift; myversion; exit 0;;
493 -h|--help) shift; myversion; myhelp; exit 0;;
494 -p|--payloads) shift; payloads="$1"; shift;;
495 -T|--test) shift; hwtest=true;;
497 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
502 # /path/to/freebios2/
503 test -z "$1" || LBROOT=$1
505 debug "LBROOT=$LBROOT"
507 xml '<?xml version="1.0" encoding="utf-8"?>'
510 if [ "$target" != "" ]; then
511 # build a single board
512 VENDOR=`printf $target|cut -f1 -d/`
513 MAINBOARD=`printf $target|cut -f2 -d/`
514 build_target $VENDOR $MAINBOARD
515 test_target $VENDOR $MAINBOARD
517 # build all boards per default
518 for VENDOR in $( vendors ); do
519 for MAINBOARD in $( mainboards $VENDOR ); do
520 build_target $VENDOR $MAINBOARD
521 test_target $VENDOR $MAINBOARD