Imported Upstream version 3.2.0
[debian/amanda] / packaging / deb / buildpkg
1 #! /bin/bash
2 set -x
3 #### Configure variables.  Feel free to change these, but be careful!
4 SRCDIR=$PWD
5 # You can pass your own temp directory as an environment variable.
6 # This prefix is prepended to all directories during "make install" 
7 FAKEROOT="${SRCDIR}/froot"
8 # Configure and Compilation directory.
9 BUILDDIR="${SRCDIR}/build"
10 # Config variables to mirror those in RPM .spec file
11 amanda_user=amandabackup
12 amanda_group=admin
13 PREFIX="/usr"
14 EPREFIX="${PREFIX}"
15 BINDIR="${EPREFIX}/bin"
16 SBINDIR="${EPREFIX}/sbin"
17 LIBEXECDIR="${EPREFIX}/lib/amanda"
18 DATADIR="${PREFIX}/share"
19 SYSCONFDIR="/etc"
20 LOCALSTATEDIR="/var"
21 AMANDAHOMEDIR="${LOCALSTATEDIR}/lib/amanda"
22 LIBDIR="${EPREFIX}/lib"
23 INCLUDEDIR="${PREFIX}/include"
24 INFODIR="${PREFIX}/info"
25 MANDIR="${DATADIR}/man"
26 LOGDIR="${LOCALSTATEDIR}/log/amanda"                  
27
28 #### CHECKS
29
30 if [ ! -f common-src/amanda.h ]
31 then
32     echo "'buildpkg' must be run from the root of an otherwise unused amanda source directory." >&2
33     exit 1
34 fi
35
36 if [ ! -f configure ]
37 then
38     echo "The source directory has not been autogen'd -- please download a source distribution tarball or run ./autogen."
39     echo "You will need autoconf, automake, and libtool to run autogen (but not to compile from a distribution tarball)."
40     exit 1
41 fi
42
43 #### Build functions
44
45 do_substitute() {
46     # We need to edit packaging/deb/changelog to reflect our current distro
47     # and release.  This can't be done within the debian packaging system;
48     # dpkg assumes that packages will have the same name on all releases and
49     # that apt will prevent users from downloading the wrong build.  We want
50     # this information helpfully obvious since we can't rely on apt.
51     /usr/bin/perl packaging/common/substitute.pl packaging/deb/changelog.src packaging/deb/changelog
52 }
53
54 do_resources() {
55     # Setup directories and files as dpkg-buildpkg expects.
56     if [ -d debian ]; then
57         rm -rf debian
58     fi
59     cp -Rf packaging/deb debian
60     if [ -d $BUILDDIR ]; then
61         rm -rf $BUILDDIR
62     fi
63     mkdir -p $BUILDDIR
64     cp -Rfp * $BUILDDIR
65 }
66
67 do_package() {
68
69     echo "Building package"
70     cd $BUILDDIR
71     # Create unsigned packages
72     dpkg-buildpackage -rfakeroot -uc -us
73 }
74
75 do_substitute
76 do_resources
77 do_package