gutenprint: fix a build race-condition

Gutenprint install hooks run in parallel but depend on each other. This
is a race condition and might trigger a build failure (e.g on AB [0]):
| chmod 700 $WORKDIR/image/usr/libexec/cups/backend/backend_gutenprint
| chmod: cannot access '$WORKDIR/image/usr/libexec/cups/backend/backend_gutenprint': Not a directory
| make[5]: *** [Makefile:2166: install-exec-hook] Error 1

Fixes this by adding an explicit dependency between the dependent
targets.

[0]: https://autobuilder.yoctoproject.org/valkyrie/#/builders/87/builds/46/steps/33/logs/stdio

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
Yoann Congal 2025-07-04 11:51:43 +02:00 committed by Khem Raj
parent f64fa6252c
commit 1c3a75acc0
No known key found for this signature in database
GPG Key ID: BB053355919D3314
2 changed files with 63 additions and 1 deletions

View File

@ -0,0 +1,60 @@
From e3b0952fe936f90cfda9cbed368fae2143b72089 Mon Sep 17 00:00:00 2001
From: Yoann Congal <yoann.congal@smile.fr>
Date: Thu, 3 Jul 2025 15:27:04 +0200
Subject: [PATCH] cups: fix a build race-condition around empty directories
removal
In automake, install-exec and install-data happen in parallel.
install-exec installs executables and install-data finishes with
install-data-hook that removes empty directories. If install-data-hook
happen before install-exec finishes, it might remove a directory while
it is used by the install process and make it fail.
Fix this by adding an explicit dependency between install-data-hook and
install-exec.
For example, here is the log of such a failure:
| make install-data-hook
| hosttools/mkdir -p 'image/usr/libexec/cups/backend'
| make[5]: Entering directory '$WORKDIR/build/src/cups'
| Expect a number of "rmdir: Directory not empty" warnings
| /bin/bash ../../libtool --mode=install $HOSTTOOLS/install -c backend_gutenprint '$WORKDIR/image/usr/libexec/cups/backend'
# Start of the install process (from install-exec)
| These messages are harmless and should be ignored.
...
| rmdir $WORKDIR/image/usr/libexec/cups/backend
# empty /usr/libexec/cups/backend is removed (from install-data-hook)
...
| libtool: install: $HOSTTOOLS/install -c backend_gutenprint $WORKDIR/image/usr/libexec/cups/backend
# install in a non-existing directory: backend_gutenprint is installed
# as /usr/libexec/cups/backend (this is now a file instead of a
# directory)
| make install-exec-hook
| make[5]: Entering directory '$WORKDIR/build/src/cups'
| chmod 700 $WORKDIR/image/usr/libexec/cups/backend/backend_gutenprint
| chmod: cannot access '$WORKDIR/image/usr/libexec/cups/backend/backend_gutenprint': Not a directory
# chmod fails because /usr/libexec/cups/backend is a file and not a
# directory
| make[5]: *** [Makefile:2166: install-exec-hook] Error 1
Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
Upstream-Status: Submitted [https://sourceforge.net/p/gimp-print/mailman/gimp-print-devel/thread/20250703164244.1120340-1-yoann.congal%40smile.fr/#msg59202153]
---
src/cups/Makefile.am | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/src/cups/Makefile.am b/src/cups/Makefile.am
index 7928ee3..fe45c92 100644
--- a/src/cups/Makefile.am
+++ b/src/cups/Makefile.am
@@ -206,8 +206,9 @@ uninstall-local: $(INSTALL_DATA_LOCAL_DEPS) $(INSTALL_BLACKLIST)
$(RM) -f "$(DESTDIR)$(cupsdata_blacklistdir)/net.sf.gimp-print.usb-quirks"
$(RM) -f "$(DESTDIR)$(pkglibdir)/backend/gutenprint$(GUTENPRINT_MAJOR_VERSION)$(GUTENPRINT_MINOR_VERSION)+usb"
-install-data-hook:
+install-data-hook: install-exec
# Remove unused directories in install tree
+# Note: it removes "exec" directories, so it must happen after install-exec.
-@echo 'Expect a number of "rmdir: Directory not empty" warnings'
-@echo 'These messages are harmless and should be ignored.'
-rmdir $(DESTDIR)$(cups_modeldir)

View File

@ -14,7 +14,9 @@ HOMEPAGE = "http://gimp-print.sourceforge.net/"
LICENSE = "GPL-2.0-or-later"
LIC_FILES_CHKSUM = "file://COPYING;md5=59530bdf33659b29e73d4adb9f9f6552"
SRC_URI = "https://downloads.sourceforge.net/gimp-print/${BP}.tar.xz"
SRC_URI = "https://downloads.sourceforge.net/gimp-print/${BP}.tar.xz \
file://0001-cups-fix-a-build-race-condition-around-empty-directo.patch \
"
SRC_URI[sha256sum] = "db44a701d2b8e6a8931c83cec06c91226be266d23e5c189d20a39dd175f2023b"
inherit autotools gettext pkgconfig