Skip to contentSkip to conversation

linux-yocto: make validate_branches handle non BSP branches

PATCH In review Bruce Ashfield 3 participants 7 messages Aug 13, 2012 – Aug 24, 2012

lore
Share & tools
lore
#0 lore raw

cover linux-yocto: make validate_branches handle non BSP branches

Scott,

Here's a fix for validate_branches that comes from a pending master change that I've been running for 3 weeks, and one that TomZ has tested in his yocto BSP work on denzil.

It fixes some BSP use cases that involve setting a specific SRCREV on a base branch, so that a BSP branch that doesn't yet exist can be created off of that known base. Previously only an existing BSP branch could have it's SRCREV restricted.

cc Tom Zanussi <[email protected]>

Cheers,

Bruce

The following changes since commit 73cdebf60df225ee10f2eb215935be3b61e1b831:

documentation/dev-manual/dev-manual-kernel-appendix.xml: Add note about conflict (2012-06-29 15:54:26 +0100)

are available in the git repository at:
git://git.pokylinux.org/poky-contrib zedd/kernel-denzil
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=zedd/kernel-denzil

Bruce Ashfield (1):
linux-yocto: allow do_validate_branches to handle all branches

 meta/classes/kernel-yocto.bbclass |  119 +++++++++++++++++++++++++------------
 1 files changed, 80 insertions(+), 39 deletions(-)
Signature · 1 line
1.7.5.4
#1 lore raw

PATCH 1/1 linux-yocto: allow do_validate_branches to handle all branches

Branch validation will not restrict a branch that doesn't exist in the tree at the time of validation (since you can't reset a SRCREV on a non-existent branch). This restriction can be removed by looking for all branches that contain the specified SRCREV and forcing them to that value.

---
 meta/classes/kernel-yocto.bbclass |  119 +++++++++++++++++++++++++------------
 1 files changed, 80 insertions(+), 39 deletions(-)
meta/classes/kernel-yocto.bbclass +80 -39
index c995a2e..d859d76 100644
@@ -214,63 +214,104 @@ python do_kernel_configcheck() {
     bb.plain( "%s" % result )
 }
 
-
-# Ensure that the branches (BSP and meta) are on the locatios specified by
+# Ensure that the branches (BSP and meta) are on the locations specified by
 # their SRCREV values. If they are NOT on the right commits, the branches
-# are reset to the correct commit.
+# are corrected to the proper commit.
 do_validate_branches() {
 	cd ${S}
+	export KMETA=${KMETA}
 
-	# nothing to do if bootstrapping
- 	if [ -n "${YOCTO_KERNEL_EXTERNAL_BRANCH}" ]; then
- 	 	return
- 	fi
-
-	# nothing to do if SRCREV is AUTOREV
+	set +e
+	# if SRCREV is AUTOREV it shows up as AUTOINC there's nothing to
+	# check and we can exit early
 	if [ "${SRCREV_machine}" = "AUTOINC" ]; then
-		# restore the branch for builds
-		git checkout -f ${KBRANCH}
 		return
 	fi
 
- 	branch_head=`git show-ref -s --heads ${KBRANCH}`
+	# If something other than the default branch was requested, it must
+	# exist in the tree, and it's a hard error if it wasn't
+	git show-ref --quiet --verify -- "refs/heads/${KBRANCH}"
+	if [ $? -eq 1 ]; then
+		if [ -n "${KBRANCH_DEFAULT}" ] && 
+                      [ "${KBRANCH}" != "${KBRANCH_DEFAULT}" ]; then
+			echo "ERROR: branch ${KBRANCH} was set for kernel compilation, "
+			echo "       but it does not exist in the kernel repository."
+			echo "       Check the value of KBRANCH and ensure that it describes"
+			echo "       a valid banch in the source kernel repository"
+			exit 1
+		fi
+	fi
+
+	if [ -z "${SRCREV_machine}" ]; then
+		target_branch_head="${SRCREV}"
+	else
+	 	target_branch_head="${SRCREV_machine}"
+	fi
+
+	# $SRCREV could have also been AUTOINC, so check again
+	if [ "${target_branch_head}" = "AUTOINC" ]; then
+		return
+	fi
+
+	containing_branches=`git branch --contains $target_branch_head | sed 's/^..//'`
+	if [ -z "$containing_branches" ]; then
+		echo "ERROR: SRCREV was set to \"$target_branch_head\", but no branches"
+		echo "       contain this commit"
+		exit 1
+	fi
+	ref=`git show ${target_branch_head} 2>&1 | head -n1 || true`
+	if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then
+	    echo "ERROR ${target_branch_head} is not a valid commit ID."
+	    echo "The kernel source tree may be out of sync"
+	    exit 1
+	fi
+
+	# force the SRCREV in each branch that contains the specified
+	# SRCREV (if it isn't the current HEAD of that branch)
+	git checkout -q master
+	for b in $containing_branches; do
+		branch_head=`git show-ref -s --heads ${b}`
+		if [ "$branch_head" != "$target_branch_head" ]; then
+			echo "[INFO] Setting branch $b to ${target_branch_head}"	      
+			git branch -D $b > /dev/null
+			git branch $b $target_branch_head > /dev/null
+		fi
+	done
+
+	## KMETA branch validation
  	meta_head=`git show-ref -s --heads ${KMETA}`
- 	target_branch_head="${SRCREV_machine}"
  	target_meta_head="${SRCREV_meta}"
+	git show-ref --quiet --verify -- "refs/heads/${KMETA}"
+	if [ $? -eq 1 ]; then
+		return
+	fi
 
-	current=`git branch |grep \*|sed 's/^\* //'`
-	if [ -n "$target_branch_head" ] && [ "$branch_head" != "$target_branch_head" ]; then
-		if [ -n "${KERNEL_REVISION_CHECKING}" ]; then
-			ref=`git show ${target_meta_head} 2>&1 | head -n1 || true`
-			if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then
-				echo "ERROR ${target_branch_head} is not a valid commit ID."
-				echo "The kernel source tree may be out of sync"
-				exit 1
-			else
-				echo "Forcing branch $current to ${target_branch_head}"
-				git branch -m $current $current-orig
-				git checkout -b $current ${target_branch_head}
-			fi
-		fi
+	if [ "${target_meta_head}" = "AUTOINC" ]; then
+		return
 	fi
 
 	if [ "$meta_head" != "$target_meta_head" ]; then
-		if [ -n "${KERNEL_REVISION_CHECKING}" ]; then
-			ref=`git show ${target_meta_head} 2>&1 | head -n1 || true`
-			if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then
-				echo "ERROR ${target_meta_head} is not a valid commit ID"
-				echo "The kernel source tree may be out of sync"
+		ref=`git show ${target_meta_head} 2>&1 | head -n1 || true`
+		if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then
+			echo "ERROR ${target_meta_head} is not a valid commit ID"
+			echo "The kernel source tree may be out of sync"
+			exit 1
+		else
+			echo "[INFO] Setting branch ${KMETA} to ${target_meta_head}"
+			git branch -m ${KMETA} ${KMETA}-orig
+			git checkout -q -b ${KMETA} ${target_meta_head}
+			if [ $? -ne 0 ];then
+				echo "ERROR: could not checkout ${KMETA} branch from known hash ${target_meta_head}"
 				exit 1
-			else
-				echo "Forcing branch meta to ${target_meta_head}"
-				git branch -m ${KMETA} ${KMETA}-orig
-				git checkout -b ${KMETA} ${target_meta_head}
-			fi	   
+			fi
 		fi
 	fi
 
-	# restore the branch for builds
-	git checkout -f ${KBRANCH}
+	git show-ref --quiet --verify -- "refs/heads/${KBRANCH}"
+	if [ $? -eq 0 ]; then
+		# restore the branch for builds
+		git checkout -q -f ${KBRANCH}
+	fi
 }
 
 # Many scripts want to look in arch/$arch/boot for the bootable
Signature · 1 line
1.7.5.4
#2 lore raw
In reply to Bruce Ashfield
Quoted 11 lines · Bruce Ashfield

Scott,

Here's a fix for validate_branches that comes from a pending master change that I've been running for 3 weeks, and one that TomZ has tested in his yocto BSP work on denzil.

It fixes some BSP use cases that involve setting a specific SRCREV on a base branch, so that a BSP branch that doesn't yet exist can be created off of that known base. Previously only an existing BSP branch could have it's SRCREV restricted.

Hi Scott,

I don't see this in denzil - do you have it queued for the next pull request, or did it get missed?

Tom

Quoted 20 lines
cc Tom Zanussi <[email protected]>

Cheers,

Bruce

The following changes since commit 73cdebf60df225ee10f2eb215935be3b61e1b831:

documentation/dev-manual/dev-manual-kernel-appendix.xml: Add note about conflict (2012-06-29 15:54:26 +0100)

are available in the git repository at:
git://git.pokylinux.org/poky-contrib zedd/kernel-denzil
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=zedd/kernel-denzil

Bruce Ashfield (1):
linux-yocto: allow do_validate_branches to handle all branches

 meta/classes/kernel-yocto.bbclass |  119 +++++++++++++++++++++++++------------
 1 files changed, 80 insertions(+), 39 deletions(-)
#3 lore raw
Quoted 13 lines · Tom Zanussi
Quoted 11 lines · Bruce Ashfield

Scott,

Here's a fix for validate_branches that comes from a pending master change that I've been running for 3 weeks, and one that TomZ has tested in his yocto BSP work on denzil.

It fixes some BSP use cases that involve setting a specific SRCREV on a base branch, so that a BSP branch that doesn't yet exist can be created off of that known base. Previously only an existing BSP branch could have it's SRCREV restricted.

Quoted 4 lines

Hi Scott,

I don't see this in denzil - do you have it queued for the next pull request, or did it get missed?

I was wondering the same thing, in particular, since I just made a minor tweak to this in master (which I'll send out tomorrow). The attached patch should also be merged to denzil.

Bruce

Quoted 25 lines

Tom

Quoted 20 lines
cc Tom Zanussi<[email protected]>

Cheers,

Bruce

The following changes since commit 73cdebf60df225ee10f2eb215935be3b61e1b831:

   documentation/dev-manual/dev-manual-kernel-appendix.xml: Add note about conflict (2012-06-29 15:54:26 +0100)

are available in the git repository at:
git://git.pokylinux.org/poky-contrib zedd/kernel-denzil
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=zedd/kernel-denzil

Bruce Ashfield (1):
linux-yocto: allow do_validate_branches to handle all branches

  meta/classes/kernel-yocto.bbclass |  119 +++++++++++++++++++++++++------------
  1 files changed, 80 insertions(+), 39 deletions(-)

From e044040afecde624362a7243c3cb748ed9e3fe9d Mon Sep 17 00:00:00 2001
From: Bruce Ashfield <[email protected]>
Date: Wed, 22 Aug 2012 01:18:05 -0400
Subject: [PATCH] kernel-yocto: set master branch to a defined SRCREV

To support custom repositories that set a SRCREV and that only have a single master branch, do_validate_branches needs a special case for 'master'. We can't delete and recreate the branch, since you cannot delete the current branch, instead we must reset the branch to the proper SRCREV.

---
 meta/classes/kernel-yocto.bbclass |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
meta/classes/kernel-yocto.bbclass +8 -4
index d859d76..e6758cf 100644
@@ -270,11 +270,15 @@ do_validate_branches() {
 	# SRCREV (if it isn't the current HEAD of that branch)
 	git checkout -q master
 	for b in $containing_branches; do
-		branch_head=`git show-ref -s --heads ${b}`
+		branch_head=`git show-ref -s --heads ${b}`		
 		if [ "$branch_head" != "$target_branch_head" ]; then
-			echo "[INFO] Setting branch $b to ${target_branch_head}"	      
-			git branch -D $b > /dev/null
-			git branch $b $target_branch_head > /dev/null
+			echo "[INFO] Setting branch $b to ${target_branch_head}"
+			if [ "$b" == "master" ]; then
+				git reset --hard $target_branch_head > /dev/null
+			else
+				git branch -D $b > /dev/null
+				git branch $b $target_branch_head > /dev/null
+			fi
 		fi
 	done
 
Signature · 1 line
1.7.5.4
#4 lore raw
Quoted 14 lines · Bruce Ashfield
Quoted 13 lines · Tom Zanussi
Quoted 11 lines · Bruce Ashfield

Scott,

Here's a fix for validate_branches that comes from a pending master change that I've been running for 3 weeks, and one that TomZ has tested in his yocto BSP work on denzil.

It fixes some BSP use cases that involve setting a specific SRCREV on a base branch, so that a BSP branch that doesn't yet exist can be created off of that known base. Previously only an existing BSP branch could have it's SRCREV restricted.

Quoted 9 lines
Quoted 4 lines

Hi Scott,

I don't see this in denzil - do you have it queued for the next pull request, or did it get missed?

I was wondering the same thing, in particular, since I just made a minor tweak to this in master (which I'll send out tomorrow). The attached patch should also be merged to denzil.

I tried the above patch on top of the other, built and booted a qemu arm bsp generated by yocto-bsp, and didn't see any problems FWIW...

Tom

Quoted 28 lines

Bruce

Quoted 25 lines

Tom

Quoted 20 lines
cc Tom Zanussi<[email protected]>

Cheers,

Bruce

The following changes since commit 73cdebf60df225ee10f2eb215935be3b61e1b831:

   documentation/dev-manual/dev-manual-kernel-appendix.xml: Add note about conflict (2012-06-29 15:54:26 +0100)

are available in the git repository at:
git://git.pokylinux.org/poky-contrib zedd/kernel-denzil
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=zedd/kernel-denzil

Bruce Ashfield (1):
linux-yocto: allow do_validate_branches to handle all branches

  meta/classes/kernel-yocto.bbclass |  119 +++++++++++++++++++++++++------------
  1 files changed, 80 insertions(+), 39 deletions(-)
#5 lore raw
Quoted 20 lines · Tom Zanussi
Quoted 19 lines · Bruce Ashfield
Quoted 17 lines · Tom Zanussi
Quoted 11 lines · Bruce Ashfield

Scott,

Here's a fix for validate_branches that comes from a pending master change that I've been running for 3 weeks, and one that TomZ has tested in his yocto BSP work on denzil.

It fixes some BSP use cases that involve setting a specific SRCREV on a base branch, so that a BSP branch that doesn't yet exist can be created off of that known base. Previously only an existing BSP branch could have it's SRCREV restricted.

Hi Scott,

I don't see this in denzil - do you have it queued for the next pull request, or did it get missed?

Quoted 7 lines
Quoted 4 lines

I was wondering the same thing, in particular, since I just made a minor tweak to this in master (which I'll send out tomorrow). The attached patch should also be merged to denzil.

I tried the above patch on top of the other, built and booted a qemu arm bsp generated by yocto-bsp, and didn't see any problems FWIW...

Good news. It will make the bsp tooling more robust for new boards.

Cheers,

Bruce

Quoted 33 lines

Tom

Quoted 28 lines

Bruce

Quoted 25 lines

Tom

Quoted 20 lines
cc Tom Zanussi<[email protected]>

Cheers,

Bruce

The following changes since commit 73cdebf60df225ee10f2eb215935be3b61e1b831:

    documentation/dev-manual/dev-manual-kernel-appendix.xml: Add note about conflict (2012-06-29 15:54:26 +0100)

are available in the git repository at:
git://git.pokylinux.org/poky-contrib zedd/kernel-denzil
http://git.pokylinux.org/cgit.cgi/poky-contrib/log/?h=zedd/kernel-denzil

Bruce Ashfield (1):
linux-yocto: allow do_validate_branches to handle all branches

   meta/classes/kernel-yocto.bbclass |  119 +++++++++++++++++++++++++------------
   1 files changed, 80 insertions(+), 39 deletions(-)
#6 lore raw
In reply to Tom Zanussi
Quoted 13 lines · Tom Zanussi
Quoted 11 lines · Bruce Ashfield

Scott,

Here's a fix for validate_branches that comes from a pending master change that I've been running for 3 weeks, and one that TomZ has tested in his yocto BSP work on denzil.

It fixes some BSP use cases that involve setting a specific SRCREV on a base branch, so that a BSP branch that doesn't yet exist can be created off of that known base. Previously only an existing BSP branch could have it's SRCREV restricted.

Quoted 6 lines

Hi Scott,

I don't see this in denzil - do you have it queued for the next pull request, or did it get missed?

Tom

Sorry about this - it did get missed. I now have it in my denzil-next branches and I'm planning to submit a pull request sometime next week.

Scott

Signature · 3 lines
Scott Garman
Embedded Linux Engineer - Yocto Project
Intel Open Source Technology Center