tzwrapper.cc: fixed use of iterator after erase
[barry.git] / maintainer / make-bm-rpm.sh
blob03efc50b27d758063968521bdacfd90e5fa2b2af
1 #!/bin/bash
3 if [ -z "$1" -o -z "$2" -o -z "$3" -o -z "$4" ] ; then
4 echo
5 echo "Usage: ./make-rpm.sh tarball rpm_args build_dir results_dir"
6 echo
7 echo "<build_dir>/rpmbuild is the RPM tree where the build will"
8 echo "take place. If rpmbuild does not exist, but SPECS does, then"
9 echo "it is assumed build_dir == the rpmbuild dir. This is useful"
10 echo "in the (hopefully) rare occasions where you need to build in"
11 echo "/usr/src."
12 echo
13 echo "tarball is the full pathname of the tarball to extract."
14 echo "It is allowed to be relative to the current directory."
15 echo "It will be copied to rpmbuild/SOURCES, and the entire tar tree"
16 echo "will be extracted into <builddir>/binarybuild,"
17 echo "in order to fetch the spec file."
18 echo
19 echo "rpm_args is the full command line to build the package."
20 echo
21 echo "<results_dir>/results/ is where the resulting RPM and SRC RPM"
22 echo "packages will be copied."
23 echo
24 exit 1
27 TARBALL="$1"
28 RPMTARGETS="$2"
29 RPMPATH="$3"
30 if [ -d "$RPMPATH/rpmbuild/SPECS" ] ; then
31 RPMPATH="$3/rpmbuild"
33 BUILDPATH="$RPMPATH/binarybuild"
34 DESTPATH="$4/results"
36 set -e
39 # Note that all commands below are done from the current directory.
40 # Where the directory must change, it is done within brackets so that
41 # we return to the current directory immediately afterward.
43 # This is so that all paths and directories given on the command line
44 # may be relative, and everything still works.
47 # setup directories
48 rm -rf "$BUILDPATH"
49 mkdir -p "$BUILDPATH"
50 rm -rf "$DESTPATH"
51 mkdir -p "$DESTPATH"
52 rm -f "$RPMPATH"/RPMS/*/* "$RPMPATH"/SRPMS/*
54 # expand source
55 tar -C "$BUILDPATH" -xjvf "$TARBALL"
57 # build binary packages
58 if ! (cd "$BUILDPATH"/* && eval $RPMTARGETS) ; then
59 echo "bm-RPM build failed"
60 exit 1
63 # move results to destination directory
64 mv $(find "$RPMPATH" -type f -name "*.rpm" -print) "$DESTPATH"