@cryptotaxi247 / netdata-1 / commits / 62d8fc5c2

Add Debian packaging

Matthew Newton committed Apr 1, 2016 at 17:25 UTC 62d8fc5c2279613fe86456ff0f6c99ad699d6ca4
16 files changed +369
contrib/README.md new
+49
@@ -0,0 +1,49 @@
1 +# netdata contrib
2 +
3 +## Building .deb packages
4 +
5 +The `contrib/debian/` directory contains basic rules to build a
6 +Debian package. It has been tested on Debian Jessie and Wheezy,
7 +but should work, possibly with minor changes, if you have other
8 +dpkg-based systems such as Ubuntu or Mint.
9 +
10 +To build netdata for a Debian Jessie system, the debian directory
11 +has to be available in the root of the netdata source. The easiest
12 +way to do this is with a symlink:
13 +
14 + ~/netdata$ ln -s contrib/debian
15 +
16 +Then build the debian package:
17 +
18 + ~/netdata$ dpkg-buildpackage -us -uc -rfakeroot
19 +
20 +This should give a package that can be installed in the parent
21 +directory, which you can install manually with dpkg.
22 +
23 + ~/netdata$ ls ../*.deb
24 + ../netdata_1.0.0_amd64.deb
25 + ~/netdata$ sudo dpkg -i ../netdata_1.0.0_amd64.deb
26 +
27 +
28 +### Building for a Debian system without systemd
29 +
30 +The included packaging is designed for modern Debian systems that
31 +are based on systemd. To build non-systemd packages (for example,
32 +for Debian wheezy), you will need to make a couple of minor
33 +updates first.
34 +
35 +* edit `contrib/debian/rules` and adjust the `dh` rule near the
36 + top to remove systemd (see comments in that file).
37 +
38 +* edit `contrib/debian/control`: remove `dh-systemd` from the
39 + Build-Depends list, and add `pkg-config` to it.
40 +
41 +Then proceed as the main instructions above.
42 +
43 +### Reinstalling netdata
44 +
45 +The recommended way to upgrade netdata packages built from this
46 +source is to remove the current package from your system, then
47 +install the new package. Upgrading on wheezy is known to not
48 +work cleanly; Jessie may behave as expected.
49 +
contrib/debian/changelog new
+5
@@ -0,0 +1,5 @@
1 +netdata (1.0.0) UNRELEASED; urgency=medium
2 +
3 + * Initial release.
4 +
5 + -- Matthew Newton <mcn4@leicester.ac.uk> Fri, 01 Apr 2016 17:24:11 +0100
contrib/debian/compat new
+1
@@ -0,0 +1 @@
1 +9
contrib/debian/control new
+24
@@ -0,0 +1,24 @@
1 +Source: netdata
2 +Build-Depends: debhelper (>= 9),
3 + dh-autoreconf,
4 + dh-systemd (>= 1.5),
5 + dpkg-dev (>= 1.13.19),
6 + zlib1g-dev
7 +Section: net
8 +Priority: optional
9 +Maintainer: Costa Tsaousis <costa@tsaousis.gr>
10 +Standards-Version: 3.9.6
11 +Homepage: https://github.com/firehol/netdata/wiki
12 +
13 +Package: netdata
14 +Architecture: any
15 +Depends: adduser,
16 + libcap2-bin (>= 1:2.0),
17 + lsb-base (>= 3.1-23.2),
18 + ${misc:Depends},
19 + ${shlibs:Depends}
20 +Description: real-time charts for system monitoring
21 + Netdata is a daemon that collects data in realtime (per second)
22 + and presents a web site to view and analyze them. The presentation
23 + is also real-time and full of interactive charts that precisely
24 + render all collected values.
contrib/debian/copyright new
+10
@@ -0,0 +1,10 @@
1 +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
2 +Upstream-Name: Netdata
3 +Upstream-Contact: Costa Tsaousis <costa@tsaousis.gr>
4 +Source: https://github.com/firehol/netdata
5 +
6 +Files: *
7 +Copyright: 2014-2016, Costa Tsaousis
8 +License: GPL-3+
9 + On Debian systems, the complete text of the GNU General Public
10 + License version 3 can be found in /usr/share/common-licenses/GPL-3.
contrib/debian/netdata.conf new
+16
@@ -0,0 +1,16 @@
1 +# NetData Configuration
2 +
3 +# The current full configuration can be retrieved from the running
4 +# server at the URL
5 +#
6 +# http://localhost:19999/netdata.conf
7 +#
8 +# for example:
9 +#
10 +# wget -O /etc/netdata/netdata.conf http://localhost:19999/netdata.conf
11 +#
12 +
13 +[global]
14 + run as user = netdata
15 + web files owner = root
16 + web files group = netdata
contrib/debian/netdata.default new
+4
@@ -0,0 +1,4 @@
1 +# Extra arguments to pass to netdata
2 +#
3 +#EXTRA_OPTS=""
4 +
contrib/debian/netdata.docs new
+1
@@ -0,0 +1 @@
1 +ChangeLog
contrib/debian/netdata.init new
+56
@@ -0,0 +1,56 @@
1 +#!/bin/sh
2 +# Start/stop the netdata daemon.
3 +#
4 +### BEGIN INIT INFO
5 +# Provides: netdata
6 +# Required-Start: $remote_fs
7 +# Required-Stop: $remote_fs
8 +# Should-Start: $network
9 +# Should-Stop: $network
10 +# Default-Start: 2 3 4 5
11 +# Default-Stop:
12 +# Short-Description: Real-time charts for system monitoring
13 +# Description: Netdata is a daemon that collects data in realtime (per second)
14 +# and presents a web site to view and analyze them. The presentation
15 +# is also real-time and full of interactive charts that precisely
16 +# render all collected values.
17 +### END INIT INFO
18 +
19 +PATH=/bin:/usr/bin:/sbin:/usr/sbin
20 +DESC="netdata daemon"
21 +NAME=netdata
22 +DAEMON=/usr/sbin/netdata
23 +PIDFILE=/var/run/netdata/netdata.pid
24 +SCRIPTNAME=/etc/init.d/"$NAME"
25 +
26 +test -f $DAEMON || exit 0
27 +
28 +. /lib/lsb/init-functions
29 +
30 +[ -r /etc/default/netdata ] && . /etc/default/netdata
31 +
32 +case "$1" in
33 +start) log_daemon_msg "Starting real-time system monitoring" "netdata"
34 + start_daemon -p $PIDFILE $DAEMON $EXTRA_OPTS
35 + log_end_msg $?
36 + ;;
37 +stop) log_daemon_msg "Stopping real-time system monitoring" "netdata"
38 + killproc -p $PIDFILE $DAEMON
39 + RETVAL=$?
40 + [ $RETVAL -eq 0 ] && [ -e "$PIDFILE" ] && rm -f $PIDFILE
41 + log_end_msg $RETVAL
42 + # wait for plugins to exit
43 + sleep 1
44 + ;;
45 +restart|force-reload) log_daemon_msg "Restarting real-time system monitoring" "netdata"
46 + $0 stop
47 + $0 start
48 + ;;
49 +status)
50 + status_of_proc -p $PIDFILE $DAEMON $NAME && exit 0 || exit $?
51 + ;;
52 +*) log_action_msg "Usage: /etc/init.d/cron {start|stop|status|restart|force-reload}"
53 + exit 2
54 + ;;
55 +esac
56 +exit 0
contrib/debian/netdata.install new
+1
@@ -0,0 +1 @@
1 +debian/netdata.conf /etc/netdata/
contrib/debian/netdata.lintian-overrides new
+16
@@ -0,0 +1,16 @@
1 +
2 +# See Debian policy 10.9. apps.plugin has extra capabilities, so don't let
3 +# normal users run it.
4 +netdata: non-standard-executable-perm usr/lib/*/netdata/plugins.d/apps.plugin 0754 != 0755
5 +
6 +
7 +# FontAwesome is at least in the fonts-font-awesome package, but this is
8 +# not available in wheezy. glyphicons-halflings-regular isn't currently in
9 +# a Debian package. Therefore don't complain about shipping them with netdata
10 +# for the time being.
11 +netdata: duplicate-font-file usr/share/netdata/fonts/*
12 +netdata: font-in-non-font-package usr/share/netdata/fonts/*
13 +
14 +# Files here are marked as conffiles so that local updates to the html files
15 +# isn't clobbered on upgrade.
16 +netdata: non-etc-file-marked-as-conffile var/lib/netdata/www/*
contrib/debian/netdata.postinst.in new
+41
@@ -0,0 +1,41 @@
1 +#! /bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + configure)
7 + if [ -z "$2" ]; then
8 + if ! getent group netdata >/dev/null; then
9 + addgroup --quiet --system netdata
10 + fi
11 +
12 + if ! getent passwd netdata >/dev/null; then
13 + adduser --quiet --system --ingroup netdata --home /var/lib/netdata --no-create-home netdata
14 + fi
15 +
16 + if ! dpkg-statoverride --list /var/lib/netdata >/dev/null 2>&1; then
17 + dpkg-statoverride --update --add root netdata 0755 /var/lib/netdata
18 + fi
19 +
20 + if ! dpkg-statoverride --list /var/lib/netdata/www >/dev/null 2>&1; then
21 + dpkg-statoverride --update --add root netdata 0755 /var/lib/netdata/www
22 + fi
23 +
24 + if ! dpkg-statoverride --list /var/cache/netdata >/dev/null 2>&1; then
25 + dpkg-statoverride --update --add netdata netdata 0755 /var/cache/netdata
26 + fi
27 +
28 + fi
29 +
30 + chown -R root:netdata /usr/share/netdata/*
31 + chown -R root:netdata /usr/lib/@DEB_HOST_MULTIARCH@/netdata/plugins.d
32 + setcap cap_dac_read_search,cap_sys_ptrace+ep /usr/lib/@DEB_HOST_MULTIARCH@/netdata/plugins.d/apps.plugin
33 +
34 +#PERMS#
35 + ;;
36 +esac
37 +
38 +#DEBHELPER#
39 +
40 +exit 0
41 +
contrib/debian/netdata.postrm new
+43
@@ -0,0 +1,43 @@
1 +#! /bin/sh
2 +
3 +set -e
4 +
5 +case "$1" in
6 + remove)
7 + ;;
8 +
9 + purge)
10 + if dpkg-statoverride --list | grep -qw /var/cache/netdata; then
11 + dpkg-statoverride --remove /var/cache/netdata
12 + fi
13 +
14 + if dpkg-statoverride --list | grep -qw /var/lib/netdata/www; then
15 + dpkg-statoverride --remove /var/lib/netdata/www
16 + fi
17 +
18 + if dpkg-statoverride --list | grep -qw /var/lib/netdata; then
19 + dpkg-statoverride --remove /var/lib/netdata
20 + fi
21 +
22 + if getent passwd netdata >/dev/null; then
23 + if [ -x /usr/sbin/deluser ]; then
24 + deluser --quiet --system netdata || echo "Unable to remove netdata user"
25 + fi
26 + fi
27 +
28 + if getent group netdata >/dev/null; then
29 + if [ -x /usr/sbin/delgroup ]; then
30 + delgroup --quiet --system netdata || echo "Unable to remove netdata group"
31 + fi
32 + fi
33 +
34 + ;;
35 +
36 + *)
37 + ;;
38 +esac
39 +
40 +#DEBHELPER#
41 +
42 +exit 0
43 +
contrib/debian/netdata.service new
+14
@@ -0,0 +1,14 @@
1 +[Unit]
2 +Description=netdata real-time system monitoring
3 +After=network.target
4 +
5 +[Service]
6 +Type=simple
7 +EnvironmentFile=-/etc/default/netdata
8 +ExecStart=/usr/sbin/netdata -nd $EXTRA_OPTS
9 +TimeoutStopSec=30
10 +Restart=always
11 +RestartSec=5
12 +
13 +[Install]
14 +WantedBy=multi-user.target
contrib/debian/rules new
+87
@@ -0,0 +1,87 @@
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
contrib/debian/source/format new
+1
@@ -0,0 +1 @@
1 +3.0 (native)