summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: b30907fcf12d169d9bd7b8a9fb5e16d1a3f8bbc4 (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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
#!/usr/bin/make -f

TOP = $(CURDIR)/debian/netdata

PACKAGES := $(shell dh_listpackages -a)

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

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

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:
	mkdir -p mqtt_websockets

	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

execute_after_dh_auto_clean:
	rm -rf build-core
	rm -rf build-core-no-sse debian/tmp-core-no-sse

override_dh_auto_configure:
	mkdir -p build-core
	dh_auto_configure -B build-core -- --libdir=/usr/lib --libexecdir=/usr/lib \
		--disable-cloud \
		--enable-x86-sse \
		--disable-backend-prometheus-remote-write \
		--enable-dbengine \
		--enable-https \
		--enable-plugin-cups \
		--enable-plugin-nfacct \
		--with-math
	cp -a mqtt_websockets tests build-core
	cp -a web/gui/src build-core/web/gui

ifeq (netdata-core-no-sse,$(findstring netdata-core-no-sse,$(PACKAGES)))
	mkdir -p build-core-no-sse
	dh_auto_configure -B build-core-no-sse -- --libdir=/usr/lib --libexecdir=/usr/lib \
		--disable-cloud \
		--disable-x86-sse \
		--disable-backend-prometheus-remote-write \
		--enable-dbengine \
		--enable-https \
		--enable-plugin-cups \
		--enable-plugin-nfacct \
		--with-math
	cp -a mqtt_websockets tests build-core-no-sse
	cp -a web/gui/src build-core-no-sse/web/gui
endif

override_dh_auto_build:
	dh_auto_build -B build-core

ifeq (netdata-core-no-sse,$(findstring netdata-core-no-sse,$(PACKAGES)))
	dh_auto_build -B build-core-no-sse
endif

override_dh_auto_install:
	dh_auto_install -B build-core -- DESTDIR=$(CURDIR)/debian/tmp

	# Removing unused files
	rm -f debian/tmp/etc/netdata/.install-type

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

ifeq (netdata-core-no-sse,$(findstring netdata-core-no-sse,$(PACKAGES)))
	dh_auto_install -B build-core-no-sse -- DESTDIR=$(CURDIR)/debian/tmp-core-no-sse
endif

	# Moving architecture independent plugins
	mkdir -p $(TOP)-plugins-python/usr/lib/netdata/conf.d
	mv debian/tmp/usr/lib/netdata/conf.d/python.d/mongodb.conf $(TOP)-plugins-python/usr/lib/netdata/conf.d

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

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

	mkdir -p $(TOP)-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} \
		   $(TOP)-core/usr/lib/netdata/plugins.d; \
	done

ifeq (netdata-core-no-sse,$(findstring netdata-core-no-sse,$(PACKAGES)))
	find debian/tmp-core-no-sse -name .keep -delete
	dh_install -p netdata-core-no-sse --sourcedir=debian/tmp-core-no-sse

	mkdir -p $(TOP)-core-no-sse/etc/netdata
	cp debian/local/netdata/netdata.conf $(TOP)-core-no-sse/etc/netdata
	touch $(TOP)-core-no-sse/etc/netdata/.opt-out-from-anonymous-statistics

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

	dh_install -a --remaining-packages
else
	dh_install -a
endif

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

	dh_install -i

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

	mkdir -p $(TOP)-plugins-nodejs/usr/lib/netdata/plugins.d
	for plugin in node.d.plugin; \
	do \
		mv $(TOP)-plugins-bash/usr/lib/netdata/plugins.d/$${plugin} \
		   $(TOP)-plugins-nodejs/usr/lib/netdata/plugins.d; \
	done

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

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

override_dh_installinit:
	dh_installinit -p netdata-core --name=netdata
	dh_installinit -p netdata-core-no-sse --name=netdata
	dh_installinit --remaining-packages

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

override_dh_installlogrotate:
	dh_installlogrotate -p netdata-core --name=netdata
	dh_installlogrotate -p netdata-core-no-sse --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 $(TOP)-core/usr/lib/netdata/plugins.d/apps.plugin
	chmod 4754 $(TOP)-core/usr/lib/netdata/plugins.d/perf.plugin
ifeq (netdata-core-no-sse,$(findstring netdata-core-no-sse,$(PACKAGES)))
	chmod 0754 $(TOP)-core-no-sse/usr/lib/netdata/plugins.d/apps.plugin
	chmod 4754 $(TOP)-core-no-sse/usr/lib/netdata/plugins.d/perf.plugin
endif

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 $(TOP)-plugins-bash/usr/lib/netdata/charts.d/*.sh
	chmod 0644 $(TOP)-plugins-bash/usr/lib/netdata/plugins.d/*.sh.inc
	chmod 0644 $(TOP)-plugins-python/usr/lib/netdata/python.d/*.py