diff options
author | Bruce Ashfield <bruce.ashfield@windriver.com> | 2014-03-17 10:59:16 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-09-01 14:35:39 +0100 |
commit | 6b294a048901f347337cac69dd63b3381a061470 (patch) | |
tree | 2e94bf024020bfea1025da43cf8ec7b33387ccba /meta/classes/kernel-yocto.bbclass | |
parent | 50a8400b725efd32549ccd36a2365da0edf37ef0 (diff) | |
download | poky-6b294a048901f347337cac69dd63b3381a061470.tar.gz |
kernel-yocto: remove redundant SRCREV check
do_validate_branches checks to ensure that a valid machine SRCREV was
set. A test against an empty SRCREV is done in two separate locations,
we only need one, since the first check immediately returns and the
second check never hits.
At the same time, we can stop referring to the same commit hash by
3 different names. Instead we assign to a local variable at the
top of the routine, and refer to it at all times.
(From OE-Core rev: 05508339882c7cc1fe3f1f67f72314fdcab979b7)
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/kernel-yocto.bbclass')
-rw-r--r-- | meta/classes/kernel-yocto.bbclass | 33 |
1 files changed, 12 insertions, 21 deletions
diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass index 6010dc94e0..6c92427704 100644 --- a/meta/classes/kernel-yocto.bbclass +++ b/meta/classes/kernel-yocto.bbclass | |||
@@ -296,12 +296,14 @@ do_validate_branches() { | |||
296 | export KMETA=${KMETA} | 296 | export KMETA=${KMETA} |
297 | 297 | ||
298 | machine_branch="${@ get_machine_branch(d, "${KBRANCH}" )}" | 298 | machine_branch="${@ get_machine_branch(d, "${KBRANCH}" )}" |
299 | machine_srcrev="${SRCREV_machine}" | ||
299 | 300 | ||
300 | set +e | 301 | set +e |
301 | # if SRCREV is AUTOREV it shows up as AUTOINC there's nothing to | 302 | # if SRCREV is AUTOREV it shows up as AUTOINC there's nothing to |
302 | # check and we can exit early | 303 | # check and we can exit early |
303 | if [ "${SRCREV_machine}" = "AUTOINC" ] || [ "${SRCREV_machine}" = "INVALID" ] || | 304 | if [ "${machine_srcrev}" = "AUTOINC" ] || [ "${machine_srcrev}" = "INVALID" ] || |
304 | [ "${SRCREV_machine}" = "" ]; then | 305 | [ "${machine_srcrev}" = "" ]; then |
306 | bbnote "INFO: SRCREV validation is not required for AUTOREV or empty/invalid settings, returning" | ||
305 | return | 307 | return |
306 | fi | 308 | fi |
307 | 309 | ||
@@ -319,27 +321,16 @@ do_validate_branches() { | |||
319 | fi | 321 | fi |
320 | fi | 322 | fi |
321 | 323 | ||
322 | if [ -z "${SRCREV_machine}" ]; then | 324 | ref=`git show ${machine_srcrev} 2>&1 | head -n1 || true` |
323 | target_branch_head="${SRCREV}" | ||
324 | else | ||
325 | target_branch_head="${SRCREV_machine}" | ||
326 | fi | ||
327 | |||
328 | # $SRCREV could have also been AUTOINC, so check again | ||
329 | if [ "${target_branch_head}" = "AUTOINC" ]; then | ||
330 | return | ||
331 | fi | ||
332 | |||
333 | ref=`git show ${target_branch_head} 2>&1 | head -n1 || true` | ||
334 | if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then | 325 | if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then |
335 | echo "ERROR ${target_branch_head} is not a valid commit ID." | 326 | echo "ERROR ${machine_srcrev} is not a valid commit ID." |
336 | echo "The kernel source tree may be out of sync" | 327 | echo "The kernel source tree may be out of sync" |
337 | exit 1 | 328 | exit 1 |
338 | fi | 329 | fi |
339 | 330 | ||
340 | containing_branches=`git branch --contains $target_branch_head | sed 's/^..//'` | 331 | containing_branches=`git branch --contains $machine_srcrev | sed 's/^..//'` |
341 | if [ -z "$containing_branches" ]; then | 332 | if [ -z "$containing_branches" ]; then |
342 | echo "ERROR: SRCREV was set to \"$target_branch_head\", but no branches" | 333 | echo "ERROR: SRCREV was set to \"$machine_srcrev\", but no branches" |
343 | echo " contain this commit" | 334 | echo " contain this commit" |
344 | exit 1 | 335 | exit 1 |
345 | fi | 336 | fi |
@@ -349,13 +340,13 @@ do_validate_branches() { | |||
349 | git checkout -q master | 340 | git checkout -q master |
350 | for b in $containing_branches; do | 341 | for b in $containing_branches; do |
351 | branch_head=`git show-ref -s --heads ${b}` | 342 | branch_head=`git show-ref -s --heads ${b}` |
352 | if [ "$branch_head" != "$target_branch_head" ]; then | 343 | if [ "$branch_head" != "$machine_srcrev" ]; then |
353 | echo "[INFO] Setting branch $b to ${target_branch_head}" | 344 | echo "[INFO] Setting branch $b to ${machine_srcrev}" |
354 | if [ "$b" = "master" ]; then | 345 | if [ "$b" = "master" ]; then |
355 | git reset --hard $target_branch_head > /dev/null | 346 | git reset --hard $machine_srcrev > /dev/null |
356 | else | 347 | else |
357 | git branch -D $b > /dev/null | 348 | git branch -D $b > /dev/null |
358 | git branch $b $target_branch_head > /dev/null | 349 | git branch $b $machine_srcrev > /dev/null |
359 | fi | 350 | fi |
360 | fi | 351 | fi |
361 | done | 352 | done |