source: scripts/locker-build @ 67dd774

release-1.10release-1.4release-1.5release-1.6release-1.7release-1.8release-1.9
Last change on this file since 67dd774 was 67dd774, checked in by Nelson Elhage <nelhage@mit.edu>, 15 years ago
locker-build: Two small fixes First, correctly propagate errors out of the subshell that we do the build in. Second, if a dry-run build fails, drop to a shell anyways to let me inspect what went wrong.
  • Property mode set to 100755
File size: 2.7 KB
Line 
1#!/bin/sh
2
3#########################################################
4# Build script to build BarnOwl for the locker.
5
6# Usage: locker-build [-n] [-o OUTPUT-TGZ] VERSION SOURCE-TARBALL
7# -n is a dry-run, and drops to a shell in the build directory
8# -o does the install into a temporary directory and tars it into the
9#    specified tarball instead.
10# SOURCE-TARBALL is a source tarball, created by do-release
11# VERSION should be of the form 'barnowl-VERSION'
12#
13# TODO: Scrape $VERSION from the tarball
14
15die() {
16    echo "$@" 2>&1;
17    if [ -n "$TMPDIR" ]; then
18        if [ -n "$DRYRUN" ]; then
19            echo "Dropping to a shell to investigate...";
20            $SHELL
21        fi
22    fi
23    exit 1;
24}
25
26usage () {
27    echo "Usage: $0 [-n] [-o OUTPUT-TGZ] VERSION SOURCE-TARBALL"
28    exit 2;
29}
30
31exittrap() { :; }
32for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done
33trap 'exittrap' EXIT
34
35SRC_TGZ=
36OUT_TGZ=
37DRYRUN=
38
39set -- `getopt no: "$@"`
40[ $? -eq 0 ] || usage
41
42for opt
43do
44    case "$opt" in
45        -n)
46            DRYRUN=1; shift ;;
47        -o)
48            OUT_TGZ="$2"; shift 2;;
49        --)
50            shift; break ;;
51    esac
52done
53
54NAME="$1"
55SRC_TGZ="$2"
56
57test -z "$NAME" && usage
58test -z "$SRC_TGZ"  && usage
59
60
61ATHENA_SYS="${ATHENA_SYS:-$(machtype -S)}"
62
63if [ "$(uname)" = "SunOS" ]; then
64    MAKE=gmake
65    TAR=gtar
66else
67    MAKE=make
68    TAR=tar
69fi
70
71attach barnowl
72aklog
73
74TMPDIR=$(mktemp -d /tmp/barnowl-build-XXXXXX) || die "Unable to mktemp"
75
76exittrap() { rm -rf "$TMPDIR"; }
77
78$TAR -C "$TMPDIR" -xzf "$SRC_TGZ" || die "Unable to untar"
79
80(
81    cd "$TMPDIR"/* || die "Unable to cd to $TMPDIR"
82
83    BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS"
84    export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig"
85
86    CFLAGS="-I$BARNOWL/include" \
87        LDFLAGS="-L$BARNOWL/lib -Wl,-R$BARNOWL/lib" \
88        ./configure --exec-prefix="/mit/barnowl/arch/$ATHENA_SYS" \
89        --prefix="/mit/barnowl/builds/$NAME" --mandir=/mit/barnowl/man \
90        PROTECT_CFLAGS=-fno-stack-protector \
91        || die "configure failed"
92
93    $MAKE clean  || die "make clean failed"
94
95    CPUS=$(athinfo localhost cpuspeed | grep -c MHz)
96    if [ "$CPUS" = 0 ]; then
97        CPUS=1
98    fi
99
100    $MAKE -j$CPUS EXE=$NAME all || die "make failed"
101
102    if [ -n "$DRYRUN" ]; then
103        echo "Build completed; Dropping to a shell..."
104        $SHELL
105    else
106        if [ -n "$OUT_TGZ" ]; then
107            mkdir tgz
108            $MAKE EXE=$NAME DESTDIR=tgz install || die "Install failed"
109        else
110            $MAKE EXE=$NAME install || die "Install failed"
111        fi
112    fi
113)
114
115if [ "$?" -ne 0 ]; then
116    exit "$?"
117fi
118
119if [ -n "$OUT_TGZ" ]; then
120    $TAR -C "$TMPDIR/"*/tgz -czvf "$OUT_TGZ" . || die "Make tarball failed"
121fi
122
123rm -rf "$TMPDIR"
124exittrap() { :; }
Note: See TracBrowser for help on using the repository browser.