rules 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. #!/usr/bin/make -f
  2. # Find the arch we are building for, as this determines
  3. # the location of plugins in /usr/lib
  4. DEB_HOST_MULTIARCH ?= $(shell dpkg-architecture -qDEB_HOST_MULTIARCH)
  5. TOP = $(CURDIR)/debian/netdata
  6. TEMPTOP = $(CURDIR)/debian/tmp
  7. BASE_CONFIG = system/netdata.conf
  8. SYSTEMD_VERSION = $(shell /bin/sh -c "systemd --version 2>&1 | head -n 1 | cut -f 2 -d ' '")
  9. ifeq ($(shell test $(SYSTEMD_VERSION) -ge 235 && echo "1"), 1)
  10. SYSTEMD_UNIT = system/netdata.service.v235
  11. else
  12. SYSTEMD_UNIT = system/netdata.service
  13. endif
  14. %:
  15. # For jessie and beyond
  16. #
  17. dh $@ --with autoreconf,systemd
  18. # For wheezy or other non-systemd distributions use the following. You
  19. # should also see contrib/README.md which gives details of updates to
  20. # make to debian/control.
  21. #
  22. #dh $@ --with autoreconf
  23. override_dh_installinit:
  24. echo "SystemD Version: $(SYSTEMD_VERSION)"
  25. echo "Using SystemD Unit: $(SYSTEMD_UNIT)"
  26. cp -v $(SYSTEMD_UNIT) debian/netdata.service
  27. dh_installinit
  28. override_dh_auto_configure:
  29. packaging/bundle-mosquitto.sh .
  30. packaging/bundle-lws.sh .
  31. autoreconf -ivf
  32. dh_auto_configure -- --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib \
  33. --libexecdir=/usr/libexec --with-user=netdata --with-math --with-zlib --with-webdir=/var/lib/netdata/www
  34. debian/%.postinst: debian/%.postinst.in
  35. sed 's/@DEB_HOST_MULTIARCH@/$(DEB_HOST_MULTIARCH)/g' $< > $@
  36. override_dh_install: debian/netdata.postinst
  37. cp -v $(BASE_CONFIG) debian/netdata.conf
  38. dh_install
  39. # Set the CUPS plugin install rule
  40. #
  41. mkdir -p $(TOP)-plugin-cups/usr/libexec/netdata/plugins.d
  42. mv -f $(TEMPTOP)/usr/libexec/netdata/plugins.d/cups.plugin \
  43. $(TOP)-plugin-cups/usr/libexec/netdata/plugins.d/cups.plugin
  44. # Add free IPMI plugin install rules
  45. #
  46. mkdir -p $(TOP)-plugin-freeipmi/usr/libexec/netdata/plugins.d
  47. mv -f $(TEMPTOP)/usr/libexec/netdata/plugins.d/freeipmi.plugin \
  48. $(TOP)-plugin-freeipmi/usr/libexec/netdata/plugins.d/freeipmi.plugin
  49. # Set the rest of the software in the main package
  50. #
  51. cp -rp $(TEMPTOP)/usr $(TOP)
  52. cp -rp $(TEMPTOP)/var $(TOP)
  53. cp -rp $(TEMPTOP)/etc $(TOP)
  54. mkdir -p "$(TOP)/var/log/netdata"
  55. mkdir -p "$(TOP)/var/cache/netdata"
  56. mkdir -p "$(TOP)/var/run/netdata"
  57. # Move files that local user shouldn't be editing to /usr/share/netdata
  58. #
  59. packaging/bundle-dashboard.sh . ${TOP}/var/lib/netdata/www
  60. mkdir -p "$(TOP)/usr/share/netdata/www"
  61. for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type d -printf '%f '); do \
  62. echo Relocating $$D; \
  63. mv "$(TOP)/var/lib/netdata/www/$$D" "$(TOP)/usr/share/netdata/www/$$D"; \
  64. ln -s "/usr/share/netdata/www/$$D" "$(TOP)/var/lib/netdata/www/$$D"; \
  65. done
  66. # Update postinst to set correct group for www files on installation.
  67. # Should probably be dpkg-statoverride really, but that gets *really*
  68. # messy. We also set all web files in /var as conffiles so an upgrade
  69. # doesn't splat them.
  70. #
  71. for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type f -printf '%f '); do \
  72. echo Updating postinst for $$D; \
  73. sed -i "s/^#PERMS#/chgrp netdata \/var\/lib\/netdata\/www\/$$D\n#PERMS#/g" \
  74. $(CURDIR)/debian/netdata.postinst; \
  75. echo "/var/lib/netdata/www/$$D" >> $(CURDIR)/debian/netdata.conffiles; \
  76. done
  77. sed -i "/^#PERMS#/d" $(CURDIR)/debian/netdata.postinst
  78. # Install go
  79. #
  80. debian/install_go.sh $$(cat ${CURDIR}/packaging/go.d.version) $(TOP)/usr/lib/netdata $(TOP)/usr/libexec/netdata
  81. override_dh_installdocs:
  82. dh_installdocs
  83. find . \
  84. -name README.md \
  85. -not -path './.travis/*' \
  86. -not -path './debian/*' \
  87. -not -path './contrib/*' \
  88. -exec cp \
  89. --parents \
  90. --target $(TOP)/usr/share/doc/netdata/ \
  91. {} \;
  92. override_dh_fixperms:
  93. dh_fixperms
  94. # apps.plugin should only be runnable by the netdata user. It will be
  95. # given extra capabilities in the postinst script.
  96. #
  97. chmod 0754 $(TOP)/usr/libexec/netdata/plugins.d/apps.plugin
  98. chmod 0754 $(TOP)/usr/libexec/netdata/plugins.d/perf.plugin
  99. chmod 0754 $(TOP)/usr/libexec/netdata/plugins.d/slabinfo.plugin
  100. chmod 0750 $(TOP)/usr/libexec/netdata/plugins.d/go.d.plugin
  101. # CUPS plugin package
  102. chmod 0750 $(TOP)-plugin-cups/usr/libexec/netdata/plugins.d/cups.plugin
  103. # freeIPMI plugin package
  104. chmod 4750 $(TOP)-plugin-freeipmi/usr/libexec/netdata/plugins.d/freeipmi.plugin
  105. override_dh_installlogrotate:
  106. cp system/netdata.logrotate debian/netdata.logrotate
  107. dh_installlogrotate
  108. override_dh_clean:
  109. dh_clean
  110. # Tidy up copied/generated files
  111. #
  112. -[ -r $(CURDIR)/debian/netdata.logrotate ] && rm $(CURDIR)/debian/netdata.logrotate
  113. -[ -r $(CURDIR)/debian/netdata.postinst ] && rm $(CURDIR)/debian/netdata.postinst
  114. -[ -r $(CURDIR)/debian/netdata.conffiles ] && rm $(CURDIR)/debian/netdata.conffiles