]> arthur.barton.de Git - netdata.git/blob - contrib/debian/rules
ab-debian 0.20170311.01-0ab1, upstream v1.5.0-573-g0fba967b
[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         # Set correct version (Git commit id) when called by the
29         # contrib/debian/build-new-package.sh script:
30         #
31         [ -z "$$COMMIT_ID" ] || echo "$$COMMIT_ID" >$(TOP)/var/lib/netdata/www/version.txt
32
33         # Remove unneeded .keep files
34         #
35         find "$(TOP)" -name .keep -exec rm '{}' ';'
36
37         # Move files that local user shouldn't be editing to /usr/share/netdata
38         #
39         mkdir -p "$(TOP)/usr/share/netdata"
40         for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type d -printf '%f '); do \
41                 echo Relocating $$D; \
42                 mv "$(TOP)/var/lib/netdata/www/$$D" "$(TOP)/usr/share/netdata/$$D"; \
43                 ln -s "/usr/share/netdata/$$D" "$(TOP)/var/lib/netdata/www/$$D"; \
44         done
45
46         # Update postinst to set correct group for www files on installation.
47         # Should probably be dpkg-statoverride really, but that gets *really*
48         # messy. We also set all web files in /var as conffiles so an upgrade
49         # doesn't splat them.
50         #
51         for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type f -printf '%f '); do \
52                 echo Updating postinst for $$D; \
53                 sed -i "s/^#PERMS#/chgrp netdata \/var\/lib\/netdata\/www\/$$D\n#PERMS#/g" \
54                         $(CURDIR)/debian/netdata.postinst; \
55                 echo "/var/lib/netdata/www/$$D" >> $(CURDIR)/debian/netdata.conffiles; \
56         done
57         sed -i "/^#PERMS#/d" $(CURDIR)/debian/netdata.postinst
58
59 override_dh_installdocs:
60         dh_installdocs
61
62         # Docs should not be under /usr/lib
63         #
64         mv $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/plugins.d/README.md \
65                 $(TOP)/usr/share/doc/netdata/README.plugins.md
66         mv $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/charts.d/README.md \
67                 $(TOP)/usr/share/doc/netdata/README.charts.md
68
69         # This doc is currently empty, so no point installing it.
70         #
71         rm $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/node.d/README.md
72
73 override_dh_fixperms:
74         dh_fixperms
75
76         # apps.plugin should only be runnable by the netdata user. It will be
77         # given extra capabilities in the postinst script.
78         #
79         chmod 0754 $(TOP)/usr/lib/$(DEB_HOST_MULTIARCH)/netdata/plugins.d/apps.plugin
80
81 override_dh_installlogrotate:
82         cp system/netdata.logrotate debian/netdata.logrotate
83         dh_installlogrotate
84
85 override_dh_clean:
86         dh_clean
87
88         # Tidy up copied/generated files
89         #
90         -[ -r $(CURDIR)/debian/netdata.logrotate ] && rm $(CURDIR)/debian/netdata.logrotate
91         -[ -r $(CURDIR)/debian/netdata.postinst ] && rm $(CURDIR)/debian/netdata.postinst
92         -[ -r $(CURDIR)/debian/netdata.conffiles ] && rm $(CURDIR)/debian/netdata.conffiles