c96a6796c1f73e6242876925b784d039c56ec043
[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="/tmp/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 if [ -z $AMVER ]
51 then
52     AMVER=amanda-2.6.1p2
53 fi
54
55 if [ -z $AMTARBALL ]
56 then
57     AMTARBALL=$AMVER.tar.gz
58 fi
59
60 #### Build functions
61
62 do_build() {
63
64     echo "Running configure"
65     ./configure --quiet \
66         --prefix=${PREFIX} \
67         --bindir=${BINDIR} \
68         --sbindir=${SBINDIR} \
69         --mandir=${MANDIR} \
70         --libexecdir=${LIBEXECDIR} \
71         --sysconfdir=${SYSCONFDIR} \
72         --localstatedir=${LOCALSTATEDIR} \
73         --with-star=/bin/star \
74         --with-gnutar=/bin/tar \
75         --with-gnutar-listdir=${AMANDAHOMEDIR}/gnutar-lists \
76         --with-index-server=localhost \
77         --with-tape-server=localhost \
78         --with-user=${amanda_user} \
79         --with-group=${amanda_group} \
80         --with-owner=${amanda_user} \
81         --with-fqdn \
82         --with-bsd-security \
83         --with-bsdtcp-security \
84         --with-bsdudp-security \
85         --with-amandahosts \
86         --with-smbclient=/usr/bin/smbclient \
87         --with-ssh-security \
88         --with-udpportrange=${udpportrange} \
89         --with-tcpportrange=${tcpportrange} \
90         --with-low-tcpportrange=${low_tcpportrange} \
91         --with-debugging=${LOGDIR} \
92         --disable-installperms \
93         --enable-s3-device \
94         --with-assertions \
95         || exit 1
96
97 }
98
99 do_resources() {
100     # Setup directories and files as dpkg-buildpkg expects.
101     if [ -d debian ]; then
102         rm -rf debian
103     fi
104     cp -Rf packaging/deb debian
105     if [ -d $AMVER ]; then
106         rm -rf $AMVER
107     fi
108     mkdir $AMVER
109     cp -Rfp * $AMVER
110 }
111
112 do_package() {
113
114     echo "Building package"
115     cd $AMVER
116     # Create unsigned packages
117     dpkg-buildpackage -rfakeroot -uc -us
118 }
119
120
121 do_all() {
122     do_build $1
123     do_resources $1
124     do_package $1
125 }
126
127 do_resources
128 do_package