diff mbox series

[2/4] classes/lib/scripts: Initial WORKDIR -> UNPACKDIR updates

Message ID 20240501215643.3386307-2-richard.purdie@linuxfoundation.org
State Accepted, archived
Commit 86fec41b1e809d1a2fa2feadc26d29020df53d39
Headers show
Series [1/4] base/bitbake.conf: Introduce UNPACKDIR | expand

Commit Message

Richard Purdie May 1, 2024, 9:56 p.m. UTC
Work through the initial issues I found where we need to change WORKDIR
to UNPACKDIR.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 meta/classes-recipe/kernel-yocto.bbclass | 38 ++++++++++++------------
 meta/classes-recipe/kernel.bbclass       |  4 +--
 meta/classes-recipe/ptest.bbclass        |  4 +--
 meta/lib/oe/patch.py                     |  8 ++---
 scripts/lib/recipetool/append.py         |  6 ++--
 5 files changed, 30 insertions(+), 30 deletions(-)
diff mbox series

Patch

diff --git a/meta/classes-recipe/kernel-yocto.bbclass b/meta/classes-recipe/kernel-yocto.bbclass
index 9a86616dad4..6468e8aa903 100644
--- a/meta/classes-recipe/kernel-yocto.bbclass
+++ b/meta/classes-recipe/kernel-yocto.bbclass
@@ -63,7 +63,7 @@  def find_sccs(d):
     return sources_list
 
 # check the SRC_URI for "kmeta" type'd git repositories. Return the name of
-# the repository as it will be found in WORKDIR
+# the repository as it will be found in UNPACKDIR
 def find_kernel_feature_dirs(d):
     feature_dirs=[]
     fetch = bb.fetch2.Fetch([], d)
@@ -147,24 +147,24 @@  do_kernel_metadata() {
 	# from the source tree, into a common location and normalized "defconfig" name,
 	# where the rest of the process will include and incoroporate it into the build
 	#
-	# If the fetcher has already placed a defconfig in WORKDIR (from the SRC_URI),
+	# If the fetcher has already placed a defconfig in UNPACKDIR (from the SRC_URI),
 	# we don't overwrite it, but instead warn the user that SRC_URI defconfigs take
 	# precendence.
 	#
 	if [ -n "${KBUILD_DEFCONFIG}" ]; then
 		if [ -f "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}" ]; then
-			if [ -f "${WORKDIR}/defconfig" ]; then
+			if [ -f "${UNPACKDIR}/defconfig" ]; then
 				# If the two defconfig's are different, warn that we overwrote the
-				# one already placed in WORKDIR
-				cmp "${WORKDIR}/defconfig" "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}"
+				# one already placed in UNPACKDIR
+				cmp "${UNPACKDIR}/defconfig" "${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG}"
 				if [ $? -ne 0 ]; then
-					bbdebug 1 "detected SRC_URI or unpatched defconfig in WORKDIR. ${KBUILD_DEFCONFIG} copied over it"
+					bbdebug 1 "detected SRC_URI or unpatched defconfig in UNPACKDIR. ${KBUILD_DEFCONFIG} copied over it"
 				fi
-				cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${WORKDIR}/defconfig
+				cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${UNPACKDIR}/defconfig
 			else
-				cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${WORKDIR}/defconfig
+				cp -f ${S}/arch/${ARCH}/configs/${KBUILD_DEFCONFIG} ${UNPACKDIR}/defconfig
 			fi
-			in_tree_defconfig="${WORKDIR}/defconfig"
+			in_tree_defconfig="${UNPACKDIR}/defconfig"
 		else
 			bbfatal "A KBUILD_DEFCONFIG '${KBUILD_DEFCONFIG}' was specified, but not present in the source tree (${S}/arch/${ARCH}/configs/)"
 		fi
@@ -178,7 +178,7 @@  do_kernel_metadata() {
 		patches="${@" ".join(find_patches(d,'kernel-meta'))}"
 		if [ -n "$patches" ]; then
 		    (
-			    cd ${WORKDIR}/kernel-meta
+			    cd ${UNPACKDIR}/kernel-meta
 
 			    # take the SRC_URI patches, and create a series file
 			    # this is required to support some better processing
@@ -193,11 +193,11 @@  do_kernel_metadata() {
 			    # handling the rest of the kernel. This allows us
 			    # more flexibility for handling failures or advanced
 			    # mergeing functinoality
-			    message=$(kgit-s2q --gen -v --patches ${WORKDIR}/kernel-meta 2>&1)
+			    message=$(kgit-s2q --gen -v --patches ${UNPACKDIR}/kernel-meta 2>&1)
 			    if [ $? -ne 0 ]; then
 				# setup to try the patch again
 				kgit-s2q --prev
-				bberror "Problem applying patches to: ${WORKDIR}/kernel-meta"
+				bberror "Problem applying patches to: ${UNPACKDIR}/kernel-meta"
 				bbfatal_log "\n($message)"
 			    fi
 			)
@@ -232,12 +232,12 @@  do_kernel_metadata() {
 	# SRC_URI. If they were supplied, we convert them into include directives
 	# for the update part of the process
 	for f in ${feat_dirs}; do
-		if [ -d "${WORKDIR}/$f/kernel-meta" ]; then
-			includes="$includes -I${WORKDIR}/$f/kernel-meta"
-		elif [ -d "${WORKDIR}/../oe-local-files/$f" ]; then
-			includes="$includes -I${WORKDIR}/../oe-local-files/$f"
-	        elif [ -d "${WORKDIR}/$f" ]; then
-			includes="$includes -I${WORKDIR}/$f"
+		if [ -d "${UNPACKDIR}/$f/kernel-meta" ]; then
+			includes="$includes -I${UNPACKDIR}/$f/kernel-meta"
+		elif [ -d "${UNPACKDIR}/../oe-local-files/$f" ]; then
+			includes="$includes -I${UNPACKDIR}/../oe-local-files/$f"
+	        elif [ -d "${UNPACKDIR}/$f" ]; then
+			includes="$includes -I${UNPACKDIR}/$f"
 		fi
 	done
 	for s in ${sccs} ${patches}; do
@@ -460,7 +460,7 @@  do_kernel_configme() {
 			config_flags=""
 			;;
 		*)
-			if [ -f ${WORKDIR}/defconfig ]; then
+			if [ -f ${UNPACKDIR}/defconfig ]; then
 				config_flags="-n"
 			fi
 			;;
diff --git a/meta/classes-recipe/kernel.bbclass b/meta/classes-recipe/kernel.bbclass
index c0a2056fec5..d6eedf942cc 100644
--- a/meta/classes-recipe/kernel.bbclass
+++ b/meta/classes-recipe/kernel.bbclass
@@ -679,8 +679,8 @@  kernel_do_configure() {
 
 	# Copy defconfig to .config if .config does not exist. This allows
 	# recipes to manage the .config themselves in do_configure:prepend().
-	if [ -f "${WORKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
-		cp "${WORKDIR}/defconfig" "${B}/.config"
+	if [ -f "${UNPACKDIR}/defconfig" ] && [ ! -f "${B}/.config" ]; then
+		cp "${UNPACKDIR}/defconfig" "${B}/.config"
 	fi
 
 	${KERNEL_CONFIG_COMMAND}
diff --git a/meta/classes-recipe/ptest.bbclass b/meta/classes-recipe/ptest.bbclass
index 348d729aef1..0941572f8f3 100644
--- a/meta/classes-recipe/ptest.bbclass
+++ b/meta/classes-recipe/ptest.bbclass
@@ -53,8 +53,8 @@  do_install_ptest() {
 }
 
 do_install_ptest_base() {
-    if [ -f ${WORKDIR}/run-ptest ]; then
-        install -D ${WORKDIR}/run-ptest ${D}${PTEST_PATH}/run-ptest
+    if [ -f ${UNPACKDIR}/run-ptest ]; then
+        install -D ${UNPACKDIR}/run-ptest ${D}${PTEST_PATH}/run-ptest
     fi
 
     grep -q install-ptest: Makefile 2>/dev/null && oe_runmake DESTDIR=${D}${PTEST_PATH} install-ptest
diff --git a/meta/lib/oe/patch.py b/meta/lib/oe/patch.py
index 60a0cc82914..58c6e34fe83 100644
--- a/meta/lib/oe/patch.py
+++ b/meta/lib/oe/patch.py
@@ -882,7 +882,7 @@  class UserResolver(Resolver):
             os.chdir(olddir)
 
 
-def patch_path(url, fetch, workdir, expand=True):
+def patch_path(url, fetch, unpackdir, expand=True):
     """Return the local path of a patch, or return nothing if this isn't a patch"""
 
     local = fetch.localpath(url)
@@ -891,7 +891,7 @@  def patch_path(url, fetch, workdir, expand=True):
     base, ext = os.path.splitext(os.path.basename(local))
     if ext in ('.gz', '.bz2', '.xz', '.Z'):
         if expand:
-            local = os.path.join(workdir, base)
+            local = os.path.join(unpackdir, base)
         ext = os.path.splitext(base)[1]
 
     urldata = fetch.ud[url]
@@ -905,12 +905,12 @@  def patch_path(url, fetch, workdir, expand=True):
     return local
 
 def src_patches(d, all=False, expand=True):
-    workdir = d.getVar('WORKDIR')
+    unpackdir = d.getVar('UNPACKDIR')
     fetch = bb.fetch2.Fetch([], d)
     patches = []
     sources = []
     for url in fetch.urls:
-        local = patch_path(url, fetch, workdir, expand)
+        local = patch_path(url, fetch, unpackdir, expand)
         if not local:
             if all:
                 local = fetch.localpath(url)
diff --git a/scripts/lib/recipetool/append.py b/scripts/lib/recipetool/append.py
index 341e8933057..10945d60084 100644
--- a/scripts/lib/recipetool/append.py
+++ b/scripts/lib/recipetool/append.py
@@ -101,7 +101,7 @@  def determine_file_source(targetpath, rd):
     import oe.recipeutils
 
     # See if it's in do_install for the recipe
-    workdir = rd.getVar('WORKDIR')
+    unpackdir = rd.getVar('UNPACKDIR')
     src_uri = rd.getVar('SRC_URI')
     srcfile = ''
     modpatches = []
@@ -113,9 +113,9 @@  def determine_file_source(targetpath, rd):
         if not srcpath.startswith('/'):
             # Handle non-absolute path
             srcpath = os.path.abspath(os.path.join(rd.getVarFlag('do_install', 'dirs').split()[-1], srcpath))
-        if srcpath.startswith(workdir):
+        if srcpath.startswith(unpackdir):
             # OK, now we have the source file name, look for it in SRC_URI
-            workdirfile = os.path.relpath(srcpath, workdir)
+            workdirfile = os.path.relpath(srcpath, unpackdir)
             # FIXME this is where we ought to have some code in the fetcher, because this is naive
             for item in src_uri.split():
                 localpath = bb.fetch2.localpath(item, rd)