1 | #!/bin/bash |
---|
2 | |
---|
3 | die() { |
---|
4 | echo "$1" 2>&1; |
---|
5 | if [ ! -z "$TMPDIR" ] |
---|
6 | then |
---|
7 | echo "The failed build can be found in $TMPDIR" |
---|
8 | fi |
---|
9 | exit -1 |
---|
10 | } |
---|
11 | |
---|
12 | DRYRUN= |
---|
13 | if [ "$1" = "-n" ]; then |
---|
14 | DRYRUN=1 |
---|
15 | shift; |
---|
16 | fi |
---|
17 | |
---|
18 | NAME="$1" |
---|
19 | NAME="${NAME:?Usage: barnowl-locker-build NAME}" |
---|
20 | TGZ="$2" |
---|
21 | |
---|
22 | ATHENA_SYS="${ATHENA_SYS:-$(machtype -S)}" |
---|
23 | |
---|
24 | if [ "$(uname)" = "SunOS" ]; then |
---|
25 | MAKE=gmake |
---|
26 | TAR=gtar |
---|
27 | else |
---|
28 | MAKE=make |
---|
29 | TAR=tar |
---|
30 | fi |
---|
31 | |
---|
32 | attach barnowl |
---|
33 | aklog |
---|
34 | |
---|
35 | mkdir -p /tmp/barnowl.$UID || die "Unable to mkdir" |
---|
36 | TMPDIR=$(mktemp -d /tmp/barnowl.$UID/buildXXXXXX) || die "Unable to mktemp" |
---|
37 | cd "$TMPDIR" || die "Unable to cd to $TMPDIR" |
---|
38 | |
---|
39 | $TAR xzvf "$BARNOWL_TGZ" || die "Unable to untar" |
---|
40 | cd *; |
---|
41 | |
---|
42 | # git archive --remote="$REPOURL" --format=tar $BRANCH | $TAR xf - || die "Unable to create archive" |
---|
43 | # svn co file:///mit/barnowl/src/svn/$REPOPATH/owl/ barnowl || die "Unable to checkout" |
---|
44 | # cd barnowl || die "Unable to cd" |
---|
45 | |
---|
46 | ARGS= |
---|
47 | |
---|
48 | # if ! grep -i debian /etc/athena/version >/dev/null 2>&1 ; then |
---|
49 | # ARGS=--enable-athstatic |
---|
50 | # fi |
---|
51 | |
---|
52 | # autoreconf || die "autoreconf failed" |
---|
53 | # autoconf || die "autoconf failed" |
---|
54 | |
---|
55 | BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS" |
---|
56 | export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig" |
---|
57 | |
---|
58 | CFLAGS="-I$BARNOWL/include" \ |
---|
59 | LDFLAGS="-L$BARNOWL/lib -Wl,-R$BARNOWL/lib" \ |
---|
60 | ./configure --exec-prefix="/mit/barnowl/arch/$ATHENA_SYS" \ |
---|
61 | --prefix="/mit/barnowl/builds/$NAME" --mandir=/mit/barnowl/man \ |
---|
62 | PROTECT_CFLAGS=-fno-stack-protector \ |
---|
63 | $ARGS \ |
---|
64 | || die "configure failed" |
---|
65 | |
---|
66 | $MAKE clean || die "make clean failed" |
---|
67 | |
---|
68 | CPUS=$(athinfo localhost cpuspeed | grep -c MHz) |
---|
69 | if [ "$CPUS" = 0 ]; then |
---|
70 | CPUS=1 |
---|
71 | fi |
---|
72 | |
---|
73 | $MAKE -j$CPUS EXE=$NAME all || die "make failed" |
---|
74 | |
---|
75 | if [ -n "$DRYRUN" ]; then |
---|
76 | echo "Build completed; Dropping to a shell..." |
---|
77 | exec $SHELL; |
---|
78 | else |
---|
79 | if [ -n "$TGZ" ]; then |
---|
80 | mkdir tgz |
---|
81 | $MAKE EXE=$NAME DESTDIR=tgz install || die "Install failed" |
---|
82 | cd tgz && $TAR czvf "$TGZ" . || die "Make tarball failed" |
---|
83 | else |
---|
84 | $MAKE EXE=$NAME install || die "Install failed" |
---|
85 | fi |
---|
86 | fi |
---|
87 | |
---|
88 | cd /tmp |
---|
89 | rm -rf "$TMPDIR" |
---|