Debian Codegraph @

debian/rules

raw
1 #!/usr/bin/make -f
2
3 #export DH_VERBOSE=1
4
5 # enable bindnow
6 # https://wiki.debian.org/HardeningWalkthrough
7 export DEB_BUILD_MAINT_OPTIONS = hardening=+all
8
9 # Bacula binaries break if linked with symbolic-functions
10 # https://bugs.bacula.org/view.php?id=2557
11 # Debian does not (yet) use this, but Ubuntu does. Help them out by
12 # stripping the flag from LDFLAGS
13 # https://bugs.launchpad.net/ubuntu/+source/bacula/+bug/1898006
14 export DEB_LDFLAGS_MAINT_STRIP = -Wl,-Bsymbolic-functions
15
16 # Make qtchooser select Qt5
17 export QT_SELECT=qt5
18
19 DEB_HOST_ARCH_OS ?= $(shell dpkg-architecture -qDEB_HOST_ARCH_OS)
20
21 VARIANTS := pgsql mysql sqlite3
22 VERSION := $(shell sed -n -e 's/^\#define VERSION.*"\(.*\)"$$/\1/p' src/version.h)
23
24 ######################################################################
25
26 DBC := usr/share/dbconfig-common/data/
27
28 CONF_ALL = \
29 --enable-smartalloc \
30 --with-tcp-wrappers \
31 --with-openssl \
32 --with-libiconv-prefix=/usr/include \
33 --with-readline=/usr/include/readline \
34 --disable-conio \
35 --with-libintl-prefix=/usr/include \
36 --docdir=\$${prefix}/share/doc/bacula-common \
37 --htmldir=\$${prefix}/share/doc/bacula-common/html \
38 --libdir=\$${prefix}/lib/bacula \
39 --enable-batch-insert \
40 --enable-ipv6 \
41 --with-dir-password=XXX_DIRPASSWORD_XXX \
42 --with-fd-password=XXX_FDPASSWORD_XXX \
43 --with-sd-password=XXX_SDPASSWORD_XXX \
44 --with-mon-dir-password=XXX_MONDIRPASSWORD_XXX \
45 --with-mon-fd-password=XXX_MONFDPASSWORD_XXX \
46 --with-mon-sd-password=XXX_MONSDPASSWORD_XXX \
47 --with-db-name=XXX_DBNAME_XXX \
48 --with-db-user=XXX_DBUSER_XXX \
49 --with-db-password=XXX_DBPASSWORD_XXX \
50 --with-hostname=localhost \
51 --config-cache \
52 --with-archivedir=/nonexistent/path/to/file/archive/dir \
53 --sysconfdir=/etc/bacula \
54 --with-scriptdir=/etc/bacula/scripts \
55 --sharedstatedir=/var/lib/bacula \
56 --localstatedir=/var/lib/bacula \
57 --with-logdir=/var/log/bacula \
58 --with-pid-dir=/run/bacula \
59 --with-smtp-host=localhost \
60 --with-working-dir=/var/lib/bacula \
61 --with-subsys-dir=/run/lock \
62 --with-dump-email=root \
63 --with-job-email=root \
64 --with-mysql --with-postgresql --with-sqlite3 \
65 --enable-bat --with-x \
66 --disable-s3
67
68 ifeq ($(DEB_HOST_ARCH_OS),linux)
69 # Set systemd directories, needed to properly support usr-merge
70 SYSTEMDUNITDIR = $(shell pkg-config --variable=systemdsystemunitdir systemd | sed s,^/,,)
71 TMPFILESDIR = $(shell pkg-config --variable=tmpfilesdir systemd | sed s,^/,,)
72 CONF_ALL += --with-systemd=/$(SYSTEMDUNITDIR)
73 endif
74
75 ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
76 CONF_ALL += --disable-acl --disable-xattr
77 endif
78
79 ifeq ($(DEB_HOST_ARCH_OS),hurd)
80 CONF_ALL += --disable-acl --disable-xattr
81 endif
82
83 #set to 1 if configured with systemd
84 HAVE_SYSTEMD = $(findstring 1,$(shell egrep "^\#define HAVE_SYSTEMD" config.log))
85
86 LONGNAME_mysql = mysql
87 LONGNAME_pgsql = postgresql
88 LONGNAME_sqlite3 = sqlite3
89
90 ###########################################################################
91
92 # Macro for generate file for specified database from specified template
93 # args: 1 -- template file
94 # 2 -- db type
95 # Allows for DB-type specific .in files.
96 define template-subst
97 $(shell test -f '$(subst -db.,-$(2).,$(1))' && cp '$(subst -db.,-$(2).,$(1))' '$(patsubst %.in,%,$(subst -db.,-$(2).,$(1)))')
98 sed -e 's/XX_DB_XX/$(2)/' -e 's/XX_DBLONGNAME_XX/$(LONGNAME_$(2))/' -e 's/XX_VERSION_XX/$(VERSION)/' '$(1)' >> '$(patsubst %.in,%,$(subst -db.,-$(2).,$(1)))';
99 endef
100
101 # Macro for cleanup file generated for specified database from specified template
102 # args: 1 -- template file
103 # 2 -- db type
104 define template-cleanup
105 rm -f '$(patsubst %.in,%,$(subst -db.,-$(2).,$(1)))';
106 endef
107
108 # Macro for generate from all templates files for specified database
109 # args: 1 -- db type
110 define db-templates-subst
111 $(foreach template,$(wildcard debian/*-db.*.in),$(call template-subst,$(template),$(1)))
112 endef
113
114 # Macro for cleanup all files generated for specified database from templates
115 # args: 1 -- db type
116 define db-templates-cleanup
117 $(foreach template,$(wildcard debian/*-db.*.in),$(call template-cleanup,$(template),$(1)))
118 endef
119
120 %:
121 dh $@
122
123 # For packages depending on bacula-director-DBTYPE, we handle the
124 # dependencies on that ourselves, because dpkg-shlibdeps doesn't
125 # understand the variants
126 override_dh_shlibdeps:
127 dh_shlibdeps -pbacula-bscan -pbacula-director -- -xbacula-common-mysql -xbacula-common-pgsql -xbacula-common-sqlite3
128 dh_shlibdeps -a --remaining-packages
129
130 override_dh_auto_build-arch:
131 dh_auto_build -a
132 # also build the monitoring plugin from the examples
133 make -C examples/nagios/check_bacula
134
135 override_dh_auto_install-arch:
136 dh_auto_install -a
137
138 override_dh_install-arch:
139 # sd plugins aren't installed automatically
140 # make DESTDIR=$(CURDIR)/debian/tmp -C src/stored install-aligned install-cloud
141 dh_install -a
142 # create a reference of which database type is installed on the system
143 # and create a link to the dbconfig information that is dbtype independent
144 $(foreach db,$(VARIANTS), \
145 mkdir -p debian/bacula-common-$(db)/usr/share/bacula-common; \
146 echo $(db) > debian/bacula-common-$(db)/usr/share/bacula-common/dbtype; \
147 ln -s /etc/dbconfig-common/bacula-director-$(db).conf debian/bacula-common-$(db)/usr/share/bacula-common/dbc_database.conf;)
148 ifeq ($(HAVE_SYSTEMD),1)
149 # only install systemd related files if systemd is enabled during build
150 install -m 644 platforms/systemd/bacula.conf -D debian/bacula-common/$(TMPFILESDIR)/bacula.conf
151 install -m 644 platforms/systemd/bacula-fd.service -D debian/bacula-fd/$(SYSTEMDUNITDIR)/bacula-fd.service
152 install -m 644 platforms/systemd/bacula-sd.service -D debian/bacula-sd/$(SYSTEMDUNITDIR)/bacula-sd.service
153 install -m 644 platforms/systemd/bacula-dir.service -D debian/bacula-director/$(SYSTEMDUNITDIR)/bacula-director.service
154 endif
155
156 override_dh_installexamples:
157 # The monitoring plugin in the examples needs to be cleaned, otherwise
158 # builds will not be reproducible. But only if the makefile exists,
159 # which it doesn't if we only build-indep.
160 @[ -f examples/nagios/check_bacula/Makefile ] && make -C examples/nagios/check_bacula libtool-clean distclean || true
161 dh_installexamples
162
163 override_dh_installdocs:
164 # upstream release notes should be installed as "NEWS" (Debian policy 12.7)
165 cp -a ReleaseNotes NEWS
166 dh_installdocs -pbacula --link-doc=bacula-server
167 dh_installdocs -Nbacula-common -Nbacula-client -Nbacula-server -Nbacula-director-mysql -Nbacula-director-sqlite3 -Nbacula-director-pgsql --remaining-packages --link-doc=bacula-common
168 dh_installdocs --remaining-packages
169
170 # We only need the scripts from src/cats for the arch:all packages.
171 # Compiling and installing is easier than picking out the scripts to
172 # install manually
173 override_dh_auto_build-indep:
174 make DESTDIR=$(CURDIR)/debian/tmp -C src/cats
175 override_dh_auto_install-indep:
176 mkdir -p debian/tmp/etc/bacula/scripts
177 make DESTDIR=$(CURDIR)/debian/tmp -C src/cats install
178 ######### dbconfig-common stuff
179 # The script install-dbconfig needs to be adapted when upstream changes the database format!
180 debian/scripts/install-dbconfig # handles install of all upgrade/install scripts to db version 11 and greater
181
182 override_dh_autoreconf:
183 # save the original files if not already saved
184 @[ -f configure -a ! -f debian/configure.dh_autoreconf.save ] && mv configure debian/configure.dh_autoreconf.save || true
185 @[ -f autoconf/aclocal.m4 -a ! -f debian/aclocal.m4.dh_autoreconf.save ] && mv autoconf/aclocal.m4 debian/aclocal.m4.dh_autoreconf.save || true
186 dh_autoreconf debian/autogen.sh
187
188 override_dh_autoreconf_clean:
189 dh_autoreconf_clean
190 # restore the original files if saved
191 @[ -f debian/configure.dh_autoreconf.save ] && mv debian/configure.dh_autoreconf.save configure || true
192 @[ -f debian/aclocal.m4.dh_autoreconf.save ] && mv debian/aclocal.m4.dh_autoreconf.save autoconf/aclocal.m4 || true
193
194 override_dh_auto_configure:
195 $(foreach db,$(VARIANTS),$(call db-templates-subst,$(db)))
196 # Strange workaround for strange binary path problems in Qt5.9
197 # https://gitweb.gentoo.org/repo/gentoo.git/tree/app-backup/bacula/bacula-9.0.6-r2.ebuild?id=9b8f311cb9d88f02bebc4bfb51282db4457f87d7#n166
198 mkdir -p src/qt-console/.libs
199 touch src/qt-console/.libs/bat
200 chmod 755 src/qt-console/.libs/bat
201 #
202 mkdir -p src/qt-console/tray-monitor/.libs
203 touch src/qt-console/tray-monitor/.libs/bacula-tray-monitor
204 chmod 755 src/qt-console/tray-monitor/.libs/bacula-tray-monitor
205 #
206 dh_auto_configure -- $(CONF_ALL)
207 debian/scripts/generate-doc-dir-to-symlink-migration create
208 debian/scripts/autopostrm create
209
210 override_dh_makeshlibs:
211 dh_makeshlibs -n -Xbpipe-fd.so
212 # fix shlibs for bacula-common-*
213 $(foreach db,$(VARIANTS), sed -i 's/libbaccats-[a-z0-9]*/libbaccats/' debian/bacula-common-$(db)/DEBIAN/shlibs;)
214
215 override_dh_clean:
216 $(foreach db,$(VARIANTS),$(call db-templates-cleanup,$(db)))
217 dh_clean
218 debian/scripts/generate-doc-dir-to-symlink-migration clean
219 debian/scripts/autopostrm clean
220 rm -f NEWS
221
222 override_dh_auto_test: