Imported Upstream version 3.3.2
[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 # Until we get package revisioning in community.
44 [ -f "PKG_REV" ] || echo "1" > PKG_REV
45
46 #### Build functions
47
48 do_substitute() {
49     # We need to edit packaging/deb/changelog to reflect our current distro
50     # and release.  This can't be done within the debian packaging system;
51     # dpkg assumes that packages will have the same name on all releases and
52     # that apt will prevent users from downloading the wrong build.  We want
53     # this information helpfully obvious since we can't rely on apt.
54     file_list="packaging/deb/changelog \
55         packaging/deb/postinst \
56         packaging/deb/postrm \
57         packaging/deb/preinst"
58     for file in ${file_list}; do
59         /usr/bin/perl packaging/common/substitute.pl \
60             ${file}.src ${file} || exit 1
61     done
62 }
63
64 do_resources() {
65     # Setup directories and files as dpkg-buildpkg expects.
66     if [ -d debian ]; then
67         rm -rf debian
68     fi
69     cp -Rf packaging/deb debian
70     if [ -d $BUILDDIR ]; then
71         rm -rf $BUILDDIR
72     fi
73     mkdir -p $BUILDDIR
74     cp -Rfp * $BUILDDIR
75 }
76
77 do_package() {
78
79     echo "Building package"
80     cd $BUILDDIR
81     # Create unsigned packages
82     dpkg-buildpackage -rfakeroot -uc -us
83 }
84
85 do_substitute
86 do_resources
87 do_package