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.
109 if [ -x $payloads/payload.sh ]; then
110 PAYLOAD=`$payloads/payload.sh $VENDOR $MAINBOARD`
111 printf "Using custom payload $PAYLOAD\n"
116 if [ -f $TARGCONFIG ]; then
117 cp $TARGCONFIG $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
118 printf "Using existing test target $TARGCONFIG"
119 xml " <config>$TARGCONFIG</config>"
122 printf " Creating config file..."
123 xml " <config>autogenerated</config>"
125 # This will make a target directory of ./VENDOR_MAINBOARD
127 target VENDOR_MAINBOARD
128 mainboard VENDOR/MAINBOARD
131 option CROSS_COMPILE="CROSS_PREFIX"
132 option HOSTCC="CROSS_HOSTCC"
135 if [ "$TARCH" == i386 ] ; then
138 option USE_FALLBACK_IMAGE=0
139 option ROM_IMAGE_SIZE=0x20000
140 option LINUXBIOS_EXTRA_VERSION=".0-normal"
145 option USE_FALLBACK_IMAGE=1
146 option ROM_IMAGE_SIZE=0x20000
147 option LINUXBIOS_EXTRA_VERSION=".0-fallback"
150 buildrom ./linuxbios.rom ROM_SIZE "normal" "fallback"
155 option LINUXBIOS_EXTRA_VERSION=".0"
158 buildrom ./linuxbios.rom ROM_SIZE "only"
161 ) > $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
164 sed -i.pre -e s,VENDOR,$VENDOR,g \
165 -e s,MAINBOARD,$MAINBOARD,g \
166 -e s,payload\ PAYLOAD,payload\ $PAYLOAD,g \
167 -e s,CROSSCC,"$CC",g \
168 -e s,CROSS_PREFIX,"$CROSS_COMPILE",g \
169 -e s,CROSS_HOSTCC,"$HOSTCC",g \
170 $TARGET/Config-${VENDOR}_${MAINBOARD}.lb
175 function create_builddir
180 printf " Creating builddir..."
183 config_dir=$LBROOT/util/newconfig
184 yapps2_py=$config_dir/yapps2.py
185 config_g=$config_dir/config.g
186 config_lb=Config-${VENDOR}_${MAINBOARD}.lb
190 build_dir=${VENDOR}_${MAINBOARD}
191 config_py=$build_dir/config.py
193 if [ ! -d $build_dir ] ; then
196 if [ ! -f $config_py ]; then
197 $PYTHON $yapps2_py $config_g $config_py &> $build_dir/py.log
200 # make sure config.py is up-to-date
202 export PYTHONPATH=$config_dir
203 $PYTHON $config_py $config_lb $LBROOT &> $build_dir/config.log
204 if [ $? -eq 0 ]; then
206 xml " <builddir>ok</builddir>"
210 printf "FAILED! Log excerpt:\n"
211 xml " <builddir>failed</builddir>"
213 xmlfile $build_dir/config.log
216 tail -n $CONTEXT $build_dir/config.log
221 function create_buildenv
225 create_config $VENDOR $MAINBOARD
226 create_builddir $VENDOR $MAINBOARD
229 function compile_target
234 printf " Compiling image .."
236 cd $TARGET/${VENDOR}_${MAINBOARD}
238 eval $MAKE &> make.log
241 duration=$(( $etime - $stime ))
242 if [ $ret -eq 0 ]; then
243 xml " <compile>ok</compile>"
244 xml " <compiletime>${duration}s</compiletime>"
245 printf "ok\n" > compile.status
246 printf "ok. (took ${duration}s)\n"
250 xml " <compile>failed</compile>"
251 xml " <compiletime>${duration}s</compiletime>"
256 printf "FAILED after ${duration}s! Log excerpt:\n"
257 tail -n $CONTEXT make.log
263 function built_successfully
267 if [ -d "$TARGET/${VENDOR}_${MAINBOARD}" ]; then
268 cd $TARGET/${VENDOR}_${MAINBOARD}
269 if [ -r compile.status ] ; then
270 status=`cat compile.status`
274 [ "$buildall" != "true" -a "$status" == "ok" ]
277 function build_broken
281 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/BROKEN" ] && status="no"
282 [ "$buildbroken" == "true" -o "$status" == "yes" ]
285 function build_target
289 TARCH=$( architecture $VENDOR $MAINBOARD )
292 CC='$(CROSS_COMPILE)gcc'
296 printf "Processing mainboard/$VENDOR/$MAINBOARD"
300 xml " <vendor>$VENDOR</vendor>"
301 xml " <device>$MAINBOARD</device>"
303 xml " <architecture>$TARCH</architecture>"
306 [ -r "$LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info" ] && \
307 source $LBROOT/src/mainboard/${VENDOR}/${MAINBOARD}/abuild.info
309 if [ "$ARCH" == "$TARCH" ]; then
310 printf " ($TARCH: ok)\n"
312 found_crosscompiler=false
313 if [ "$ARCH" == amd64 -a "$TARCH" == i386 ]; then
315 found_crosscompiler=true
317 if [ "$ARCH" == ppc64 -a "$TARCH" == ppc ]; then
319 found_crosscompiler=true
321 if [ "$found_crosscompiler" == "false" -a "$TARCH" == ppc ];then
322 for prefix in powerpc-eabi- powerpc-linux- ppc_74xx- \
323 powerpc-7450-linux-gnu-; do
324 if ${prefix}gcc --version > /dev/null 2> /dev/null ; then
325 found_crosscompiler=true
326 CROSS_COMPILE=$prefix
332 # TBD: look for suitable cross compiler suite
333 # cross-$TARCH-gcc and cross-$TARCH-ld
336 if [ $found_crosscompiler == "false" ]; then
337 printf " ($TARCH: skipped, we're $ARCH)\n\n"
338 xml " <status>notbuilt</status>"
344 printf " ($TARCH: ok, we're $ARCH)\n"
346 xml " <path>`which ${CROSS_COMPILE}gcc`</path>"
347 xml " <version>`${CROSS_COMPILE}gcc --version | head -1`</version>"
353 built_successfully $VENDOR $MAINBOARD && \
355 printf " ( mainboard/$VENDOR/$MAINBOARD previously ok )\n\n"
356 xml " <status>previouslyok</status>"
362 build_broken $VENDOR $MAINBOARD || \
364 printf " ( broken mainboard/$VENDOR/$MAINBOARD skipped )\n\n"
365 xml " <status>knownbroken</status>"
371 create_buildenv $VENDOR $MAINBOARD
372 if [ $? -eq 0 ]; then
373 compile_target $VENDOR $MAINBOARD &&
374 xml " <status>ok</status>" ||
375 xml "<status>broken</status>"
389 if [ "$hwtest" != "true" ]; then
393 # image does not exist. we silently skip the patch.
394 if [ ! -r "$TARGET/${VENDOR}_${MAINBOARD}/linuxbios.rom" ]; then
398 which curl &> /dev/null
400 printf "curl is not installed but required for test submission. skipping test.\n\n"
405 if [ -r "$TARGET/${VENDOR}_${MAINBOARD}/tested" ]; then
406 printf "Testing image for board $VENDOR $MAINBOARD skipped (previously submitted).\n\n"
409 # touch $TARGET/${VENDOR}_${MAINBOARD}/tested
411 printf "Submitting image for board $VENDOR $MAINBOARD to test system...\n"
413 curl -f -F "romfile=@$TARGET/${VENDOR}_${MAINBOARD}/linuxbios.rom" \
414 -F "mode=abuild" -F "mainboard=${VENDOR}_${MAINBOARD}" -F "submit=Upload" \
415 "http://qa.linuxbios.org/deployment/send.php"
423 printf "Usage: $0 [-v] [-a] [-b] [-t <vendor/board>] [-p <dir>] [lbroot]\n"
424 printf " $0 [-V|--version]\n"
425 printf " $0 [-h|--help]\n"
428 printf " [-v|--verbose] print more messages\n"
429 printf " [-a|--all] build previously succeeded ports as well\n"
430 printf " [-b|--broken] attempt to build ports that are known broken\n"
431 printf " [-t|--target <vendor/board>] attempt to build target vendor/board only\n"
432 printf " [-p|--payloads <dir>] use payloads in <dir> to build images\n"
433 printf " [-V|--version] print version number and exit\n"
434 printf " [-h|--help] print this help and exit\n"
435 printf " [-x|--xml] write xml log file \n"
436 printf " (defaults to $XMLFILE)\n"
437 printf " [-T|--test] submit image(s) to automated test system\n"
438 printf " [lbroot] absolute path to LinuxBIOS sources\n"
439 printf " (defaults to $LBROOT)\n\n"
446 LinuxBIOS autobuild v$ABUILD_VERSION ($ABUILD_DATE)
448 Copyright (C) 2004 by Stefan Reinauer <stepan@openbios.org>
449 Copyright (C) 2006 by coresystems GmbH <info@coresystems.de>
451 This program is free software; you may redistribute it under the terms
452 of the GNU General Public License. This program has absolutely no
461 LBROOT=$( cd ../..; pwd )
465 args=`getopt -l version,verbose,help,all,target:,broken,payloads:,test Vvhat:bp:T -- "$@"`
475 -x|--xml) shift; mode=xml; rm -f $XMLFILE ;;
476 -t|--target) shift; target="$1"; shift;;
477 -a|--all) shift; buildall=true;;
478 -b|--broken) shift; buildbroken=true;;
479 -v|--verbose) shift; verbose=true;;
480 -V|--version) shift; myversion; exit 0;;
481 -h|--help) shift; myversion; myhelp; exit 0;;
482 -p|--payloads) shift; payloads="$1"; shift;;
483 -T|--test) shift; hwtest=true;;
485 -*) printf "Invalid option\n\n"; myhelp; exit 1;;
490 # /path/to/freebios2/
491 test -z "$1" || LBROOT=$1
493 debug "LBROOT=$LBROOT"
495 xml '<?xml version="1.0" encoding="utf-8"?>'
498 if [ "$target" != "" ]; then
499 # build a single board
500 VENDOR=`printf $target|cut -f1 -d/`
501 MAINBOARD=`printf $target|cut -f2 -d/`
502 build_target $VENDOR $MAINBOARD
503 test_target $VENDOR $MAINBOARD
505 # build all boards per default
506 for VENDOR in $( vendors ); do
507 for MAINBOARD in $( mainboards $VENDOR ); do
508 build_target $VENDOR $MAINBOARD
509 test_target $VENDOR $MAINBOARD