summaryrefslogtreecommitdiffstats
path: root/debian/rules
blob: 6ad8b23097556d3edf82158bc52c69a9010e5ef2 (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
#!/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))))

export DH_VERBOSE = 1
export DEB_BUILD_MAINT_OPTIONS = hardening=+all

export DEB_CFLAGS_MAINT_APPEND  = -Wall -O3
export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed

%:
	dh $@

override_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

	dh_autoreconf

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

	dh_autoreconf_clean

override_dh_auto_clean:
	dh_auto_clean

	rm -rf build-optimized
	rm -rf build-no-sse debian/tmp-no-sse

override_dh_auto_configure:
	mkdir -p build-optimized
	dh_auto_configure -B build-optimized -- --libdir=/usr/lib --libexecdir=/usr/lib --enable-x86-sse --enable-plugin-freeipmi --with-math
	cp -a web/gui/src build-optimized/web/gui

ifdef $(findstring no-sse,$(PACKAGES))
	mkdir -p build-no-sse
	dh_auto_configure -B build-no-sse -- --libdir=/usr/lib --libexecdir=/usr/lib --disable-x86-sse --disable-plugin-freeipmi --with-math
	cp -a web/gui/src build-no-sse/web/gui
endif

override_dh_auto_build:
	dh_auto_build -B build-optimized

ifdef $(findstring no-sse,$(PACKAGES))
	dh_auto_build -B build-no-sse
endif

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

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

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

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

	find debian/tmp -name .keep -delete
	dh_install --remaining-packages

	# Move architecture dependent plugins
	mkdir -p $(TOP)-core/usr/lib/netdata/plugins.d
	for plugin in cgroup-network apps.plugin freeipmi.plugin; \
	do \
		mv $(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

override_dh_install-indep:
	dh_install
	# 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_installinit --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_missing:
	dh_missing --fail-missing

override_dh_fixperms-arch:
	dh_fixperms

	# 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/freeipmi.plugin
ifdef $(findstring 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/freeipmi.plugin
endif
	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