maint: removed hardcoded bmbuild from bm scripts, and added multi-target support
[barry.git] / maintainer / release-bm.sh
blob57b05fcf260b3febec6d93565ef5713cf1dd08a6
1 #!/bin/bash
3 if [ -z "$1" -o -z "$2" -o -z "$3" ] ; then
4 echo
5 echo "Usage: ./release-bm.sh builddir binary-meta-tarball target1 [target2...]"
6 echo
7 echo "Uses the given binary-meta tarball, and builds it on the"
8 echo "the target systems using the [target] script."
9 echo
10 echo "target is an optional filename containing binary package"
11 echo "build instructions. See bmchroots, bmlocal, and"
12 echo "bmremote for more information. The filename must have"
13 echo "the word 'root' in it if you wish it to run as root."
14 echo
15 echo "You can run this multiple times at the same time, for example"
16 echo "to build both remote and chroot scripts at once."
17 echo
18 echo "Note: You may wish to direct the output to a file, for"
19 echo " later examination."
20 echo
21 echo "Example: ./release-bm.sh binary-meta.tar.bz2 bmlocal"
22 echo
23 exit 1
26 set -e
28 BUILDDIR="$1"
29 shift
31 TARBALL="$1"
32 TARBASE="$(basename "$1")"
33 shift
35 TARGETFILE="$1"
36 shift
38 while [ -n "$TARGETFILE" ] ; do
39 if echo "$TARGETFILE" | grep root > /dev/null ; then
40 # needs root
41 su - -c "export BMTARBALL=$TARBALL && \
42 export BMTARBASE=$TARBASE && \
43 export BMBUILDDIR=$BUILDDIR && \
44 export THEMODE=release && \
45 export CHOWNUSER=$(whoami) && \
46 cd $(pwd) && \
47 source $TARGETFILE"
48 else
49 export BMTARBALL=$TARBALL
50 export BMTARBASE=$TARBASE
51 export BMBUILDDIR=$BUILDDIR
52 export THEMODE=release
53 export CHOWNUSER="$(whoami)"
55 source $TARGETFILE
57 done
59 echo
60 echo "Current build directory:"
61 ls "$BUILDDIR"
62 echo
63 echo "release-bm.sh done"