diff mbox series

[2/5] cpan: survive the Makefile that MakeMaker rebuilds under us

Message ID 20260922092411.262885-2-f_l_k@t-online.de
State New
Headers show
Series [1/5] gcr: initialize libgcrypt from the secret exchange | expand

Commit Message

Markus Volk Sept. 22, 2026, 9:23 a.m. UTC
ExtUtils::MakeMaker makes the generated Makefile depend on Config.pm and
config.h from the perl it was configured against. do_prepare_recipe_sysroot
stages those files fresh on every run, so their mtime can end up newer than
a Makefile written by a do_configure that is still valid. make then
regenerates the Makefile, prints "Please rerun the make command" and exits
non-zero, which fails do_compile or do_install. Run make a second time in
that case, which is what MakeMaker asks for; a run that fails for any other
reason fails again. Also drop a stale Makefile before Makefile.PL runs, so
a configure in a used work directory does not start from old settings.

Reproduced with liburi-perl by touching Config.pm and config.h in the
recipe sysroot and forcing do_install: it failed before the change and
succeeds after it.

AI-Generated: Uses Claude Code (Claude Opus 5)
Signed-off-by: Markus Volk <f_l_k@t-online.de>
---
 meta/classes-recipe/cpan.bbclass | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/cpan.bbclass b/meta/classes-recipe/cpan.bbclass
index dbf44da9d2..0f7384786f 100644
--- a/meta/classes-recipe/cpan.bbclass
+++ b/meta/classes-recipe/cpan.bbclass
@@ -23,6 +23,10 @@  export PERLHOSTLIB = "${STAGING_LIBDIR_NATIVE}/perl5/${@get_perl_version(d)}/"
 export PERLHOSTARCHLIB = "${STAGING_LIBDIR_NATIVE}/perl5/${@get_perl_version(d)}/${@get_perl_hostarch(d)}/"
 
 cpan_do_configure () {
+	# A Makefile left behind by an earlier configure run would be used with the
+	# settings it was generated with, so start from the Makefile.PL every time.
+	rm -f Makefile
+
 	yes '' | perl ${EXTRA_PERLFLAGS} Makefile.PL INSTALLDIRS=vendor NO_PERLLOCAL=1 NO_PACKLIST=1 PERL=$(which perl) ${EXTRA_CPANFLAGS}
 
 	# Makefile.PLs can exit with success without generating a
@@ -57,12 +61,17 @@  do_configure:append:class-nativesdk() {
            -e 's:LD_RUN_PATH ?= ?"?[^"]*"?::g'
 }
 
+# ExtUtils::MakeMaker regenerates the Makefile when the staged perl has become
+# newer than it, and then exits asking for make to be rerun. Do that instead of
+# failing the task; a run that fails for any other reason fails again.
 cpan_do_compile () {
-	oe_runmake PASTHRU_INC="${CFLAGS}" LD="${CCLD}"
+	oe_runmake_call PASTHRU_INC="${CFLAGS}" LD="${CCLD}" || \
+		oe_runmake PASTHRU_INC="${CFLAGS}" LD="${CCLD}"
 }
 
 cpan_do_install () {
-	oe_runmake DESTDIR="${D}" install_vendor
+	oe_runmake_call DESTDIR="${D}" install_vendor || \
+		oe_runmake DESTDIR="${D}" install_vendor
 	for PERLSCRIPT in `grep -rIEl '#! *${bindir}/perl-native.*/perl' ${D}`; do
 		sed -i -e 's|${bindir}/perl-native.*/perl|/usr/bin/env nativeperl|' $PERLSCRIPT
 	done