Imported Upstream version 2.6.1
[debian/amanda] / packaging / rpm / buildpkg
index 6361d140ae15049bcedbeb51152a5f57bf1676ec..d2b39341631cd0d182ee815bb26958ff43188cf9 100755 (executable)
@@ -1,13 +1,35 @@
 #!/bin/bash
-# Buildpkg script for producing RPM packages. Does not require root access.
+
+# Buildpkg script for producing RPM packages. (Does not require root access.)
+# Buildpkg is designed to be used by both buildbot (to automate rpm production)
+# and by J Random User (to build an rpm for kicks).  The odd way of handling
+# all optioins through environment variables is a product of buildbot.
+#
+# AMVER: the version of amanda we're working on.  This will become part of the
+#     rpm name.  AMVER must line up with the version number mentioned in the
+#     .spec file.
+# AMTARBALL: the name of the tarball which contains the source code.  it must
+#     unpack into a directory named AMVER.  It's easiest and safest to just 
+#     let the script create a new one for you, even if it's a bit more overhead
+# AMPKGDIR: Rpmbuild expects absolute paths, so we provide this var.  It also
+#     allows you to build somewhere other than `pwd`.  You probably don't want
+#     to use the system-wide location, as the script tries to blow these
+#     directories away.
+# 
+# Other Hints:
+# Not everyone will want to use the ./configure options we provide.  The
+# easiest way to change them is by editing the .spec file.  This isn't so
+# easy, unfortunately.  Look at the %build section, and the %define xxxx 
+# statements immediately above it. good luck.
 
 # This is useful for debugging
 set -x
 # Buildbot exports some useful env variables.
 # Check for $AMVER.  I couldn't come up with a good way to detect it.
 if [ -z $AMVER ]; then
-    AMVER=amanda-2.6.0p2
+    AMVER=amanda-2.6.1
 fi
+
 # Check for AMTARBALL variable.
 if [ -z $AMTARBALL ]; then 
     AMTARBALL=$AMVER.tar.gz
@@ -17,7 +39,7 @@ fi
 if [ ! -f ${AMTARBALL} ]; then
     mkdir ${AMVER}
     cp -Rfp * ${AMVER}/
-    tar -cf ${AMTARBALL} -z ${AMVER}
+    tar -cf ${AMTARBALL} -z ${AMVER} || exit 1
     rm -rf ${AMVER}
 fi
 
@@ -26,27 +48,27 @@ if [ -z $AMPKGDIR ]; then
     AMPKGDIR=${PWD}
 fi
 if [ ! -d ${AMPKGDIR} ]; then
-    mkdir ${AMPKGDIR}
+    mkdir ${AMPKGDIR} || exit 1
 fi
 cd ${AMPKGDIR}
 
 if [ -d rpm ]; then
-    rm -rf rpm
+    rm -rf rpm || exit 1
 fi
 mkdir rpm
 mkdir rpm/SOURCES
 mkdir rpm/SRPMS
 mkdir rpm/SPECS
 mkdir rpm/BUILD
-mkdir rpm/RPMS
+mkdir rpm/RPMS || exit 1
 
 # Make a copy of the tarball with the name that rpmbuild expects
-cp ${AMTARBALL} rpm/SOURCES/${AMVER}.tar.gz
-cp packaging/rpm/amanda.spec rpm/SPECS/amanda.spec
+cp ${AMTARBALL} rpm/SOURCES/${AMVER}.tar.gz || exit 1
+cp packaging/rpm/amanda.spec rpm/SPECS || exit 1
 # Rpmbuild requires absolute paths.  annoying.  If you need to change the 
 # default value of some rpm.spec variable, just pass extra --define options.
 # this is useful for changing %amanda_release or %amanda_version
 rpmbuild -ba --define "_topdir ${AMPKGDIR}/rpm" \
-             ${AMPKGDIR}/rpm/SPECS/amanda.spec 
+             ${AMPKGDIR}/rpm/SPECS/amanda.spec || exit 1
 cp rpm/RPMS/*/*.rpm . || exit 1
 cp rpm/SRPMS/*.rpm . || exit 1