From 8711b1a38494379cb80dd4eadf5461866f45ac0d Mon Sep 17 00:00:00 2001 From: Karol Lewandowski Date: Wed, 4 Oct 2023 11:53:24 +0200 Subject: [PATCH] generator: Ensure isu.cfg is also available in /run/isu/ Package in /opt/isu/ can be removed/upgraded/etc. so we can't depend on it to have valid run-time info Change-Id: Ie86249f509dd688e76393723ca1d2b3612926a97 --- packaging/isu.spec | 2 +- src/systemd_generator/isu-generator | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/packaging/isu.spec b/packaging/isu.spec index 7a72be7..6add561 100644 --- a/packaging/isu.spec +++ b/packaging/isu.spec @@ -1,6 +1,6 @@ Summary: Individual Service Upgrade support Name: isu -Version: 8.0.12 +Version: 8.0.13 Release: 1 Source0: %{name}-%{version}.tar.gz License: MIT diff --git a/src/systemd_generator/isu-generator b/src/systemd_generator/isu-generator index befac2a..51720b5 100755 --- a/src/systemd_generator/isu-generator +++ b/src/systemd_generator/isu-generator @@ -5,6 +5,7 @@ set -e PKGDIR="/opt/isu" RUNDIR="/run/isu" +ISUCFG="isu.cfg" # Public key will be checked only if below variable is set #PUBKEY="/path/to/publickey.pem" @@ -71,14 +72,28 @@ EOF return 0 } -install_mount_unit() +setup_isu_run_dir() { - local isu_pkg_name="$1" + local isu_pkg_dir="$1" + local isu_pkg_name="$2" + local isu_pkg_run="$RUNDIR/$isu_pkg_name" + + if ! mkdir -p "$isu_pkg_run/rootfs"; then + log "Unable to create needed directory hierarchy at $isu_pkg_run/rootfs - skipping ISU package" + return 1 + fi - if ! mkdir -p "$RUNDIR/$isu_pkg_name/rootfs"; then - log "Unable to create directory to mount $isu_pkg_dir's rootfs - skipping ISU package" + if ! install -m0644 -o root -g root --context=_ "$isu_pkg_dir/$ISUCFG" "$isu_pkg_run/$ISUCFG"; then + log "Unable to setup essential ISU configuration - skipping ISU package" return 1 fi +} + +install_mount_unit() +{ + local isu_pkg_name="$1" + + if ! test -d "$RUNDIR/$isu_pkg_name/rootfs"; then return 1; fi local mount_unit="run-isu-$(systemd-escape ${isu_pkg_name})-rootfs.mount" if [ ! -r "$UNITDIR/$mount_unit" ]; then @@ -142,6 +157,7 @@ isu_prepare_system() return 1 fi + setup_isu_run_dir "$isu_pkg_dir" "$isu_pkg_name" install_mount_unit "$isu_pkg_name" } -- 2.7.4