From e5175e4c51ca6c1d5c05d1740fb37ca0ffb95e20 Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Wed, 6 Sep 2023 00:32:56 +0200 Subject: [PATCH] generator: Ensure mount units are started at boot User session units can not depend on .mount units, so system units have to start these even if it will be used much later. Change-Id: I54c26a1e8eb57cbf6cbe0ea73c742630b9d0bdbf --- packaging/isu.spec | 2 +- src/systemd_generator/isu-generator | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/packaging/isu.spec b/packaging/isu.spec index 2b17c79..77f069c 100644 --- a/packaging/isu.spec +++ b/packaging/isu.spec @@ -1,6 +1,6 @@ Summary: Individual Service Upgrade support Name: isu -Version: 8.0.2 +Version: 8.0.3 Release: 1 Source0: %{name}-%{version}.tar.gz License: MIT diff --git a/src/systemd_generator/isu-generator b/src/systemd_generator/isu-generator index 5db6da1..24e7455 100755 --- a/src/systemd_generator/isu-generator +++ b/src/systemd_generator/isu-generator @@ -48,12 +48,24 @@ install_units() local mount_unit="run-isu-$(systemd-escape ${isu_pkg_name})-rootfs.mount" local confd="${new_srv_path}.d" mkdir -p "${confd}" - cat <> "$confd/isu.conf.tmp" || return 1 + if [ "$INSTANCE" = "system" ]; then + cat <> "$confd/isu.conf.tmp" || return 1 +# Automatically generated by $0 [Unit] After=${mount_unit} BindsTo=${mount_unit} EOF + else +# User session unit can not depend on system session units, thus we can't really use After=/etc. here. +# However, given that we guarantee that isu .mount units are mounted in local-fs.target, which is part +# of basic.target, it should be enough to depend on the DefaultDependencies logic. + cat <> "$confd/isu.conf.tmp" || return 1 +# Automatically generated by $0 +[Unit] +DefaultDependencies=yes +EOF + fi # make new unit visible mv "${confd}/isu.conf.tmp" "${confd}/isu.conf" || return 1 @@ -80,17 +92,18 @@ install_mount_unit() # install_mount_unit() invocation - for the same ISU package, but different # .service file cat <> "$UNITDIR/$mount_unit" || return 1 -# This unit file has been automatically generated by isu-generator. -# -# Do not edit this file as it will be re-created at next generator run. - +# Automatically generated by $0 [Unit] DefaultDependencies=no +Before=local-fs.target [Mount] What=${PKGDIR}/${isu_pkg_name}/rootfs.img Where=${RUNDIR}/${isu_pkg_name}/rootfs EOF + mkdir -p "$UNITDIR/local-fs.target.wants" + ln -s "../$mount_unit" "$UNITDIR/local-fs.target.wants/" + fi return 0 -- 2.7.4