Changeset 56e4869


Ignore:
Timestamp:
Apr 11, 2009, 6:11:04 PM (16 years ago)
Author:
Nelson Elhage <nelhage@mit.edu>
Branches:
master, debian, release-1.10, release-1.4, release-1.5, release-1.6, release-1.7, release-1.8, release-1.9
Children:
f9f065a
Parents:
5c81472
Message:
Add usage and clean up the build script a lot.
Location:
scripts
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • scripts/locker-build

    r5c81472 r56e4869  
    1 #!/bin/bash
     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
    214
    315die() {
    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
     16      echo "$@" 2>&1;
     17      exit 1;
    1018}
    1119
     20usage () {
     21    echo "Usage: $0 [-n] [-o OUTPUT-TGZ] VERSION SOURCE-TARBALL"
     22    exit 2;
     23}
     24
     25exittrap() { :; }
     26for sig in 1 2 13 15; do trap "exit $(($sig + 128))" $sig; done
     27trap 'exittrap' EXIT
     28
     29SRC_TGZ=
     30OUT_TGZ=
    1231DRYRUN=
    13 if [ "$1" = "-n" ]; then
    14     DRYRUN=1
    15     shift;
    16 fi
     32
     33set -- `getopt no: "$@"`
     34[ $? -eq 0 ] || usage
     35
     36for opt
     37do
     38    case "$opt" in
     39        -n)
     40            DRYRUN=1; shift ;;
     41        -o)
     42            OUT_TGZ="$2"; shift 2;;
     43        --)
     44            shift; break ;;
     45    esac
     46done
    1747
    1848NAME="$1"
    19 NAME="${NAME:?Usage: barnowl-locker-build NAME}"
    20 TGZ="$2"
     49SRC_TGZ="$2"
     50
     51test -z "$NAME" && usage
     52test -z "$SRC_TGZ"  && usage
     53
    2154
    2255ATHENA_SYS="${ATHENA_SYS:-$(machtype -S)}"
     
    3366aklog
    3467
    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"
     68TMPDIR=$(mktemp -d /tmp/barnowl-build-XXXXXX) || die "Unable to mktemp"
    3869
    39 $TAR xzvf "$BARNOWL_TGZ" || die "Unable to untar"
    40 cd *;
     70exittrap() { rm -rf "$TMPDIR"; }
    4171
    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"
     72$TAR -C "$TMPDIR" -xzvf "$SRC_TGZ" || die "Unable to untar"
    4573
    46 ARGS=
     74(
     75    cd "$TMPDIR"/* || die "Unable to cd to $TMPDIR"
    4776
    48 # if ! grep -i debian /etc/athena/version >/dev/null 2>&1 ; then
    49 #     ARGS=--enable-athstatic
    50 # fi
     77    BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS"
     78    export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig"
    5179
    52 # autoreconf         || die "autoreconf failed"
    53 # autoconf        || die "autoconf failed"
     80    CFLAGS="-I$BARNOWL/include" \
     81        LDFLAGS="-L$BARNOWL/lib -Wl,-R$BARNOWL/lib" \
     82        ./configure --exec-prefix="/mit/barnowl/arch/$ATHENA_SYS" \
     83        --prefix="/mit/barnowl/builds/$NAME" --mandir=/mit/barnowl/man \
     84        PROTECT_CFLAGS=-fno-stack-protector \
     85        || die "configure failed"
    5486
    55 BARNOWL="/afs/sipb.mit.edu/project/barnowl/arch/$ATHENA_SYS"
    56 export PKG_CONFIG_PATH="$BARNOWL/lib/pkgconfig"
     87    $MAKE clean  || die "make clean failed"
    5788
    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"
     89    CPUS=$(athinfo localhost cpuspeed | grep -c MHz)
     90    if [ "$CPUS" = 0 ]; then
     91        CPUS=1
     92    fi
    6593
    66 $MAKE clean  || die "make clean failed"
     94    $MAKE -j$CPUS EXE=$NAME all || die "make failed"
    6795
    68 CPUS=$(athinfo localhost cpuspeed | grep -c MHz)
    69 if [ "$CPUS" = 0 ]; then
    70    CPUS=1
     96    if [ -n "$DRYRUN" ]; then
     97        echo "Build completed; Dropping to a shell..."
     98        $SHELL
     99    else
     100        if [ -n "$OUT_TGZ" ]; then
     101            mkdir tgz
     102            $MAKE EXE=$NAME DESTDIR=tgz install || die "Install failed"
     103        else
     104            $MAKE EXE=$NAME install || die "Install failed"
     105        fi
     106    fi
     107)
     108
     109if [ -n "$OUT_TGZ" ]; then
     110    $TAR -C "$TMPDIR/"*/tgz -czvf "$OUT_TGZ" . || die "Make tarball failed"
    71111fi
    72112
    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
    89113rm -rf "$TMPDIR"
     114exittrap() { :; }
  • scripts/locker-update

    r5c81472 r56e4869  
    11#!/bin/bash
    22NEWVERSION="$1"
     3
     4# Run this as 'locker-update NEW-VERSION' to upgrade the barnowl.real
     5# symlink in all arch/ directories to point to the new version.
    36
    47if [ -z "$NEWVERSION" ]; then
     
    1922                echo "New version $NEWVERSION not built for arch $i...";
    2023            else
     24                # Sanity -- make sure the 'barnowl' symlink is correct.
    2125                ln -sf "../../common/bin/barnowl" "$i/bin/barnowl"
    2226                ln -sf "$NEWVERSION" "$i/bin/barnowl.real"
Note: See TracChangeset for help on using the changeset viewer.