diff mbox series

[RFC,8/9] insane/do_qa_unpack: add checks that ensure S is set correctly

Message ID 20250610094400.1653931-8-alex.kanavin@gmail.com
State New
Headers show
Series [RFC,1/9] bitbake.conf: set BB_GIT_DEFAULT_DESTSUFFIX to match default S value | expand

Commit Message

Alexander Kanavin June 10, 2025, 9:43 a.m. UTC
From: Alexander Kanavin <alex@linutronix.de>

The checks are fatal, as this avoids rather more cryptic errors further
down the build. Example:

ERROR: gnu-config-native-20240823+git-r0 do_unpack: Recipes that set S = "${WORKDIR}/git" or S = "${UNPACKDIR}/git" should remove that assignment, as S set by bitbake.conf in oe-core now works.
ERROR: perlcross-native-1.6.2-r0 do_unpack: S should be set relative to UNPACKDIR, e.g. replace WORKDIR with UNPACKDIR in "S = ${WORKDIR}/perl-cross-${PV}"

Dropping the S = ${WORKDIR}/git assignment (addressing the first error) can be done
with a single sed command when there is a lot of recipes:

sed -i "/^S = \"\${WORKDIR}\/git\"/d" `find . -name *.bb`

Replacing WORKDIR with UNPACKDIR can be done similarly, but should be done after
the removals:

sed -i "s/^S = \"\${WORKDIR}\//S = \"\${UNPACKDIR}\//g" `find . -name *.bb`

Signed-off-by: Alexander Kanavin <alex@linutronix.de>
---
 meta/classes-global/insane.bbclass | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Jason Schonberg June 10, 2025, 4:04 p.m. UTC | #1
> From: Alexander Kanavin <alex@linutronix.de>
> 
> The checks are fatal, as this avoids rather more cryptic errors further
> down the build. Example:
> 
> ERROR: gnu-config-native-20240823+git-r0 do_unpack: Recipes that set S = "${WORKDIR}/git" or S = "${UNPACKDIR}/git" should remove that assignment, as S set by bitbake.conf in oe-core now works.
> ERROR: perlcross-native-1.6.2-r0 do_unpack: S should be set relative to UNPACKDIR, e.g. replace WORKDIR with UNPACKDIR in "S = ${WORKDIR}/perl-cross-${PV}"
> 
> Dropping the S = ${WORKDIR}/git assignment (addressing the first error) can be done
> with a single sed command when there is a lot of recipes:
> 
> sed -i "/^S = \"\${WORKDIR}\/git\"/d" `find . -name *.bb`

Perhaps, given the patches that you are posting, your find commands should cover the include files too?

 `find . -name *.bb -o -name *.inc`

Thanks,
Jason
Alexander Kanavin June 11, 2025, 9:07 a.m. UTC | #2
On Tue, 10 Jun 2025 at 18:04, Jason Schonberg <schonm@gmail.com> wrote:
> Perhaps, given the patches that you are posting, your find commands should cover the include files too?
>
>  `find . -name *.bb -o -name *.inc`

Yes, good idea. And *.bbclass too. I adjusted the commit message.

Alex
diff mbox series

Patch

diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass
index eb8591f6242..0a0a38a3b43 100644
--- a/meta/classes-global/insane.bbclass
+++ b/meta/classes-global/insane.bbclass
@@ -1431,6 +1431,14 @@  Rerun configure task after fixing this."""
 python do_qa_unpack() {
     src_uri = d.getVar('SRC_URI')
     s_dir = d.getVar('S')
+    s_dir_orig = d.getVar('S', False)
+
+    if s_dir_orig == '${WORKDIR}/git' or s_dir_orig == '${UNPACKDIR}/git':
+        bb.fatal('Recipes that set S = "${WORKDIR}/git" or S = "${UNPACKDIR}/git" should remove that assignment, as S set by bitbake.conf in oe-core now works.')
+
+    if '${WORKDIR}' in s_dir_orig:
+        bb.fatal('S should be set relative to UNPACKDIR, e.g. replace WORKDIR with UNPACKDIR in "S = {}"'.format(s_dir_orig))
+
     if src_uri and not os.path.exists(s_dir):
         bb.warn('%s: the directory %s (%s) pointed to by the S variable doesn\'t exist - please set S within the recipe to point to where the source has been unpacked to' % (d.getVar('PN'), d.getVar('S', False), s_dir))
 }