simple gitignore
[strace-test.git] / strace-build-test
1 #!/bin/bash
2
3 POINT=HEAD
4 ARCH=$(dpkg-architecture -q DEB_BUILD_ARCH)
5 HOSTNAME=$(hostname)
6
7 while getopts ":p:a:" opt; do
8   case $opt in
9     p)
10       POINT=$OPTARG
11       ;;
12     a)
13       ARCH=$OPTARG
14       set +e
15       chk=`dpkg-architecture -a$ARCH > /dev/null 2>&1 ; echo $?`
16       set -e
17       if [ $chk != 0 ]; then
18           echo "Did not recognise ${ARCH} as a Debian architecture name. Exit."
19           exit 1
20       fi
21       ARCH=${ARCH}
22       ;;
23     \?)
24       echo "Invalid option: -$OPTARG" >&2
25       ;;
26   esac
27 done
28
29 PATH=/usr/local/sbin:/usr/local/bin:$PATH
30 export PATH
31
32 NUMCPUS=$(grep processor /proc/cpuinfo | wc -l)
33 if [ $NUMCPUS -gt 1 ]; then
34     PARALLEL="-j $NUMCPUS"
35 else
36     PARALLEL=""
37 fi
38
39 set -e
40 set -x
41
42 mysid=sid-93sam-strace-$RANDOM
43
44 BASE_CHROOT="sid_$ARCH-dchroot"
45
46 schroot -e -c $mysid || true
47 schroot -b -c $BASE_CHROOT -n $mysid
48 dd-schroot-cmd -y -c $mysid apt-get update
49 dd-schroot-cmd -y -c $mysid apt-get build-dep strace
50 dd-schroot-cmd -y -c $mysid apt-get install git autotools-dev gawk dh-autoreconf
51
52 DATETIME=$(date -u '+%Y-%m-%d-%H%M%S')
53 BDIR=~/build/strace/build-test-${DATETIME}
54
55 mkdir -p ${BDIR}
56 cd ${BDIR}
57
58 cat > ~/build/strace/inside-schroot-test.sh << EOF
59 #!/bin/sh
60 cd ${BDIR}
61 git clone -q http://git.code.sf.net/p/strace/code strace.git
62 echo "BUILD ENVIRONMENT INFORMATION"
63 echo "============================="
64 echo "Debian architecture"
65 echo "-------------------"
66 dpkg-architecture -q DEB_BUILD_ARCH
67 echo "Hostname"
68 echo "--------"
69 hostname
70 echo "uname -rm"
71 echo "---------"
72 uname -rm
73 echo "Version of kernel headers (linux-libc-dev)"
74 echo "------------------------------------------"
75 dpkg -s linux-libc-dev
76 echo "Version of libc"
77 echo "---------------"
78 dpkg -s libc6-dev
79 echo "Version of gcc"
80 echo "--------------"
81 dpkg -s gcc
82 cd strace.git
83 git checkout $POINT
84 git log | head -1
85 ./bootstrap
86 ./configure
87 make $PARALLEL && make check VERBOSE=1 && echo SUCCESS > ${BDIR}/RESULT
88 EOF
89
90 chmod +x ~/build/strace/inside-schroot-test.sh
91
92 cd ~
93
94 # Run the command, outout to typescript
95 script -c "schroot -r -c $mysid ~/build/strace/inside-schroot-test.sh"
96
97 if [ ! -f ${BDIR}/RESULT ] ; then
98     echo "BUILD FAILED - not doing cleanup"
99     echo "Results in ${BDIR}"
100 fi
101 schroot -e -c $mysid
102 rm -rf ${BDIR}
103 rm -f ~/build/strace/inside-schroot-test.sh
104 mv typescript typescript-$ARCH-$HOSTNAME-${DATETIME}.txt
105
106 gzip -9 typescript-$ARCH-$HOSTNAME-${DATETIME}.txt
107 FILE="typescript-$ARCH-$HOSTNAME-${DATETIME}.txt.gz"
108
109 (echo "START $FILE" ; \
110  base64 < $FILE ; \
111  echo "END $FILE") | \
112     mailx -s "strace-build-test $ARCH-$HOSTNAME-${DATETIME} log" \
113           steve-strace@einval.com
114
115 rm -f $FILE