summaryrefslogtreecommitdiffstats
path: root/contrib/debian/rules
blob: 0e17e39539b28b08f63aafdc3f0fcfd643634b40 (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
#!/usr/bin/make -f

# Find the arch we are building for, as this determines
# the location of plugins in /usr/lib
DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
TOP = $(CURDIR)/debian/netdata
TEMPTOP = $(CURDIR)/debian/tmp

%:
	# For jessie and beyond
	#
	dh $@ --with autoreconf,systemd

	# For wheezy or other non-systemd distributions use the following. You
	# should also see contrib/README.md which gives details of updates to
	# make to debian/control.
	#
	#dh $@ --with autoreconf

override_dh_auto_configure:
	autoreconf -ivf
	dh_auto_configure -- --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib \
	--libexecdir=/usr/libexec --with-user=netdata --with-math --with-zlib --with-webdir=/var/lib/netdata/www

debian/%.postinst: debian/%.postinst.in
	sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' $< > $@

override_dh_install: debian/netdata.postinst
	dh_install

	# Remove unneeded .keep files
	#
	find "$(TOP)" -name .keep -exec rm '{}' ';'

	# Set the CUPS plugin install rule
	#
	mkdir -p $(TOP)-plugin-cups/usr/libexec/netdata/plugins.d
	mv -f $(TEMPTOP)/usr/libexec/netdata/plugins.d/cups.plugin \
	$(TOP)-plugin-cups/usr/libexec/netdata/plugins.d/cups.plugin

	# Set the rest of the software in the main package
	#
	cp -rp $(TEMPTOP)/usr $(TOP)/usr
	cp -rp $(TEMPTOP)/var $(TOP)/var
	#cp -rp $(TEMPTOP)/etc $(TOP)/etc

	# Copy sample netdata.conf
	cp -p $(CURDIR)/system/edit-config $(TOP)/etc/netdata/

	# Create placeholder dirs in netdata configuration directory
	#
	mkdir -p $(TOP)/etc/netdata/health.d
	mkdir -p $(TOP)/etc/netdata/python.d
	mkdir -p $(TOP)/etc/netdata/charts.d
	mkdir -p $(TOP)/etc/netdata/cystonm-plugins.d
	mkdir -p $(TOP)/etc/netdata/go.d
	mkdir -p $(TOP)/etc/netdata/ssl
	mkdir -p $(TOP)/etc/netdata/node.d
	mkdir -p $(TOP)/etc/netdata/statsd.d


	# Move files that local user shouldn't be editing to /usr/share/netdata
	#
	mkdir -p "$(TOP)/usr/share/netdata/www"
	for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type d -printf '%f '); do \
		echo Relocating $$D; \
		mv "$(TOP)/var/lib/netdata/www/$$D" "$(TOP)/usr/share/netdata/www/$$D"; \
		ln -s "/usr/share/netdata/www/$$D" "$(TOP)/var/lib/netdata/www/$$D"; \
	done

	# Update postinst to set correct group for www files on installation.
	# Should probably be dpkg-statoverride really, but that gets *really*
	# messy. We also set all web files in /var as conffiles so an upgrade
	# doesn't splat them.
	#
	for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type f -printf '%f '); do \
		echo Updating postinst for $$D; \
		sed -i "s/^#PERMS#/chgrp netdata \/var\/lib\/netdata\/www\/$$D\n#PERMS#/g" \
			$(CURDIR)/debian/netdata.postinst; \
		echo "/var/lib/netdata/www/$$D" >> $(CURDIR)/debian/netdata.conffiles; \
	done
	sed -i "/^#PERMS#/d" $(CURDIR)/debian/netdata.postinst

	# Install go
	#
	debian/install_go.sh $$(cat ${CURDIR}/packaging/go.d.version) $(TOP)/usr/lib/netdata $(TOP)/usr/libexec/netdata

override_dh_installdocs:
	dh_installdocs

	find . \
		-name README.md \
		-not -path './.travis/*' \
		-not -path './debian/*' \
		-not -path './contrib/*' \
		-exec cp \
		--parents \
		--target $(TOP)/usr/share/doc/netdata/ \
		{} \;

override_dh_fixperms:
	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)/usr/libexec/netdata/plugins.d/apps.plugin
	chmod 0754 $(TOP)/usr/libexec/netdata/plugins.d/freeipmi.plugin
	chmod 0754 $(TOP)/usr/libexec/netdata/plugins.d/perf.plugin
	chmod 0754 $(TOP)/usr/libexec/netdata/plugins.d/slabinfo.plugin
	chmod 0750 $(TOP)/usr/libexec/netdata/plugins.d/go.d.plugin

	# Support script for configuration file management
	#
	chmod 0750 $(TOP)/etc/netdata/edit-config

	# CUPS plugin package
	chmod 0750 $(TOP)-plugin-cups/usr/libexec/netdata/plugins.d/cups.plugin

override_dh_installlogrotate:
	cp system/netdata.logrotate debian/netdata.logrotate
	dh_installlogrotate

override_dh_clean:
	dh_clean

	# Tidy up copied/generated files
	#
	-[ -r $(CURDIR)/debian/netdata.logrotate ] && rm $(CURDIR)/debian/netdata.logrotate
	-[ -r $(CURDIR)/debian/netdata.postinst ] && rm $(CURDIR)/debian/netdata.postinst
	-[ -r $(CURDIR)/debian/netdata.conffiles ] && rm $(CURDIR)/debian/netdata.conffiles