summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 7a53290895a59c4e5ed44e7b70e210db10b73b33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

VERSION		:= $(shell dpkg-parsechangelog -SVersion)

VERSION_MAJOR	:= $(word 1, $(subst ., ,$(VERSION)))
VERSION_MINOR	:= $(word 2, $(subst ., ,$(VERSION)))
VERSION_FIX	:= $(word 3, $(subst -, ,$(subst ., ,$(VERSION))))
VERSION_SUFFIX	:= -$(word 4, $(subst -, ,$(subst ., ,$(VERSION))))

include /usr/share/dpkg/architecture.mk

ifeq ($(DEB_HOST_ARCH),s390x)
export DEB_CFLAGS_MAINT_APPEND  = -Wall -O2
else
export DEB_CFLAGS_MAINT_APPEND  = -Wall -O3
endif

export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
	dh ${@} --with apache2

execute_before_dh_autoreconf:
	rm -f debian/configure.ac.orig
	cp configure.ac debian/configure.ac.orig

	sed -i	-e 's/^\(define(\[VERSION_MAJOR]\).*/\1, [$(VERSION_MAJOR)])/' \
		-e 's/^\(define(\[VERSION_MINOR]\).*/\1, [$(VERSION_MINOR)])/' \
		-e 's/^\(define(\[VERSION_FIX]\).*/\1, [$(VERSION_FIX)])/' \
		-e 's/^\(define(\[VERSION_SUFFIX]\).*/\1, [$(VERSION_SUFFIX)])/' \
	configure.ac

execute_before_dh_autoreconf_clean:
	if [ -e debian/configure.ac.orig ]; \
	then \
		rm -f configure.ac; \
		mv debian/configure.ac.orig configure.ac; \
	fi

override_dh_auto_configure:
	dh_auto_configure -- \
		--libdir=/usr/lib \
		--libexecdir=/usr/lib \
		--disable-cloud \
		--disable-exporting-prometheus-remote-write \
		--enable-dbengine \
		--enable-https \
		--enable-plugin-cups \
		--enable-plugin-nfacct \
		--enable-x86-sse \
		--with-math

execute_after_dh_auto_install:
	# Removing unused files
	rm -f debian/tmp/etc/netdata/.install-type
	rm -f debian/tmp/etc/netdata/netdata-updater.conf
	rm -f debian/tmp/usr/lib/netdata/install-service.sh
	rm -rf debian/tmp/usr/lib/netdata/system

	# Building without aws kinesis backend (needs aws sdk)
	rm -f debian/tmp/usr/lib/netdata/conf.d/aws_kinesis.conf

override_dh_install-arch:
	find debian/tmp -name .keep -delete

	# Copy architecture dependent plugins
	mkdir -p debian/netdata-core/etc/netdata
	cp debian/local/netdata/netdata.conf debian/netdata-core/etc/netdata
	touch debian/netdata-core/etc/netdata/.opt-out-from-anonymous-statistics

	mkdir -p debian/netdata-core/usr/lib/netdata/plugins.d
	for plugin in cgroup-network apps.plugin nfacct.plugin perf.plugin slabinfo.plugin; \
	do \
		cp debian/tmp/usr/lib/netdata/plugins.d/$${plugin} \
		   debian/netdata-core/usr/lib/netdata/plugins.d; \
	done

	dh_install -a

override_dh_install-indep:
	find debian/tmp -name .keep -delete

	dh_install -i

	# Move architecture dependent plugins
	mkdir -p debian/netdata-core/usr/lib/netdata/plugins.d
	for plugin in cgroup-network apps.plugin nfacct.plugin perf.plugin slabinfo.plugin; \
	do \
		mv -f debian/netdata-plugins-bash/usr/lib/netdata/plugins.d/$${plugin} \
		   debian/netdata-core/usr/lib/netdata/plugins.d; \
	done

	mkdir -p debian/netdata-plugins-python/usr/lib/netdata/plugins.d
	for plugin in python.d.plugin; \
	do \
		mv debian/netdata-plugins-bash/usr/lib/netdata/plugins.d/$${plugin} \
		   debian/netdata-plugins-python/usr/lib/netdata/plugins.d; \
	done

	# Setting package version (update check)
	echo $(VERSION) > debian/netdata-web/usr/share/netdata/web/version.txt

override_dh_installsystemd:
	dh_installsystemd -p netdata-core --name=netdata
	dh_installsystemd --remaining-packages

override_dh_installlogrotate:
	dh_installlogrotate -p netdata-core --name=netdata
	dh_installlogrotate --remaining-packages

override_dh_fixperms-arch:
	dh_fixperms -a

	# apps.plugin should only be runnable by the netdata user. It will be
	# given extra capabilities in the postinst script.
	chmod 0754 debian/netdata-core/usr/lib/netdata/plugins.d/apps.plugin
	chmod 4754 debian/netdata-core/usr/lib/netdata/plugins.d/perf.plugin

override_dh_fixperms-indep:
	dh_fixperms -i

	# apps.plugin should only be runnable by the netdata user. It will be
	# given extra capabilities in the postinst script.
	chmod 0644 debian/netdata-plugins-bash/usr/lib/netdata/charts.d/*.sh
	chmod 0644 debian/netdata-plugins-bash/usr/lib/netdata/plugins.d/*.sh.inc
	chmod 0644 debian/netdata-plugins-python/usr/lib/netdata/python.d/*.py