516d1d96bb1247557376e78a58eb67eaae72c83f
[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     /usr/bin/perl packaging/common/substitute.pl packaging/deb/changelog.src packaging/deb/changelog
55 }
56
57 do_resources() {
58     # Setup directories and files as dpkg-buildpkg expects.
59     if [ -d debian ]; then
60         rm -rf debian
61     fi
62     cp -Rf packaging/deb debian
63     if [ -d $BUILDDIR ]; then
64         rm -rf $BUILDDIR
65     fi
66     mkdir -p $BUILDDIR
67     cp -Rfp * $BUILDDIR
68 }
69
70 do_package() {
71
72     echo "Building package"
73     cd $BUILDDIR
74     # Create unsigned packages
75     dpkg-buildpackage -rfakeroot -uc -us
76 }
77
78 do_substitute
79 do_resources
80 do_package