]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
run-postinsts: Add workaround for locking deadlock issue
authorRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 28 Mar 2024 13:03:34 +0000 (13:03 +0000)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Sat, 30 Mar 2024 22:18:39 +0000 (22:18 +0000)
When run-postinsts is installed, a service is added for system which can run
while the package is still being installed. This calls "opkg configure" and if
package management is still running, it can deadlock and error.

To work around this, call fcntl-lock on the opkg lock file and if the lock
was held, it would wait to obtain it. This wait gives the package management
time to finish the install before the configure can then take the lock and run.

Note the dependency in SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS otherwise we'd see
sstate selftest failures.

Also ensure that if the configure fails, the scripts returns an error. This
applies to opkg and dpkg.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/conf/layer.conf
meta/recipes-devtools/run-postinsts/run-postinsts/run-postinsts
meta/recipes-devtools/run-postinsts/run-postinsts_1.0.bb

index 62f86f361ad9e702d2e22e4608a73fda76556ccf..efbf2610f99643ad82b9ae3bc5921530101417cf 100644 (file)
@@ -87,6 +87,7 @@ SIGGEN_EXCLUDE_SAFE_RECIPE_DEPS += " \
   sato-icon-theme->gtk+3 \
   adwaita-icon-theme->gdk-pixbuf \
   adwaita-icon-theme->gtk+3 \
+  run-postinsts->util-linux \
 "
 
 # Avoid adding bison-native to the sysroot without a specific
index 95dccb9cae11f6db415a285240563c3c47c46e25..1f3e692029c09919a997a24c46c988b5495cdf7d 100755 (executable)
@@ -81,11 +81,18 @@ remove_rcsd_link=1
 if $pm_installed; then
        case $pm in
                "ipk")
-                       eval opkg configure $append_log
+                       if ! `fcntl-lock --wait 30 /run/opkg.lock true`; then
+                               eval echo "Unable to obtain the opkg lock, deadlock?" $append_log
+                       fi
+                       if ! eval "opkg configure $append_log"; then
+                           exit 1
+                       fi
                        ;;
 
                "deb")
-                       eval dpkg --configure -a $append_log
+                       if ! eval "eval dpkg --configure -a $append_log"; then
+                           exit 1
+                       fi
                        ;;
        esac
 else
index 72ba8c02270a9d217f4f495b3084c80a1cf82105..e977942de87e732e9941be8e9177f953696f257c 100644 (file)
@@ -12,6 +12,8 @@ S = "${WORKDIR}"
 
 inherit allarch systemd update-rc.d
 
+RDEPENDS:${PN} = "util-linux-fcntl-lock"
+
 INITSCRIPT_NAME = "run-postinsts"
 INITSCRIPT_PARAMS = "start 99 S ."