rules 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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. TOP = $(CURDIR)/debian/netdata
  5. TEMPTOP = $(CURDIR)/debian/tmp
  6. BASE_CONFIG = system/netdata.conf
  7. SYSTEMD_VERSION = $(shell /bin/sh -c "systemd --version 2>&1 | head -n 1 | cut -f 2 -d ' '")
  8. ifeq ($(shell test $(SYSTEMD_VERSION) -ge 235 && echo "1"), 1)
  9. SYSTEMD_UNIT = system/systemd/netdata.service.v235
  10. else
  11. SYSTEMD_UNIT = system/systemd/netdata.service
  12. endif
  13. ifeq ($(shell test `uname -m` != "x86_64" && echo "1"), 1)
  14. HAVE_EBPF = 0
  15. EBPF_CONFIG = --disable-ebpf
  16. else
  17. HAVE_EBPF = 1
  18. endif
  19. %:
  20. dh $@
  21. override_dh_installinit:
  22. echo "SystemD Version: $(SYSTEMD_VERSION)"
  23. echo "Using SystemD Unit: $(SYSTEMD_UNIT)"
  24. cp -v $(SYSTEMD_UNIT) debian/netdata.service
  25. dh_systemd_enable
  26. dh_installinit
  27. override_dh_auto_configure:
  28. if [ $(HAVE_EBPF) -eq 1 ]; then \
  29. packaging/bundle-libbpf.sh . ${TOP}/usr/libexec/netdata/plugins.d; \
  30. packaging/bundle-ebpf-co-re.sh . ${TOP}/usr/libexec/netdata/plugins.d; \
  31. fi
  32. autoreconf -ivf
  33. dh_auto_configure -- --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib \
  34. --libexecdir=/usr/libexec --with-user=netdata --with-math --with-zlib --with-webdir=/var/lib/netdata/www \
  35. --disable-dependency-tracking $(EBPF_CONFIG)
  36. override_dh_install:
  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. # Copy the updater script
  58. #
  59. cp -v packaging/installer/netdata-updater.sh $(TOP)/usr/libexec/netdata/netdata-updater.sh
  60. # Move files that local user shouldn't be editing to /usr/share/netdata
  61. #
  62. mkdir -p "$(TOP)/usr/share/netdata/www"
  63. for D in $$(find "$(TOP)/var/lib/netdata/www/" -maxdepth 1 -type d -printf '%f '); do \
  64. echo Relocating $$D; \
  65. mv "$(TOP)/var/lib/netdata/www/$$D" "$(TOP)/usr/share/netdata/www/$$D"; \
  66. ln -s "/usr/share/netdata/www/$$D" "$(TOP)/var/lib/netdata/www/$$D"; \
  67. done
  68. if [ $(HAVE_EBPF) -eq 1 ]; then \
  69. packaging/bundle-ebpf.sh . ${TOP}/usr/libexec/netdata/plugins.d; \
  70. fi
  71. # Install go
  72. #
  73. debian/install_go.sh $$(cat ${CURDIR}/packaging/go.d.version) $(TOP)/usr/lib/netdata $(TOP)/usr/libexec/netdata
  74. override_dh_installdocs:
  75. dh_installdocs
  76. find . \
  77. -name README.md \
  78. -not -path './debian/*' \
  79. -not -path './contrib/*' \
  80. -exec cp \
  81. --parents \
  82. --target $(TOP)/usr/share/doc/netdata/ \
  83. {} \;
  84. override_dh_fixperms:
  85. dh_fixperms
  86. # Updater script should be executable
  87. #
  88. chmod 0755 $(TOP)/usr/libexec/netdata/netdata-updater.sh
  89. # apps.plugin should only be runnable by the netdata user. It will be
  90. # given extra capabilities in the postinst script.
  91. #
  92. chmod 0750 $(TOP)/usr/libexec/netdata/plugins.d/apps.plugin
  93. chmod 0750 $(TOP)/usr/libexec/netdata/plugins.d/debugfs.plugin
  94. chmod 0750 $(TOP)/usr/libexec/netdata/plugins.d/perf.plugin
  95. chmod 0750 $(TOP)/usr/libexec/netdata/plugins.d/slabinfo.plugin
  96. chmod 0750 $(TOP)/usr/libexec/netdata/plugins.d/go.d.plugin
  97. # CUPS plugin package
  98. chmod 0750 $(TOP)-plugin-cups/usr/libexec/netdata/plugins.d/cups.plugin
  99. # freeIPMI plugin package
  100. chmod 4750 $(TOP)-plugin-freeipmi/usr/libexec/netdata/plugins.d/freeipmi.plugin
  101. override_dh_installlogrotate:
  102. cp system/logrotate/netdata debian/netdata.logrotate
  103. dh_installlogrotate
  104. override_dh_installdeb:
  105. dh_installdeb
  106. @echo "Recreating conffiles without auto-adding /etc files"
  107. @cp $(CURDIR)/debian/conffiles $(CURDIR)/debian/netdata/DEBIAN/conffiles
  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.conffiles ] && rm $(CURDIR)/debian/netdata.conffiles