Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revamp systemd service unit file installation #674

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ PREFIX?=/usr/local
CONFIG_DIR?=/etc/keyd
SOCKET_PATH=/var/run/keyd.socket

# If this variable is set to the empty string, no systemd unit files will be
# installed.
SYSTEMD_SYSTEM_DIR = /usr/lib/systemd/system

CFLAGS:=-DVERSION=\"v$(VERSION)\ \($(COMMIT)\)\" \
-I/usr/local/include \
-L/usr/local/lib \
Expand Down Expand Up @@ -48,17 +52,17 @@ man:
done
install:

@if [ -e /run/systemd/system ]; then \
@if [ -n '$(SYSTEMD_SYSTEM_DIR)' ]; then \
sed -e 's#@PREFIX@#$(PREFIX)#' keyd.service.in > keyd.service; \
mkdir -p $(DESTDIR)$(PREFIX)/lib/systemd/system/; \
install -Dm644 keyd.service $(DESTDIR)$(PREFIX)/lib/systemd/system/keyd.service; \
else \
echo "NOTE: systemd not found, you will need to manually add keyd to your system's init process."; \
mkdir -p '$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)'; \
install -Dm644 keyd.service '$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd.service'; \
fi

@if [ "$(VKBD)" = "usb-gadget" ]; then \
sed -e 's#@PREFIX@#$(PREFIX)#' src/vkbd/usb-gadget.service.in > src/vkbd/usb-gadget.service; \
install -Dm644 src/vkbd/usb-gadget.service $(DESTDIR)$(PREFIX)/lib/systemd/system/keyd-usb-gadget.service; \
if [ -n '$(SYSTEMD_SYSTEM_DIR)' ]; then \
sed -e 's#@PREFIX@#$(PREFIX)#' src/vkbd/usb-gadget.service.in > src/vkbd/usb-gadget.service; \
install -Dm644 src/vkbd/usb-gadget.service '$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd-usb-gadget.service'; \
fi; \
install -Dm755 src/vkbd/usb-gadget.sh $(DESTDIR)$(PREFIX)/bin/keyd-usb-gadget.sh; \
fi

Expand All @@ -81,15 +85,15 @@ install:

uninstall:
-groupdel keyd
rm -rf $(DESTDIR)$(PREFIX)/lib/systemd/system/keyd.service \
$(DESTDIR)$(PREFIX)/bin/keyd \
[ -z '$(SYSTEMD_SYSTEM_DIR)' ] || rm -f \
'$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd.service' \
'$(DESTDIR)$(SYSTEMD_SYSTEM_DIR)/keyd-usb-gadget.service'
rm -rf $(DESTDIR)$(PREFIX)/bin/keyd \
$(DESTDIR)$(PREFIX)/bin/keyd-application-mapper \
$(DESTDIR)$(PREFIX)/share/doc/keyd/ \
$(DESTDIR)$(PREFIX)/share/man/man1/keyd*.gz \
$(DESTDIR)$(PREFIX)/share/keyd/ \
$(DESTDIR)$(PREFIX)/lib/systemd/system/keyd-usb-gadget.service \
$(DESTDIR)$(PREFIX)/bin/keyd-usb-gadget.sh \
$(DESTDIR)$(PREFIX)/lib/systemd/system/keyd.service
$(DESTDIR)$(PREFIX)/bin/keyd-usb-gadget.sh
clean:
-rm -rf bin keyd.service src/vkbd/usb-gadget.service
test:
Expand Down