1#!/usr/bin/make -f
2# -*- makefile -*-
3#
4# Sample debian/rules that uses debhelper.
5#
6# This file was originally written by Joey Hess and Craig Small.
7# As a special exception, when this file is copied by dh-make into a
8# dh-make output file, you may use that output file without restriction.
9# This special exception was added by Craig Small in version 0.37 of dh-make.
10#
11# Modified to make a template file for a multi-binary package with separated
12# build-arch and build-indep targets  by Bill Allombert 2001
13
14# Uncomment this to turn on verbose mode.
15DH_VERBOSE = 1
16
17# This has to be exported to make some magic below work.
18DH_OPTIONS = -v
19
20
21
22
23DAEMON_USER = bareos
24DAEMON_GROUP = bareos
25DIRECTOR_DAEMON_USER = $(DAEMON_USER)
26STORAGE_DAEMON_USER = $(DAEMON_USER)
27FILE_DAEMON_USER = root
28STORAGE_DAEMON_GROUP = $(DAEMON_GROUP)
29BAREOS_VERSION := $(shell dpkg-parsechangelog | egrep '^Version:' | sed 's/Version: //g')
30
31define CONFIGURE_COMMON
32  -DDEBUG_PREFIX_MAP:BOOL=OFF \
33  -Dsbin-perm=755 \
34  -Dsbindir=/usr/sbin \
35  -Dbindir=/usr/bin \
36  -Dlibdir=/usr/lib/bareos \
37  -Dsysconfdir=/etc \
38  -Dconfdir=/etc/bareos \
39  -Darchivedir=/var/lib/bareos/storage \
40  -Dbackenddir=/usr/lib/bareos/backends \
41  -Dconfigtemplatedir=/usr/lib/bareos/defaultconfigs \
42  -Dscriptdir=/usr/lib/bareos/scripts \
43  -Dplugindir=/usr/lib/bareos/plugins \
44  -Dworkingdir=/var/lib/bareos \
45  -Dpiddir=/var/lib/bareos \
46  -Dbsrdir=/var/lib/bareos \
47  -Dlogdir=/var/log/bareos \
48  -Dsubsysdir=/var/lock \
49  -Dreadline=yes \
50  -Dbatch-insert=yes \
51  -Ddynamic-debian-package-list=yes\
52  -Ddynamic-cats-backends=yes \
53  -Ddynamic-storage-backends=yes \
54  -Dscsi-crypto=yes \
55  -Dlmdb=yes \
56  -Dndmp=yes \
57  -Dipv6=yes \
58  -Dacl=yes \
59  -Dxattr=yes \
60  -Dpostgresql=yes \
61  -Dmysql=yes \
62  -Dsqlite3=yes \
63  -Dopenssl=yes \
64  -Ddir-user=$(DIRECTOR_DAEMON_USER) \
65  -Ddir-group=$(DAEMON_GROUP) \
66  -Dsd-user=$(STORAGE_DAEMON_USER) \
67  -Dsd-group=$(STORAGE_DAEMON_GROUP) \
68  -Dfd-user=$(FILE_DAEMON_USER) \
69  -Dfd-group=$(DAEMON_GROUP) \
70  -Ddir-password="XXX_REPLACE_WITH_DIRECTOR_PASSWORD_XXX" \
71  -Dfd-password="XXX_REPLACE_WITH_CLIENT_PASSWORD_XXX" \
72  -Dsd-password="XXX_REPLACE_WITH_STORAGE_PASSWORD_XXX" \
73  -Dmon-dir-password="XXX_REPLACE_WITH_DIRECTOR_MONITOR_PASSWORD_XXX" \
74  -Dmon-fd-password="XXX_REPLACE_WITH_CLIENT_MONITOR_PASSWORD_XXX" \
75  -Dmon-sd-password="XXX_REPLACE_WITH_STORAGE_MONITOR_PASSWORD_XXX" \
76  -Dbasename="XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX" \
77  -Dhostname="XXX_REPLACE_WITH_LOCAL_HOSTNAME_XXX" \
78  -Dincludes=yes \
79  -Drpath=no \
80  -Ddefault_db_backend="XXX_REPLACE_WITH_DATABASE_DRIVER_XXX" \
81  -DVERSION_STRING=$(BAREOS_VERSION)
82endef
83
84#  --docdir="\$(_docdir)/bareos" \
85#  --htmldir="\$(_docdir)/bareos/html" \
86
87ifeq ($(DEB_HOST_ARCH_OS),kfreebsd)
88CONFIGURE_COMMON       += -Dacl=no -Dxattr=no -Dscsi-crypto=no -Dndmp=no
89endif
90ifeq ($(DEB_HOST_ARCH_OS),hurd)
91CONFIGURE_COMMON       += -Dscsi-crypto=no -Dndmp=no
92endif
93CONFIGURE_CLIENT_ONLY = $(CONFIGURE_COMMON) -Dclient-only=yes
94CONFIGURE_FULL        = $(CONFIGURE_COMMON) -Dpython=yes -Dtraymonitor=yes -DSHARE_INSTALL_PREFIX:PATH=/usr/share -Dwebuiconfdir=/etc/bareos-webui
95
96override_dh_auto_configure:
97	@if [ "`lsb_release --short  --id`" = "Ubuntu" ] && [ "`lsb_release --short  --release`" = "8.04" ]; then \
98		echo "configure common configuration"; \
99		dh_auto_configure -- $(CONFIGURE_COMMON); \
100	else \
101		echo "configure full configuration"; \
102		dh_auto_configure -- $(CONFIGURE_FULL); \
103	fi
104
105override_dh_fixperms:
106	# all files in /etc/bareos
107	dh_fixperms \
108		--exclude etc/bareos/ \
109		--exclude var/lib/bareos/ \
110		--exclude var/log/bareos/
111
112override_dh_strip:
113	dh_strip --dbg-package=bareos-dbg
114
115override_dh_install:
116	chrpath -d $(CURDIR)/debian/tmp/usr/lib/bareos/backends/libbareoscats-mysql* \
117		$(CURDIR)/debian/tmp/usr/lib/bareos/backends/libbareoscats-postgresql* \
118		$(CURDIR)/debian/tmp/usr/lib/bareos/backends/libbareoscats-sqlite3*
119	dh_install
120
121override_dh_installinit:
122	dh_installinit --package=bareos-director   --name=bareos-dir --no-start
123	dh_installinit --package=bareos-storage    --name=bareos-sd  --no-start
124	dh_installinit --package=bareos-filedaemon --name=bareos-fd
125
126override_dh_makeshlibs:
127	dh_makeshlibs -n
128
129
130override_dh_auto_test:
131# Only run tests,
132# if DEB_BUILD_OPTIONS does not contain nocheck,
133# see https://www.debian.org/doc/debian-policy/ch-source.html#s-debianrules-options
134# No tabs allowed before ifeq.
135ifneq (nocheck,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
136	cd obj-$(DEB_BUILD_GNU_TYPE) && ls Testing/*/Test.xml || REGRESS_DEBUG=1 ctest -V -S CTestScript.cmake || echo "ctest result:$?"
137else
138	@echo "ctest: skipped"
139endif
140
141
142override_dh_shlibdeps:
143	dh_shlibdeps -l$(shell pwd)/debian/tmp/usr/lib/bareos
144
145
146%:
147	PARALLEL="--parallel"; \
148	if [ "`lsb_release --short  --id`" = "Ubuntu" ] && [ "`lsb_release --short  --release`" = "8.04" ]; then PARALLEL=""; fi; \
149	if dh --list | grep -q systemd; then WITH="--with"; SYSTEMD="systemd"; fi; \
150	dh $@ $$PARALLEL $$WITH $$SYSTEMD
151
152gen-debian-copyright:
153	(cd debian; make copyright)
154