generator: Ensure isu.cfg is also available in /run/isu/<PKG_NAME> 40/299540/1
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 4 Oct 2023 09:53:24 +0000 (11:53 +0200)
committerKarol Lewandowski <k.lewandowsk@samsung.com>
Wed, 4 Oct 2023 10:11:32 +0000 (12:11 +0200)
Package in /opt/isu/<PKG_NAME> can be removed/upgraded/etc. so we
can't depend on it to have valid run-time info

Change-Id: Ie86249f509dd688e76393723ca1d2b3612926a97

packaging/isu.spec
src/systemd_generator/isu-generator

index 7a72be7..6add561 100644 (file)
@@ -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
index befac2a..51720b5 100755 (executable)
@@ -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"
 }