[systemd-devel] How to handle staged installs with a Systemd unit?

Jeffrey Walton noloader at gmail.com
Thu Dec 26 12:46:20 UTC 2019


Hi Everyone,

My program package includes a systemd timer and service. I was able to
setup my Makefile for a regular install using the daemons web page
(https://www.freedesktop.org/software/systemd/man/daemon.html).

My question is, how should I handle a staged install using DESTDIR?
Specifically, should we expect the timer and service to be enabled in
the staged directory? Should we expect the timer to be started in the
directory?

The relevant pieces of my current GNUmakefile is shown below. I'm not
sure about these bits during a staged install:

    systemctl enable callboot-update.service
    systemctl enable callboot-update.timer
    systemctl start callboot-update.timer

Thanks in advance.

# https://www.gnu.org/prep/standards/html_node/Command-Variables.html
INSTALL_PROGRAM ?= install
INSTALL_DATA ?= install -m 644

# https://www.gnu.org/prep/standards/html_node/Directory-Variables.html
# and https://www.freedesktop.org/software/systemd/man/daemon.html
PREFIX ?= /opt/callboot
BINDIR ?= $(PREFIX)/bin
LIBDIR ?= $(PREFIX)/lib
SYSCONFDIR ?= $(PREFIX)/etc
DATADIR ?= $(PREFIX)/share
LOCALSTATEDIR ?= $(PREFIX)/var
SYSTEMDSYSTEMUNITDIR ?= /etc/systemd/system
...

install: directories
    ...
ifneq ($(shell ls callboot-update.service 2>/dev/null),)
    $(INSTALL_DATA) callboot-update.service $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)/
    systemctl enable callboot-update.service
endif
ifneq ($(shell ls callboot-update.timer 2>/dev/null),)
    $(INSTALL_DATA) callboot-update.timer $(DESTDIR)$(SYSTEMDSYSTEMUNITDIR)/
    systemctl enable callboot-update.timer
    systemctl start callboot-update.timer
endif


More information about the systemd-devel mailing list