Patchwork [2/8] kernel-yocto: allow building from fetcher source dir

login
register
mail settings
Submitter Bruce Ashfield
Date Feb. 27, 2013, 5:06 a.m.
Message ID <5cb5d2edd8674d9f44feae18b4d4049a5e24a23c.1361940628.git.bruce.ashfield@windriver.com>
Download mbox | patch
Permalink /patch/45189/
State Accepted
Commit d9149a0ce0e21e9d22905d1ae29196bd938cfef2
Headers show

Comments

Bruce Ashfield - Feb. 27, 2013, 5:06 a.m.
The linux-yocto recipes themselves always set S="${WORKDIR}/linux" and
arrange for the fetcher default of ${WORKDIR}/git to be renamed before
building.

Part of this rename involves an assumption that the directory used by
the fetcher can be removed as part of the renaming process, or in fact
that renaming is required.

If a derived recipe uses S="${WORKDIR}/git", the checkout phase fails
since the kernel source is removed as part of the processing.

To fix this the code now detects this situation and does not clean the
source directory before renaming the fetcher default (and in fact does
not rename it at all).

Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
---
 meta/classes/kernel-yocto.bbclass |   39 +++++++++++++++++++++----------------
 1 file changed, 22 insertions(+), 17 deletions(-)

Patch

diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass
index 368f91e..7b8e607 100644
--- a/meta/classes/kernel-yocto.bbclass
+++ b/meta/classes/kernel-yocto.bbclass
@@ -148,29 +148,34 @@  do_kernel_checkout() {
 
 	# A linux yocto SRC_URI should use the bareclone option. That
 	# ensures that all the branches are available in the WORKDIR version
-	# of the repository. 
+	# of the repository.
+	source_dir=`echo ${S} | sed 's%/$%%'`
+	source_workdir="${WORKDIR}/git"
 	if [ -d "${WORKDIR}/git/" ] && [ -d "${WORKDIR}/git/.git" ]; then
-		# we build out of {S}, so ensure that ${S} is clean and present
-		rm -rf ${S}
-		mkdir -p ${S}
-		
-		# We can fix up the kernel repository even if it wasn't a bare clone.
-		mv ${WORKDIR}/git/.git ${S}
-		rm -rf ${WORKDIR}/git/
+		# case2: the repository is a non-bare clone
+
+		# if S is WORKDIR/git, then we shouldn't be moving or deleting the tree.
+		if [ "${source_dir}" != "${source_workdir}" ]; then
+			rm -rf ${S}
+			mv ${WORKDIR}/git ${S}
+		fi
 		cd ${S}
 	elif [ -d "${WORKDIR}/git/" ] && [ ! -d "${WORKDIR}/git/.git" ]; then
-		# we build out of {S}, so ensure that ${S} is clean and present
-		rm -rf ${S}
-		mkdir -p ${S}/.git
-
-		mv ${WORKDIR}/git/* ${S}/.git
-		rm -rf ${WORKDIR}/git/
+		# case2: the repository is a bare clone
+
+		# if S is WORKDIR/git, then we shouldn't be moving or deleting the tree.
+		if [ "${source_dir}" != "${source_workdir}" ]; then
+			rm -rf ${S}
+			mkdir -p ${S}/.git
+			mv ${WORKDIR}/git/* ${S}/.git
+			rm -rf ${WORKDIR}/git/
+		fi
 		cd ${S}	
 		git config core.bare false
 	else
-	        # We have no git repository at all. To support low bandwidth options
-		# for building the kernel, we'll just convert the tree to a git repo
-	        # and let the rest of the process work unchanged
+		# case 3: we have no git repository at all. 
+		# To support low bandwidth options for building the kernel, we'll just 
+		# convert the tree to a git repo and let the rest of the process work unchanged
 	        cd ${S}
 		git init
 		git add .