Imported Upstream version 2.6.0p1
[debian/amanda] / packaging / rpm / buildpkg
1 #!/bin/bash
2 # Buildpkg script for producing RPM packages. Does not require root access.
3
4 # This is useful for debugging
5 set -x
6 # Buildbot exports some useful env variables.
7 # Check for $AMVER.  I couldn't come up with a good way to detect it.
8 if [ -z $AMVER ]; then
9     AMVER=amanda-2.6.0p1
10 fi
11 # Check for AMTARBALL variable.
12 if [ -z $AMTARBALL ]; then 
13     AMTARBALL=$AMVER.tar.gz
14 fi
15
16 # Check for AMTARBALL file, if it's not there, create it.
17 if [ ! -f ${AMTARBALL} ]; then
18     mkdir ${AMVER}
19     cp -Rfp * ${AMVER}/
20     tar -cf ${AMTARBALL} -z ${AMVER}
21     rm -rf ${AMVER}
22 fi
23
24 # Check for the packaging dirs.
25 if [ -z $AMPKGDIR ]; then
26     AMPKGDIR=${PWD}
27 fi
28 if [ ! -d ${AMPKGDIR} ]; then
29     mkdir ${AMPKGDIR}
30 fi
31 cd ${AMPKGDIR}
32
33 if [ -d rpm ]; then
34     rm -rf rpm
35 fi
36 mkdir rpm
37 mkdir rpm/SOURCES
38 mkdir rpm/SRPMS
39 mkdir rpm/SPECS
40 mkdir rpm/BUILD
41 mkdir rpm/RPMS
42
43 # Make a copy of the tarball with the name that rpmbuild expects
44 cp ${AMTARBALL} rpm/SOURCES/${AMVER}.tar.gz
45 cp packaging/rpm/amanda.spec rpm/SPECS/amanda.spec
46 # Rpmbuild requires absolute paths.  annoying.  If you need to change the 
47 # default value of some rpm.spec variable, just pass extra --define options.
48 # this is useful for changing %amanda_release or %amanda_version
49 rpmbuild -ba --define "_topdir ${AMPKGDIR}/rpm" \
50              ${AMPKGDIR}/rpm/SPECS/amanda.spec