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