David Lamparter | f6295c2 | 2013-01-15 17:59:08 +0100 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | # written 2012-2013 by David Lamparter, placed in Public Domain. |
| 3 | # |
| 4 | # builds some git commit of Quagga in some different configurations |
| 5 | # usage: buildtest.sh [commit [configurations...]] |
| 6 | |
| 7 | basecfg="--prefix=/usr --enable-user=quagga --enable-group=quagga --enable-vty-group=quagga --enable-configfile-mask=0660 --enable-logfile-mask=0640 --enable-vtysh --sysconfdir=/etc/quagga --enable-exampledir=/etc/quagga/samples --localstatedir=/var/run/quagga --libdir=/usr/lib64/quagga --enable-ipv6 --enable-ripngd --enable-ospf6d --enable-rtadv --disable-static --enable-isisd --enable-multipath=0 --enable-babeld" |
| 8 | |
| 9 | configs_base="gcc|$basecfg" |
| 10 | |
| 11 | configs_nov6="gcc|$basecfg" |
| 12 | configs_nov6="${configs_nov6/enable-ipv6/disable-ipv6}" |
| 13 | configs_nov6="${configs_nov6/enable-ospf6d/disable-ospf6d}" |
| 14 | configs_nov6="${configs_nov6/enable-ripngd/disable-ripngd}" |
| 15 | configs_nov6="${configs_nov6/enable-babeld/disable-babeld}" |
| 16 | |
| 17 | configs_ext="gcc|$basecfg --enable-opaque-lsa --enable-ospf-te --enable-ospfclient --enable-isis-topology" |
| 18 | configs_snmp="gcc|$basecfg --enable-opaque-lsa --enable-ospf-te --enable-ospfclient --enable-isis-topology --enable-snmp" |
| 19 | configs_clang="clang|$basecfg --enable-opaque-lsa --enable-ospf-te --enable-ospfclient --enable-isis-topology" |
| 20 | configs_icc="icc|$basecfg --enable-opaque-lsa --enable-ospf-te --enable-ospfclient --enable-isis-topology" |
| 21 | |
| 22 | defconfigs="base nov6 ext" |
| 23 | net-snmp-config --version &> /dev/null && defconfigs="$defconfigs snmp" |
| 24 | clang --version &> /dev/null && defconfigs="$defconfigs clang" |
| 25 | icc --version &> /dev/null && defconfigs="$defconfigs icc" |
| 26 | |
| 27 | echo "enabled configurations: $defconfigs" |
| 28 | |
| 29 | cc_gcc="CC=gcc; export CC" |
| 30 | cc_clang="CC=clang; export CC" |
| 31 | cc_icc="CC=icc; export CC" |
| 32 | |
| 33 | ############################### |
| 34 | |
| 35 | errfunc() { |
| 36 | echo "something went wrong! check $TEMP" |
| 37 | exit 1 |
| 38 | } |
| 39 | |
| 40 | set -e |
| 41 | trap errfunc ERR |
| 42 | |
| 43 | COMMITREF="$1" |
| 44 | COMMITISH="`git rev-list --max-count=1 ${COMMITREF:-HEAD}`" |
| 45 | TEMP="`mktemp -t -d quaggabuild.XXXXXX`" |
| 46 | BASE="`pwd`" |
| 47 | CONFIGS="$2" |
| 48 | |
| 49 | echo using temporary directory: $TEMP |
| 50 | echo git commit used: |
| 51 | git --no-pager log -n 1 --pretty=oneline "$COMMITISH" |
| 52 | |
| 53 | cd "$TEMP" |
| 54 | git clone "$BASE" "source" |
| 55 | cd "source" |
| 56 | git checkout -b build "$COMMITISH" |
| 57 | git clean -d -f -x |
| 58 | sh bootstrap.sh |
| 59 | |
| 60 | cd .. |
| 61 | |
| 62 | echo -e "\n\n\n\n\033[33;1mmaking dist tarball\033[m" |
| 63 | |
| 64 | mkdir build_dist |
| 65 | cd build_dist |
| 66 | ../source/configure |
| 67 | make distdir=sdist dist-gzip |
| 68 | cd .. |
| 69 | tar zxvf build_dist/sdist.tar.gz |
| 70 | |
| 71 | for cfg in ${CONFIGS:-$defconfigs}; do |
| 72 | echo -e "\n\n\n\n\033[33;1mbuilding configuration $cfg\033[m" |
| 73 | config="\${configs_$cfg}" |
| 74 | eval "config=$config" |
| 75 | |
| 76 | cc="${config%%|*}" |
| 77 | args="${config#*|}" |
| 78 | |
| 79 | ccset="\${cc_$cc}" |
| 80 | eval "ccset=$ccset" |
| 81 | eval "$ccset" |
| 82 | |
| 83 | bdir="build_$cfg" |
| 84 | mkdir "$bdir" |
| 85 | cd "$bdir" |
| 86 | ../sdist/configure $args |
| 87 | make -j5 |
| 88 | make DESTDIR="$TEMP/inst_$cfg" install |
| 89 | cd .. |
| 90 | done |
| 91 | |
| 92 | echo -e "\n\n\n\neverything seems ok. you may now\n\trm -rf $TEMP" |