]> code.ossystems Code Review - openembedded-core.git/commitdiff
linux-wrs: validate commits when forcing branches
authorBruce Ashfield <bruce.ashfield@windriver.com>
Sat, 25 Sep 2010 05:39:02 +0000 (01:39 -0400)
committerSaul Wold <Saul.Wold@intel.com>
Thu, 30 Sep 2010 17:08:55 +0000 (10:08 -0700)
Fixes [BUGID #372]

If for some unknown reason, the kernel git repository hasn't been properly
updated and is *older* than the revisions listed in default-revisions the
branch sanity checking kicks in and tries to force branches to the right
revs. The problem is, the revisions it is looking for don't exist in the
tree.  As a result, error messages are thrown about invalid commit IDs.
These aren't helpful, and are simply confusing for the user.

Instead we can test for the commit ID, and if it isn't valid, indicate
that the commit ID isn't valid and that the tree is potentially out
of sync.

This situation is not common, but it is an easy test and the extra
sanity checking is useful.

Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
meta/recipes-kernel/linux/linux-wrs_git.bb

index cf910e0a6b1cee306ee10079c7e9631c860ea95a..0e27890a949ebac8697e679ac17578ce2117edad 100644 (file)
@@ -38,18 +38,21 @@ do_patch() {
            defconfig=${WORKDIR}/defconfig
        fi
 
+       # simply ensures that a branch of the right name has been created
        createme ${ARCH} ${WRMACHINE}-${LINUX_KERNEL_TYPE} ${defconfig}
        if [ $? -ne 0 ]; then
                echo "ERROR. Could not create ${WRMACHINE}-${LINUX_KERNEL_TYPE}"
                exit 1
        fi
 
+       # updates or generates the target description
        updateme ${WORKDIR}
        if [ $? -ne 0 ]; then
                echo "ERROR. Could not update ${WRMACHINE}-${LINUX_KERNEL_TYPE}"
                exit 1
        fi
 
+       # executes and modifies the source tree as required
        patchme ${WRMACHINE}-${LINUX_KERNEL_TYPE}
        if [ $? -ne 0 ]; then
                echo "ERROR. Could not modify ${WRMACHINE}-${LINUX_KERNEL_TYPE}"
@@ -65,17 +68,31 @@ validate_branches() {
 
        if [ -n "$target_branch_head" ] && [ "$branch_head" != "$target_branch_head" ]; then
                if [ -n "${force_revisions}" ]; then
-                       echo "Forcing branch ${WRMACHINE}-${LINUX_KERNEL_TYPE} to ${target_branch_head}"
-                       git branch -m ${WRMACHINE}-${LINUX_KERNEL_TYPE} ${WRMACHINE}-${LINUX_KERNEL_TYPE}-orig
-                       git checkout -b ${WRMACHINE}-${LINUX_KERNEL_TYPE} ${target_branch_head}
+                       git show ${target_branch_head} > /dev/null 2>&1
+                       if [ $? -eq 0 ]; then
+                               echo "Forcing branch ${WRMACHINE}-${LINUX_KERNEL_TYPE} to ${target_branch_head}"
+                               git branch -m ${WRMACHINE}-${LINUX_KERNEL_TYPE} ${WRMACHINE}-${LINUX_KERNEL_TYPE}-orig
+                               git checkout -b ${WRMACHINE}-${LINUX_KERNEL_TYPE} ${target_branch_head}
+                       else
+                               echo "ERROR ${target_branch_head} is not a valid commit ID."
+                               echo "The kernel source tree may be out of sync"
+                               exit 1
+                       fi             
                fi
        fi
 
        if [ "$meta_head" != "$target_meta_head" ]; then
                if [ -n "${force_revisions}" ]; then
-                       echo "Forcing branch wrs_meta to ${target_meta_head}"
-                       git branch -m wrs_meta wrs_meta-orig
-                       git checkout -b wrs_meta ${target_meta_head}
+                       git show ${target_meta_head} > /dev/null 2>&1
+                       if [ $? -eq 0 ]; then
+                               echo "Forcing branch wrs_meta to ${target_meta_head}"
+                               git branch -m wrs_meta wrs_meta-orig
+                               git checkout -b wrs_meta ${target_meta_head}
+                       else
+                               echo "ERROR ${target_meta_head} is not a valid commit ID"
+                               echo "The kernel source tree may be out of sync"
+                               exit 1
+                       fi         
                fi
        fi
 }