diff mbox series

[meta-oe] poke: Fix the reproducibility of installed scripts

Message ID 20250322220146.3969535-1-yoann.congal@smile.fr
State Accepted
Headers show
Series [meta-oe] poke: Fix the reproducibility of installed scripts | expand

Commit Message

Yoann Congal March 22, 2025, 10:01 p.m. UTC
From: Yoann Congal <yoann.congal@smile.fr>

There is a race condition between 2 actions at install around the
installed script in $pkgdatadir:
* Removal of existing scripts /usr/share/poke/*.pk
* Installation of default scripts in the same directory

Sadly, those 2 actions are not ordered. Depending on the build system load,
removal can (rarely) happen *after* the installation. In this case, no
script in present in /usr/share/poke/ when the install process end.

In OE, we always install on an empty sysroot, so, no pre-existing scripts can
exists. Remove the code that does the cleanup to avoid the
race-condition and ensure the scripts are always present.

Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
---
FWIW, I plan to report a bug to upstream.

 ...bpoke-Remove-existing-script-cleanup.patch | 43 +++++++++++++++++++
 meta-oe/recipes-devtools/poke/poke_4.2.bb     |  1 +
 2 files changed, 44 insertions(+)
 create mode 100644 meta-oe/recipes-devtools/poke/poke/0001-libpoke-Remove-existing-script-cleanup.patch

Comments

Yoann Congal March 24, 2025, 9:01 a.m. UTC | #1
Le sam. 22 mars 2025 à 23:03, Yoann Congal <yoann.congal@smile.fr> a écrit :
>
> From: Yoann Congal <yoann.congal@smile.fr>
>
> There is a race condition between 2 actions at install around the
> installed script in $pkgdatadir:
> * Removal of existing scripts /usr/share/poke/*.pk
> * Installation of default scripts in the same directory
>
> Sadly, those 2 actions are not ordered. Depending on the build system load,
> removal can (rarely) happen *after* the installation. In this case, no
> script in present in /usr/share/poke/ when the install process end.
>
> In OE, we always install on an empty sysroot, so, no pre-existing scripts can
> exists. Remove the code that does the cleanup to avoid the
> race-condition and ensure the scripts are always present.
>
> Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
> ---
> FWIW, I plan to report a bug to upstream.

You can drop this patch, upstream answered[0] that "make -j install"
is not supported. I'll integrate this into the recipe instead of a
patch.

[0]: https://sourceware.org/bugzilla/show_bug.cgi?id=32815
>
>  ...bpoke-Remove-existing-script-cleanup.patch | 43 +++++++++++++++++++
>  meta-oe/recipes-devtools/poke/poke_4.2.bb     |  1 +
>  2 files changed, 44 insertions(+)
>  create mode 100644 meta-oe/recipes-devtools/poke/poke/0001-libpoke-Remove-existing-script-cleanup.patch
>
> diff --git a/meta-oe/recipes-devtools/poke/poke/0001-libpoke-Remove-existing-script-cleanup.patch b/meta-oe/recipes-devtools/poke/poke/0001-libpoke-Remove-existing-script-cleanup.patch
> new file mode 100644
> index 0000000000..8562e36c66
> --- /dev/null
> +++ b/meta-oe/recipes-devtools/poke/poke/0001-libpoke-Remove-existing-script-cleanup.patch
> @@ -0,0 +1,43 @@
> +From 65d1c6146995216538b0224e5aefe5e8c0c69a0d Mon Sep 17 00:00:00 2001
> +From: Yoann Congal <yoann.congal@smile.fr>
> +Date: Sat, 22 Mar 2025 22:11:47 +0100
> +Subject: [PATCH] libpoke: Remove existing script cleanup
> +
> +There is a race condition between 2 actions:
> +* Removal of existing scripts $(pkgdatadir)/*.pk in "install-data-local"
> +* Installation of default scripts with automake:
> +  "dist_pkgdata_DATA = pkl-rt.pk pkl-config.pk std.pk std-types.pk"
> +
> +Sadly, "install-data-local" and the generated target from
> +"dist_pkgdata_DATA" are not ordered. Depending on the build system load,
> +removal can (rarely) happen *after* the installation. In this case, no
> +script in present in $(pkgdatadir) when the install process end.
> +
> +In OE, we always install on an empty sysroot, so, no pre-existing scripts can
> +exists. Remove the code that does the cleanup to avoid the race-condition.
> +
> +Upstream-Status: Inappropriate [OE specific]
> +
> +Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
> +---
> + libpoke/Makefile.am | 9 ---------
> + 1 file changed, 9 deletions(-)
> +
> +diff --git a/libpoke/Makefile.am b/libpoke/Makefile.am
> +index 6eff76b..965252b 100644
> +--- a/libpoke/Makefile.am
> ++++ b/libpoke/Makefile.am
> +@@ -268,13 +268,4 @@ pvm-vm1.c: pvm-vm.h
> + pvm-vm2.c: pvm-vm1.c
> +       @{ test -f $(srcdir)/pvm-vm2.c && test ! $(srcdir)/pvm-vm2.c -ot $(srcdir)/pvm-vm1.c; } || $(MAKE) generate-vm-files
> +
> +-# In order to avoid problems with older installations, we remove the
> +-# Poke scripts installed in $(pkgdatadir).  Note however that other
> +-# programs may install scripts in subdirectories under $(pkgdatadir),
> +-# and these are not to be touched.
> +-install-data-local: uninstall-sources
> +-uninstall-local: uninstall-sources
> +-uninstall-sources:
> +-      rm -f $(DESTDIR)$(pkgdatadir)/*.pk
> +-
> + # End of Makefile.am
> diff --git a/meta-oe/recipes-devtools/poke/poke_4.2.bb b/meta-oe/recipes-devtools/poke/poke_4.2.bb
> index a31b6605a2..3e12ddb11c 100644
> --- a/meta-oe/recipes-devtools/poke/poke_4.2.bb
> +++ b/meta-oe/recipes-devtools/poke/poke_4.2.bb
> @@ -7,6 +7,7 @@ LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
>
>  SRC_URI = "${GNU_MIRROR}/poke/poke-${PV}.tar.gz \
>            file://0003-configure.ac-HELP2MAN-replace-by-true-when-cross-com.patch \
> +          file://0001-libpoke-Remove-existing-script-cleanup.patch \
>            "
>
>  DEPENDS = "flex-native bison-native bdwgc readline"
diff mbox series

Patch

diff --git a/meta-oe/recipes-devtools/poke/poke/0001-libpoke-Remove-existing-script-cleanup.patch b/meta-oe/recipes-devtools/poke/poke/0001-libpoke-Remove-existing-script-cleanup.patch
new file mode 100644
index 0000000000..8562e36c66
--- /dev/null
+++ b/meta-oe/recipes-devtools/poke/poke/0001-libpoke-Remove-existing-script-cleanup.patch
@@ -0,0 +1,43 @@ 
+From 65d1c6146995216538b0224e5aefe5e8c0c69a0d Mon Sep 17 00:00:00 2001
+From: Yoann Congal <yoann.congal@smile.fr>
+Date: Sat, 22 Mar 2025 22:11:47 +0100
+Subject: [PATCH] libpoke: Remove existing script cleanup
+
+There is a race condition between 2 actions:
+* Removal of existing scripts $(pkgdatadir)/*.pk in "install-data-local"
+* Installation of default scripts with automake:
+  "dist_pkgdata_DATA = pkl-rt.pk pkl-config.pk std.pk std-types.pk"
+
+Sadly, "install-data-local" and the generated target from
+"dist_pkgdata_DATA" are not ordered. Depending on the build system load,
+removal can (rarely) happen *after* the installation. In this case, no
+script in present in $(pkgdatadir) when the install process end.
+
+In OE, we always install on an empty sysroot, so, no pre-existing scripts can
+exists. Remove the code that does the cleanup to avoid the race-condition.
+
+Upstream-Status: Inappropriate [OE specific]
+
+Signed-off-by: Yoann Congal <yoann.congal@smile.fr>
+---
+ libpoke/Makefile.am | 9 ---------
+ 1 file changed, 9 deletions(-)
+
+diff --git a/libpoke/Makefile.am b/libpoke/Makefile.am
+index 6eff76b..965252b 100644
+--- a/libpoke/Makefile.am
++++ b/libpoke/Makefile.am
+@@ -268,13 +268,4 @@ pvm-vm1.c: pvm-vm.h
+ pvm-vm2.c: pvm-vm1.c
+ 	@{ test -f $(srcdir)/pvm-vm2.c && test ! $(srcdir)/pvm-vm2.c -ot $(srcdir)/pvm-vm1.c; } || $(MAKE) generate-vm-files
+ 
+-# In order to avoid problems with older installations, we remove the
+-# Poke scripts installed in $(pkgdatadir).  Note however that other
+-# programs may install scripts in subdirectories under $(pkgdatadir),
+-# and these are not to be touched.
+-install-data-local: uninstall-sources
+-uninstall-local: uninstall-sources
+-uninstall-sources:
+-	rm -f $(DESTDIR)$(pkgdatadir)/*.pk
+-
+ # End of Makefile.am
diff --git a/meta-oe/recipes-devtools/poke/poke_4.2.bb b/meta-oe/recipes-devtools/poke/poke_4.2.bb
index a31b6605a2..3e12ddb11c 100644
--- a/meta-oe/recipes-devtools/poke/poke_4.2.bb
+++ b/meta-oe/recipes-devtools/poke/poke_4.2.bb
@@ -7,6 +7,7 @@  LIC_FILES_CHKSUM = "file://COPYING;md5=d32239bcb673463ab874e80d47fae504"
 
 SRC_URI = "${GNU_MIRROR}/poke/poke-${PV}.tar.gz \
           file://0003-configure.ac-HELP2MAN-replace-by-true-when-cross-com.patch \
+          file://0001-libpoke-Remove-existing-script-cleanup.patch \
           "
 
 DEPENDS = "flex-native bison-native bdwgc readline"