1d75bbed5ea1022b5c5f9aed109538a1b8f628f5
[debian/amanda] / packaging / deb / rules
1 #!/usr/bin/make -f
2 # debian/rules for amanda using debhelper. GNU copyright 2008 by Dan Locks, 
3 # based on work by Bdale Garbee.
4
5 #       Warning - do *not* use -j on an SMP machine, or the build gets
6 #               confused... some sort of race condition in the makefiles?
7
8 # Uncomment this to turn on verbose mode.
9 #export DH_VERBOSE=1
10 AMVER=3.2alpha
11
12 # These are variables that the user can override.  They get used in various
13 # places during configure, build, and install.
14 PREFIX=/usr
15 BINDIR=$(PREFIX)/bin
16 LIBDIR=$(PREFIX)/lib
17 AMLIBDIR=$(LIBDIR)/amanda
18 LIBEXECDIR=$(PREFIX)/libexec
19 AMLIBEXECDIR=$(LIBEXECDIR)/amanda
20 MANDIR=$(PREFIX)/share/man
21 DOCDIR=$(PREFIX)/share/doc
22 SYSCONFDIR=/etc
23 LOCALSTATEDIR=/var
24 AMANDAHOMEDIR=$(LOCALSTATEDIR)/lib/amanda
25 LOGDIR=$(LOCALSTATEDIR)/log/amanda
26 # Extract the perl site_lib directory.  This is used to install amanda's perl 
27 # libs. If configure finds a different install or you specify a different path using
28 # --with-amperldir= make sure you change this variable as well.
29 PERLSITELIB=$(shell perl -V:installsitelib|sed -e"s:installsitelib='/::;s:'\;::")
30 AMANDAUSER=amandabackup
31 AMANDAGROUP=disk
32 WITHOUT_SERVER="False"
33 WITHOUT_CLIENT="False"
34
35 r=$(shell pwd)/debian/tmp
36 server=$(shell pwd)/debian/amanda-backup-server
37 client=$(shell pwd)/debian/amanda-backup-client
38
39 log=$(shell pwd)/debian/dpkg.log
40
41 # These are used for cross-compiling and for saving the configure script
42 # from having to guess our platform (since we know it already)
43 DEB_HOST_GNU_TYPE   ?= $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
44 DEB_BUILD_GNU_TYPE  ?= $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
45
46 WD=$(shell pwd)
47
48 build: build-stamp 
49 build-stamp: /sbin/dump /usr/bin/smbclient 
50         dh_testdir
51         ./configure \
52                 MAKEFLAGS="-j1 " \
53                 CFLAGS="-pipe " \
54                 MAILER=/usr/bin/mail \
55                 --enable-as-needed \
56                 --quiet \
57                 --host=$(DEB_HOST_GNU_TYPE) \
58                 --build=$(DEB_BUILD_GNU_TYPE) \
59                 --prefix=$(PREFIX) \
60                 --bindir=$(BINDIR) \
61                 --mandir=$(MANDIR) \
62                 --libexecdir=$(LIBEXECDIR) \
63                 --enable-shared \
64                 --sysconfdir=$(SYSCONFDIR) \
65                 --localstatedir=$(LOCALSTATEDIR) \
66                 --with-amdatadir=$(AMANDAHOMEDIR) \
67                 --with-gnutar-listdir=$(AMANDAHOMEDIR)/gnutar-lists \
68                 --with-index-server=localhost \
69                 --with-tape-server=localhost \
70                 --with-user=$(AMANDAUSER) \
71                 --with-group=$(AMANDAGROUP) \
72                 --with-fqdn \
73                 --with-bsd-security \
74                 --with-bsdtcp-security \
75                 --with-bsdudp-security \
76                 --with-amandahosts \
77                 --with-smbclient=$(BINDIR)/smbclient \
78                 --with-debugging=$(LOGDIR) \
79                 --with-ssh-security \
80                 --with-assertions \
81                 --enable-s3-device \
82                 --disable-installperms
83         touch missing
84         # There's probably a better way to do this.  Preinst and postrm are the
85         # same for client and server, but we leave room for differences by just
86         # appending here.
87         cat $(WD)/debian/preinst >> $(WD)/debian/amanda-backup-client.preinst
88         cat $(WD)/debian/preinst >> $(WD)/debian/amanda-backup-server.preinst
89         cat $(WD)/debian/postrm >> $(WD)/debian/amanda-backup-client.postrm
90         cat $(WD)/debian/postrm >> $(WD)/debian/amanda-backup-server.postrm
91         make -s LIBTOOLFLAGS=--silent
92         touch build-stamp
93
94 clean:
95         dh_testdir >> $(log) 2>&1
96         dh_testroot >> $(log) 2>&1
97         -make -s LIBTOOLFLAGS=--silent clean
98         -make -s LIBTOOLFLAGS=--silent distclean
99         -rm -f build-stamp missing config/config.h common-src/genversion
100         -find . -type d -name .deps -exec rm -rf {} \;
101         -test -r /usr/share/misc/config.sub && \
102                 cp -f /usr/share/misc/config.sub config/config.sub
103         -test -r /usr/share/misc/config.guess && \
104                 cp -f /usr/share/misc/config.guess config/config.guess
105         dh_clean >> $(log) 2>&1
106
107 # Build architecture-dependent files here.
108 binary-arch: build
109         echo "---->dh_testdir: " >> $(log)
110         dh_testdir >> $(log) 2>&1
111         echo "---->dh_testroot: " >> $(log)
112         dh_testroot >> $(log) 2>&1
113         echo "---->dh_clean: " >> $(log)
114         dh_clean -k >> $(log) 2>&1
115         echo "---->dh_installdirs: " >> $(log)
116         dh_installdirs -v >> $(log) 2>&1
117         make -s LIBTOOLFLAGS=--silent install DESTDIR=$(r)
118         echo "---->dh_installdocs: " >> $(log)
119         dh_installdocs -v >> $(log) 2>&1
120         install -d $(r)/$(DOCDIR)/amanda-common/examples
121         cp -a example/* $(r)/$(DOCDIR)/amanda-common/examples
122         cp ChangeLog $(r)/$(DOCDIR)/amanda-common/changelog
123         echo "---->dh_installchangelogs: " >> $(log)
124         dh_installchangelogs -v >> $(log) 2>&1
125         # Here's how we get the perl modules installed into sitelib
126         echo $(PERLSITELIB)/* >> debian/amanda-backup-server.install
127         echo "---->dh_install -v --fail-missing: " >> $(log)
128         dh_install -v --sourcedir=$(r) >> $(log) 2>&1
129         echo "---->dh_strip: " >> $(log)
130         dh_strip >> $(log) 2>&1
131         echo "---->dh_compress: " >> $(log)
132         dh_compress >> $(log) 2>&1
133         echo "---->dh_fixperms: " >> $(log)
134         dh_fixperms -v >> $(log) 2>&1
135         # fix perms manually
136         chown -R $(AMANDAUSER):$(AMANDAGROUP) debian/*/var/lib/*
137         #chmod -R u=rwX,g=rwX,o-rwx debian/*/var/lib/*
138         chown -R $(AMANDAUSER):$(AMANDAGROUP) $(client)/$(LOGDIR) $(server)/$(LOGDIR)
139         #chmod -R u=rwX,g=rwX,o-rwx $(server)/$(LOGDIR)
140         chown -R $(AMANDAUSER):$(AMANDAGROUP)  $(client)/$(SYSCONFDIR)/amanda $(server)/$(SYSCONFDIR)/amanda
141         chmod -R u=rwX,g=rwX,o-rwx $(client)/$(SYSCONFDIR)/amanda
142         chmod -R u=rwX,g=rwX,o-rwx $(server)/$(SYSCONFDIR)/amanda
143         chown -R $(AMANDAUSER):$(AMANDAGROUP) $(client)/$(AMANDAHOMEDIR)/gnutar-lists $(server)/$(AMANDAHOMEDIR)/gnutar-lists
144         chmod -R u=rwX,g=rwX,o-rwx  $(client)/$(AMANDAHOMEDIR)/gnutar-lists $(server)/$(AMANDAHOMEDIR)/gnutar-lists
145         # .. setuid
146         chown root:disk \
147                 $(client)/$(AMLIBEXECDIR)/application/amgtar \
148                 $(client)/$(AMLIBEXECDIR)/application/amstar \
149                 $(client)/$(AMLIBEXECDIR)/killpgrp \
150                 $(client)/$(AMLIBEXECDIR)/rundump \
151                 $(client)/$(AMLIBEXECDIR)/runtar \
152                 $(client)/$(AMLIBEXECDIR)/calcsize \
153                 $(server)/$(AMLIBEXECDIR)/application/amgtar \
154                 $(server)/$(AMLIBEXECDIR)/application/amstar \
155                 $(server)/$(AMLIBEXECDIR)/killpgrp \
156                 $(server)/$(AMLIBEXECDIR)/rundump \
157                 $(server)/$(AMLIBEXECDIR)/runtar \
158                 $(server)/$(AMLIBEXECDIR)/calcsize \
159                 $(server)/$(AMLIBEXECDIR)/dumper \
160                 $(server)/$(AMLIBEXECDIR)/planner \
161                 $(server)/usr/sbin/amcheck \
162                 $(server)/usr/sbin/amservice
163         chmod u=srwx,g=rx,o=r \
164                 $(client)/$(AMLIBEXECDIR)/application/amgtar \
165                 $(client)/$(AMLIBEXECDIR)/application/amstar \
166                 $(client)$(AMLIBEXECDIR)/killpgrp \
167                 $(client)$(AMLIBEXECDIR)/rundump \
168                 $(client)$(AMLIBEXECDIR)/runtar \
169                 $(client)$(AMLIBEXECDIR)/calcsize \
170                 $(server)/$(AMLIBEXECDIR)/application/amgtar \
171                 $(server)/$(AMLIBEXECDIR)/application/amstar \
172                 $(server)$(AMLIBEXECDIR)/killpgrp \
173                 $(server)$(AMLIBEXECDIR)/rundump \
174                 $(server)$(AMLIBEXECDIR)/runtar \
175                 $(server)$(AMLIBEXECDIR)/calcsize \
176                 $(server)$(AMLIBEXECDIR)/dumper \
177                 $(server)$(AMLIBEXECDIR)/planner \
178                 $(server)/usr/sbin/amcheck \
179                 $(server)/usr/sbin/amservice
180         echo "Amanda version $(AMVER)" >  $(server)/$(AMANDAHOMEDIR)/amanda-release 
181         echo "Amanda version $(AMVER)" >  $(client)/$(AMANDAHOMEDIR)/amanda-release 
182         install -o root -g root -m 0644 debian/amanda-backup-client.lintian \
183                 $(client)/usr/share/lintian/overrides/amanda-backup-client
184         install -o root -g root -m 0644 debian/amanda-backup-server.lintian \
185                 $(server)/usr/share/lintian/overrides/amanda-backup-server
186         dh_makeshlibs  >> $(log) 2>&1
187         dh_perl >> $(log) 2>&1
188         dh_shlibdeps -l"$(r)/usr/lib:$(client)/usr/lib:$(server)/usr/lib" >> $(log) 2>&1
189         dh_installdeb >> $(log) 2>&1
190         dh_gencontrol >> $(log) 2>&1
191         dh_md5sums  >> $(log) 2>&1
192         dh_builddeb  >> $(log) 2>&1
193
194 source diff:                                                                  
195         @echo >&2 'source and diff are obsolete - use dpkg-source -b'; false
196
197 binary: binary-arch
198 .PHONY: build clean binary-arch binary