From 8f17d6026b3da5b3266d2cad4cf4eecde7557f86 Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Thu, 21 Dec 2017 18:25:13 +0100 Subject: [PATCH 1/4] Add configurable path variables for services Setting PREFIX to a location different to /usr, the install routine fails to install the systemd and dbus service files. These are installed, but in the PREFIX directory and not /usr. DBus and systemd usually only read their files from /usr/ and ignore files in /usr/local. Now by default, we're asking pkg-config, where to install it. Mostly, this will be /usr and this conflicts the FHS. But it's the user's intent to install dunst and (possibly) override the package manager's files belonging to dunst. At the current point, even DBus ignores the PREFIX and installs its systemd service file to the location specified by pkg-config. --- Makefile | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index c9bd3e9..9567d47 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,18 @@ ifneq ($(wildcard ./.git/.),) VERSION := $(shell git describe --tags) endif +SERVICEDIR_DBUS ?= $(shell pkg-config dbus-1 --variable=session_bus_services_dir) +SERVICEDIR_DBUS := ${SERVICEDIR_DBUS} +ifeq (,${SERVICEDIR_DBUS}) +$(error "Failed to query pkg-config for package 'dbus-1'!") +endif + +SERVICEDIR_SYSTEMD ?= $(shell pkg-config systemd --variable=systemduserunitdir) +SERVICEDIR_SYSTEMD := ${SERVICEDIR_SYSTEMD} +ifeq (,${SERVICEDIR_SYSTEMD}) +$(error "Failed to query pkg-config for package 'systemd'!") +endif + LIBS := $(shell pkg-config --libs ${pkg_config_packs}) INCS := $(shell pkg-config --cflags ${pkg_config_packs}) @@ -103,13 +115,12 @@ install-doc: install -m644 dunstrc ${DESTDIR}${PREFIX}/share/dunst install-service: service - mkdir -p ${DESTDIR}${PREFIX}/share/dbus-1/services/ - install -m644 org.knopwob.dunst.service ${DESTDIR}${PREFIX}/share/dbus-1/services - install -Dm644 dunst.systemd.service ${DESTDIR}${PREFIX}/lib/systemd/user/dunst.service + install -Dm644 org.knopwob.dunst.service ${DESTDIR}${SERVICEDIR_DBUS}/org.knopwob.dunst.service + install -Dm644 dunst.systemd.service ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service uninstall: rm -f ${DESTDIR}${PREFIX}/bin/dunst rm -f ${DESTDIR}${MANPREFIX}/man1/dunst.1 - rm -f ${DESTDIR}${PREFIX}/share/dbus-1/services/org.knopwob.dunst.service - rm -f ${DESTDIR}${PREFIX}/lib/systemd/user/dunst.service + rm -f ${DESTDIR}${SERVICEDIR_DBUS}/org.knopwob.dunst.service + rm -f ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service rm -rf ${DESTDIR}${PREFIX}/share/dunst From 573ea1de20c12db0d04705a95431418ae8d6271a Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Thu, 21 Dec 2017 20:09:38 +0100 Subject: [PATCH 2/4] Use systemd as a soft dependency Dunst does not neccessarily need systemd. Dunst gets started primarily via DBus. The systemd service is useful on systemd init based systems, but won't have any impact on non-systemd systems. To make systemd a soft dependency is neccessary, as pkg-config now also queries the systemd.pc file, which won't exist on non systemd systems. --- Makefile | 48 +++++++++++++++++++++++++++++++++++++++++------- config.mk | 4 ++++ 2 files changed, 45 insertions(+), 7 deletions(-) diff --git a/Makefile b/Makefile index 9567d47..f4ff0ac 100644 --- a/Makefile +++ b/Makefile @@ -8,17 +8,30 @@ ifneq ($(wildcard ./.git/.),) VERSION := $(shell git describe --tags) endif +ifeq (,${SYSTEMD}) +# Check for systemctl to avoid discrepancies on systems, where +# systemd is installed, but systemd.pc is in another package +systemctl := $(shell command -v systemctl >/dev/null && echo systemctl) +ifeq (systemctl,${systemctl}) +SYSTEMD := 1 +else +SYSTEMD := 0 +endif +endif + SERVICEDIR_DBUS ?= $(shell pkg-config dbus-1 --variable=session_bus_services_dir) SERVICEDIR_DBUS := ${SERVICEDIR_DBUS} ifeq (,${SERVICEDIR_DBUS}) $(error "Failed to query pkg-config for package 'dbus-1'!") endif +ifneq (0,${SYSTEMD}) SERVICEDIR_SYSTEMD ?= $(shell pkg-config systemd --variable=systemduserunitdir) SERVICEDIR_SYSTEMD := ${SERVICEDIR_SYSTEMD} ifeq (,${SERVICEDIR_SYSTEMD}) $(error "Failed to query pkg-config for package 'systemd'!") endif +endif LIBS := $(shell pkg-config --libs ${pkg_config_packs}) INCS := $(shell pkg-config --cflags ${pkg_config_packs}) @@ -78,10 +91,15 @@ doc: docs/dunst.1 docs/dunst.1: docs/dunst.pod pod2man --name=dunst -c "Dunst Reference" --section=1 --release=${VERSION} $< > $@ -.PHONY: service -service: +.PHONY: service service-dbus service-systemd +service: service-dbus +service-dbus: @sed "s|##PREFIX##|$(PREFIX)|" org.knopwob.dunst.service.in > org.knopwob.dunst.service +ifneq (0,${SYSTEMD}) +service: service-systemd +service-systemd: @sed "s|##PREFIX##|$(PREFIX)|" dunst.systemd.service.in > dunst.systemd.service +endif .PHONY: clean clean-dunst clean-dunstify clean-doc clean-tests clean: clean-dunst clean-dunstify clean-doc clean-tests @@ -101,7 +119,10 @@ clean-doc: clean-tests: rm -f test/test test/*.o -.PHONY: install install-dunst install-doc install-service uninstall +.PHONY: install install-dunst install-doc \ + install-service install-service-dbus install-service-systemd \ + uninstall \ + uninstall-service uninstall-service-dbus uninstall-service-systemd install: install-dunst install-doc install-service install-dunst: dunst doc @@ -114,13 +135,26 @@ install-doc: mkdir -p ${DESTDIR}${PREFIX}/share/dunst install -m644 dunstrc ${DESTDIR}${PREFIX}/share/dunst -install-service: service +install-service: service install-service-dbus +install-service-dbus: install -Dm644 org.knopwob.dunst.service ${DESTDIR}${SERVICEDIR_DBUS}/org.knopwob.dunst.service +ifneq (0,${SYSTEMD}) +install-service: install-service-systemd +install-service-systemd: install -Dm644 dunst.systemd.service ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service +endif -uninstall: +uninstall: uninstall-service rm -f ${DESTDIR}${PREFIX}/bin/dunst rm -f ${DESTDIR}${MANPREFIX}/man1/dunst.1 - rm -f ${DESTDIR}${SERVICEDIR_DBUS}/org.knopwob.dunst.service - rm -f ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service rm -rf ${DESTDIR}${PREFIX}/share/dunst + +uninstall-service: uninstall-service-dbus +uninstall-service-dbus: + rm -f ${DESTDIR}${SERVICEDIR_DBUS}/org.knopwob.dunst.service + +ifneq (0,${SYSTEMD}) +uninstall-service: uninstall-service-systemd +uninstall-service-systemd: + rm -f ${DESTDIR}${SERVICEDIR_SYSTEMD}/dunst.service +endif diff --git a/config.mk b/config.mk index 7b26a48..47811ac 100644 --- a/config.mk +++ b/config.mk @@ -2,6 +2,10 @@ PREFIX ?= /usr/local MANPREFIX = ${PREFIX}/share/man +# Disable systemd service file installation, +# if you don't want to use systemd albeit installed +#SYSTEMD ?= 0 + # uncomment to disable parsing of dunstrc # or use "CFLAGS=-DSTATIC_CONFIG make" to build #STATIC= -DSTATIC_CONFIG # Warning: This is deprecated behavior From de09b5a87da0f4c53da8ea627054220042512eaa Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Thu, 21 Dec 2017 20:43:21 +0100 Subject: [PATCH 3/4] Do not create directories separately --- Makefile | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index f4ff0ac..3908e25 100644 --- a/Makefile +++ b/Makefile @@ -126,14 +126,11 @@ clean-tests: install: install-dunst install-doc install-service install-dunst: dunst doc - mkdir -p ${DESTDIR}${PREFIX}/bin - install -m755 dunst ${DESTDIR}${PREFIX}/bin - mkdir -p ${DESTDIR}${MANPREFIX}/man1 - install -m644 docs/dunst.1 ${DESTDIR}${MANPREFIX}/man1 + install -Dm755 dunst ${DESTDIR}${PREFIX}/bin/dunst + install -Dm644 docs/dunst.1 ${DESTDIR}${MANPREFIX}/man1/dunst.1 install-doc: - mkdir -p ${DESTDIR}${PREFIX}/share/dunst - install -m644 dunstrc ${DESTDIR}${PREFIX}/share/dunst + install -Dm644 dunstrc ${DESTDIR}${PREFIX}/share/dunst/dunstrc install-service: service install-service-dbus install-service-dbus: From 85da5d788bbbf86390cfbd7b145f38d06f807e6c Mon Sep 17 00:00:00 2001 From: Benedikt Heine Date: Mon, 25 Dec 2017 17:29:20 +0100 Subject: [PATCH 4/4] Add build documentation --- README.md | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b955018..cdb3b04 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,9 @@ Dunst is a highly configurable and lightweight notification daemon. -## Compiling +## Installation + +### Dependencies Dunst has a number of build dependencies that must be present before attempting configuration. The names are different depending on [distribution](https://github.com/dunst-project/dunst/wiki/Dependencies): @@ -25,6 +27,23 @@ Dunst has a number of build dependencies that must be present before attempting - pango/cairo - libgtk-3-dev +### Building + +``` +git clone https://github.com/dunst-project/dunst.git +cd dunst +make +sudo make install +``` + +### Make parameters + +- `PREFIX=`: Set the prefix of the installation. (Default: `/usr/local`) +- `MANPREFIX=`: Set the prefix of the manpage. (Default: `${PREFIX}/share/man`) +- `SYSTEMD=(0|1)`: Enable/Disable the systemd unit. (Default: detected via `pkg-config`) +- `SERVICEDIR_SYSTEMD=`: The path to put the systemd user service file. Unused, if `SYSTEMD=0`. (Default: detected via `pkg-config`) +- `SERVICEDIR_DBUS=`: The path to put the dbus service file. (Default: detected via `pkg-config`) + Checkout the [wiki][wiki] for more information. ## Bug reports