generator: .mount unit is always needed, not depending on existence of original servi... 10/297610/3
authorKarol Lewandowski <k.lewandowsk@samsung.com>
Mon, 21 Aug 2023 11:35:45 +0000 (13:35 +0200)
committerAdam Michalski <a.michalski2@partner.samsung.com>
Wed, 23 Aug 2023 14:13:27 +0000 (16:13 +0200)
Change-Id: I70d217a9cf42b65092b7051063a7c99e4248a70d

src/systemd_generator/isu-generator

index 3594497..7ffbf35 100755 (executable)
@@ -44,9 +44,11 @@ install_units()
        rm -f "${new_srv_path}" "${new_srv_path}.tmp"
 
        cat "$srv_path" > "$new_srv_path".tmp || return 1
-       if [ -f "$SERVICES_DIR/${srv_fname}" ]; then
+       local mount_unit="run-isu-$(systemd-escape ${isu_pkg_name})-rootfs.mount"
+       if [ ! -r "$mount_unit" ]; then
                # generate mount unit for ISU image and extend the service file to use it
-               local mount_unit="run-isu-$(systemd-escape ${isu_pkg_name})-rootfs.mount"
+               # if mount unit already exists, it means it's been generated by previous
+               # install_units() invocation - for the same ISU package, but different .service file
                cat <<EOF >> "$UNITDIR/$mount_unit" || return 1
 # This unit file has been automatically generated by isu-generator.
 #
@@ -59,6 +61,7 @@ DefaultDependencies=no
 What=${PKGDIR}/${isu_pkg_name}/rootfs.img
 Where=${RUNDIR}/${isu_pkg_name}/rootfs
 EOF
+       fi
 
        cat <<EOF >> "$new_srv_path".tmp || return 1
 
@@ -66,7 +69,6 @@ EOF
 After=${mount_unit}
 BindsTo=${mount_unit}
 EOF
-       fi
 
        # make new unit visible
        mv "${new_srv_path}.tmp" "${new_srv_path}" || return 1