Skip to content

Commit

Permalink
fix: Improve systemd service packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
mmstick committed Mar 31, 2022
1 parent 1e1599a commit 46e781a
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 15 deletions.
24 changes: 11 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,19 +1,16 @@
prefix ?= /usr
sysconfdir ?= /etc
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
includedir = $(prefix)/include
datarootdir = $(prefix)/share
datadir = $(datarootdir)
datadir = $(prefix)/share

SRC = Cargo.toml Cargo.lock Makefile $(shell find src -type f -wholename '*src/*.rs')

.PHONY: all clean distclean install uninstall update

BIN=system76-power
RDD=com.system76.PowerDaemon
POLICY=com.system76.powerdaemon
ID=com.system76.PowerDaemon

DEBUG ?= 0
ifeq ($(DEBUG),0)
Expand All @@ -35,17 +32,18 @@ distclean:
rm -rf .cargo vendor vendor.tar.xz

install: all
install -D -m 0644 "data/$(ID).conf" "$(DESTDIR)$(datadir)/dbus-1/system.d/$(ID).conf"
install -D -m 0644 "data/$(ID).policy" "$(DESTDIR)$(datadir)/polkit-1/actions/$(ID).policy"
install -D -m 0644 "data/$(ID).service" "$(DESTDIR)$(datadir)/systemd/system/$(ID).service"
install -D -m 0644 "data/$(ID).xml" "$(DESTDIR)$(datadir)/dbus-1/interfaces/$(ID).xml"
install -D -m 0755 "target/release/$(BIN)" "$(DESTDIR)$(bindir)/$(BIN)"
install -D -m 0644 "data/$(RDD).xml" "$(DESTDIR)$(sysconfdir)/dbus-1/interfaces/$(RDD).xml"
install -D -m 0644 "data/$(BIN).conf" "$(DESTDIR)$(sysconfdir)/dbus-1/system.d/$(BIN).conf"
install -D -m 0644 "debian/$(BIN).service" "$(DESTDIR)$(sysconfdir)/systemd/system/$(BIN).service"
install -D -m 0644 "data/$(POLICY).policy" $(DESTDIR)$(datadir)/polkit-1/actions/$(POLICY).policy

uninstall:
rm -f "$(DESTDIR)$(bindir)/$(BIN)"
rm -f "$(DESTDIR)$(sysconfdir)/dbus-1/system.d/$(BIN).conf"
rm -f "$(DESTDIR)$(sysconfdir)/systemd/system/$(BIN).service"
rm -f "$(DESTDIR)$(sysconfdir)/dbus-1/interfaces/$(RDD).xml"
rm -f "$(DESTDIR)$(bindir)/$(ID)"
rm -f "$(DESTDIR)$(datadir)/dbus-1/interfaces/$(ID).xml"
rm -f "$(DESTDIR)$(datadir)/dbus-1/system.d/$(ID).conf"
rm -f "$(DESTDIR)$(datadir)/polkit-1/actions/$(ID).policy"
rm -f "$(DESTDIR)$(datadir)/systemd/system/$(ID).service"

update:
cargo update
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 4 additions & 2 deletions debian/rules
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#!/usr/bin/make -f

export sysconfdir = "/usr/share/"
export VENDORED ?= 1
VENDOR ?= 1
CLEAN ?= 1

%:
Expand All @@ -14,6 +13,9 @@ override_dh_auto_build:
override_dh_auto_install:
dh_auto_install --destdir="debian/tmp"

override_dh_installsystemd:
dh_installsystemd --name=com.system76.PowerDaemon

override_dh_auto_clean:
ifeq ($(CLEAN),1)
make clean
Expand Down
11 changes: 11 additions & 0 deletions debian/system76-power.com.system76.PowerDaemon.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[Unit]
Description=System76 Power Daemon

[Service]
ExecStart=/usr/bin/system76-power daemon
Restart=on-failure
Type=dbus
BusName=com.system76.PowerDaemon

[Install]
WantedBy=multi-user.target

0 comments on commit 46e781a

Please sign in to comment.