]> arthur.barton.de Git - netdata.git/blob - contrib/debian/rules
Ensure netdata owns /var/lib/netdata/.
[netdata.git] / contrib / debian / rules
1 #!/usr/bin/make -f
2
3 # Find the arch we are building for, as this determines
4 # the location of plugins in /usr/lib
5 DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
6 TOP = $(CURDIR)/debian/netdata
7
8 %:
9         # For jessie and beyond
10         #
11         dh $@ --with autoreconf,systemd
12
13         # For wheezy or other non-systemd distributions use the following. You
14         # should also see contrib/README.md which gives details of updates to
15         # make to debian/control.
16         #
17         #dh $@ --with autoreconf
18
19 override_dh_auto_configure:
20         dh_auto_configure -- --with-math --with-webdir=/var/lib/netdata/www
21
22 debian/%.postinst: debian/%.postinst.in
23         sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' $< > $@
24
25 override_dh_install: debian/netdata.postinst
26         dh_install
27
28         # Remove unneeded .keep files
29         #
30         find "$(TOP)" -name .keep -exec rm '{}' ';'
31
32         # Move files that local user shouldn't be editing to /usr/share/netdata
33         #
34         mkdir -p "$(TOP)/usr/share/netdata"
35         for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type d -printf '%f '); do \
36                 echo Relocating $$D; \
37                 mv "$(TOP)/var/lib/netdata/www/$$D" "$(TOP)/usr/share/netdata/$$D"; \
38                 ln -s "/usr/share/netdata/$$D" "$(TOP)/var/lib/netdata/www/$$D"; \
39         done
40
41         # Update postinst to set correct group for www files on installation.
42         # Should probably be dpkg-statoverride really, but that gets *really*
43         # messy. We also set all web files in /var as conffiles so an upgrade
44         # doesn't splat them.
45         #
46         for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type f -printf '%f '); do \
47                 echo Updating postinst for $$D; \
48                 sed -i "s/^#PERMS#/chgrp netdata \/var\/lib\/netdata\/www\/$$D\n#PERMS#/g" \
49                         $(CURDIR)/debian/netdata.postinst; \
50                 echo "/var/lib/netdata/www/$$D" >> $(CURDIR)/debian/netdata.conffiles; \
51         done
52         sed -i "/^#PERMS#/d" $(CURDIR)/debian/netdata.postinst
53
54 override_dh_installdocs:
55         dh_installdocs
56
57         # Docs should not be under /usr/lib
58         #
59         mv $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/plugins.d/README.md \
60                 $(TOP)/usr/share/doc/netdata/README.plugins.md
61         mv $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/charts.d/README.md \
62                 $(TOP)/usr/share/doc/netdata/README.charts.md
63
64         # This doc is currently empty, so no point installing it.
65         #
66         rm $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/node.d/README.md
67
68 override_dh_fixperms:
69         dh_fixperms
70
71         # apps.plugin should only be runnable by the netdata user. It will be
72         # given extra capabilities in the postinst script.
73         #
74         chmod 0754 $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/plugins.d/apps.plugin
75
76 override_dh_installlogrotate:
77         cp system/netdata.logrotate debian/netdata.logrotate
78         dh_installlogrotate
79
80 override_dh_clean:
81         dh_clean
82
83         # Tidy up copied/generated files
84         #
85         -[ -r $(CURDIR)/debian/netdata.logrotate ] && rm $(CURDIR)/debian/netdata.logrotate
86         -[ -r $(CURDIR)/debian/netdata.postinst ] && rm $(CURDIR)/debian/netdata.postinst
87         -[ -r $(CURDIR)/debian/netdata.conffiles ] && rm $(CURDIR)/debian/netdata.conffiles