From 69b66599609c6513de8d72c45fe327312b0b81ac Mon Sep 17 00:00:00 2001 From: Ed Santiago Date: Thu, 7 Oct 2021 08:10:41 -0600 Subject: Unit files: Use actual installed path for podman Don't hardcode /usr/bin/podman in unit files: instead, use template files with a path replaced at install time. Because 'make' can be invoked repeatedly, with different PREFIX, do not leave the generated files behind in our work directory: wipe them immediately after install. To get this to work, fix a longstanding bug in podman.spec.in, a PREFIX that should've been DESTDIR. Side note: #7023 made contrib/systemd/user a symlink to .../system but did not update paths in Makefile. The unrelated-looking path change you see here is a belated correction for that. Fixes: #10787 Signed-off-by: Ed Santiago --- Makefile | 17 +++++++++++++---- contrib/spec/podman.spec.in | 2 +- contrib/systemd/auto-update/podman-auto-update.service | 13 ------------- .../systemd/auto-update/podman-auto-update.service.in | 13 +++++++++++++ contrib/systemd/system/podman-restart.service | 12 ------------ contrib/systemd/system/podman-restart.service.in | 12 ++++++++++++ contrib/systemd/system/podman.service | 15 --------------- contrib/systemd/system/podman.service.in | 15 +++++++++++++++ 8 files changed, 54 insertions(+), 45 deletions(-) delete mode 100644 contrib/systemd/auto-update/podman-auto-update.service create mode 100644 contrib/systemd/auto-update/podman-auto-update.service.in delete mode 100644 contrib/systemd/system/podman-restart.service create mode 100644 contrib/systemd/system/podman-restart.service.in delete mode 100644 contrib/systemd/system/podman.service create mode 100644 contrib/systemd/system/podman.service.in diff --git a/Makefile b/Makefile index 590675d25..8af9cfd1b 100644 --- a/Makefile +++ b/Makefile @@ -770,20 +770,29 @@ install.docker-full: install.docker install.docker-docs .PHONY: install.systemd ifneq (,$(findstring systemd,$(BUILDTAGS))) -install.systemd: +PODMAN_UNIT_FILES = contrib/systemd/auto-update/podman-auto-update.service \ + contrib/systemd/system/podman.service \ + contrib/systemd/system/podman-restart.service + +%.service: %.service.in + sed -e 's;@@PODMAN@@;$(BINDIR)/podman;g' $< >$@.tmp.$$ \ + && mv -f $@.tmp.$$ $@ + +install.systemd: $(PODMAN_UNIT_FILES) install ${SELINUXOPT} -m 755 -d ${DESTDIR}${SYSTEMDDIR} ${DESTDIR}${USERSYSTEMDDIR} # User services install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.service ${DESTDIR}${USERSYSTEMDDIR}/podman-auto-update.service install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.timer ${DESTDIR}${USERSYSTEMDDIR}/podman-auto-update.timer - install ${SELINUXOPT} -m 644 contrib/systemd/user/podman.socket ${DESTDIR}${USERSYSTEMDDIR}/podman.socket - install ${SELINUXOPT} -m 644 contrib/systemd/user/podman.service ${DESTDIR}${USERSYSTEMDDIR}/podman.service - install ${SELINUXOPT} -m 644 contrib/systemd/user/podman-restart.service ${DESTDIR}${USERSYSTEMDDIR}/podman-restart.service + install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.socket ${DESTDIR}${USERSYSTEMDDIR}/podman.socket + install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.service ${DESTDIR}${USERSYSTEMDDIR}/podman.service + install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-restart.service ${DESTDIR}${USERSYSTEMDDIR}/podman-restart.service # System services install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.service ${DESTDIR}${SYSTEMDDIR}/podman-auto-update.service install ${SELINUXOPT} -m 644 contrib/systemd/auto-update/podman-auto-update.timer ${DESTDIR}${SYSTEMDDIR}/podman-auto-update.timer install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.socket ${DESTDIR}${SYSTEMDDIR}/podman.socket install ${SELINUXOPT} -m 644 contrib/systemd/system/podman.service ${DESTDIR}${SYSTEMDDIR}/podman.service install ${SELINUXOPT} -m 644 contrib/systemd/system/podman-restart.service ${DESTDIR}${SYSTEMDDIR}/podman-restart.service + rm -f $(PODMAN_UNIT_FILES) else install.systemd: endif diff --git a/contrib/spec/podman.spec.in b/contrib/spec/podman.spec.in index fa513932f..3a4026038 100644 --- a/contrib/spec/podman.spec.in +++ b/contrib/spec/podman.spec.in @@ -435,7 +435,7 @@ BUILDTAGS=$BUILDTAGS make binaries %install install -dp %{buildroot}%{_unitdir} install -dp %{buildroot}%{_usr}/lib/systemd/user -PODMAN_VERSION=%{version} %{__make} PREFIX=%{buildroot}%{_prefix} ETCDIR=%{buildroot}%{_sysconfdir} \ +PODMAN_VERSION=%{version} %{__make} DESTDIR=%{buildroot} PREFIX=%{_prefix} ETCDIR=%{_sysconfdir} \ install.bin-nobuild \ install.remote-nobuild \ %if %{with doc} diff --git a/contrib/systemd/auto-update/podman-auto-update.service b/contrib/systemd/auto-update/podman-auto-update.service deleted file mode 100644 index dc5fac8cf..000000000 --- a/contrib/systemd/auto-update/podman-auto-update.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Podman auto-update service -Documentation=man:podman-auto-update(1) -Wants=network-online.target -After=network-online.target - -[Service] -Type=oneshot -ExecStart=/usr/bin/podman auto-update -ExecStartPost=/usr/bin/podman image prune -f - -[Install] -WantedBy=multi-user.target default.target diff --git a/contrib/systemd/auto-update/podman-auto-update.service.in b/contrib/systemd/auto-update/podman-auto-update.service.in new file mode 100644 index 000000000..de4460d60 --- /dev/null +++ b/contrib/systemd/auto-update/podman-auto-update.service.in @@ -0,0 +1,13 @@ +[Unit] +Description=Podman auto-update service +Documentation=man:podman-auto-update(1) +Wants=network-online.target +After=network-online.target + +[Service] +Type=oneshot +ExecStart=@@PODMAN@@ auto-update +ExecStartPost=@@PODMAN@@ image prune -f + +[Install] +WantedBy=multi-user.target default.target diff --git a/contrib/systemd/system/podman-restart.service b/contrib/systemd/system/podman-restart.service deleted file mode 100644 index baf12b3ae..000000000 --- a/contrib/systemd/system/podman-restart.service +++ /dev/null @@ -1,12 +0,0 @@ -[Unit] -Description=Podman Start All Containers With Restart Policy Set To Always -Documentation=man:podman-start(1) -StartLimitIntervalSec=0 - -[Service] -Type=oneshot -Environment=LOGGING="--log-level=info" -ExecStart=/usr/bin/podman $LOGGING start --all --filter restart-policy=always - -[Install] -WantedBy=multi-user.target diff --git a/contrib/systemd/system/podman-restart.service.in b/contrib/systemd/system/podman-restart.service.in new file mode 100644 index 000000000..a2951e111 --- /dev/null +++ b/contrib/systemd/system/podman-restart.service.in @@ -0,0 +1,12 @@ +[Unit] +Description=Podman Start All Containers With Restart Policy Set To Always +Documentation=man:podman-start(1) +StartLimitIntervalSec=0 + +[Service] +Type=oneshot +Environment=LOGGING="--log-level=info" +ExecStart=@@PODMAN@@ $LOGGING start --all --filter restart-policy=always + +[Install] +WantedBy=multi-user.target diff --git a/contrib/systemd/system/podman.service b/contrib/systemd/system/podman.service deleted file mode 100644 index cefb13ae3..000000000 --- a/contrib/systemd/system/podman.service +++ /dev/null @@ -1,15 +0,0 @@ -[Unit] -Description=Podman API Service -Requires=podman.socket -After=podman.socket -Documentation=man:podman-system-service(1) -StartLimitIntervalSec=0 - -[Service] -Type=exec -KillMode=process -Environment=LOGGING="--log-level=info" -ExecStart=/usr/bin/podman $LOGGING system service - -[Install] -WantedBy=multi-user.target diff --git a/contrib/systemd/system/podman.service.in b/contrib/systemd/system/podman.service.in new file mode 100644 index 000000000..132671dff --- /dev/null +++ b/contrib/systemd/system/podman.service.in @@ -0,0 +1,15 @@ +[Unit] +Description=Podman API Service +Requires=podman.socket +After=podman.socket +Documentation=man:podman-system-service(1) +StartLimitIntervalSec=0 + +[Service] +Type=exec +KillMode=process +Environment=LOGGING="--log-level=info" +ExecStart=@@PODMAN@@ $LOGGING system service + +[Install] +WantedBy=multi-user.target -- cgit v1.2.3-54-g00ecf