From: Bruce Ashfield Date: Thu, 9 Sep 2010 03:18:59 +0000 (-0400) Subject: linux-wrs: validate branches against known revisions X-Git-Tag: 2011-1~4555 X-Git-Url: https://code.ossystems.io/gitweb?a=commitdiff_plain;h=8fe347a851b6c22cd84532622effc3fa237efe89;p=openembedded-core.git linux-wrs: validate branches against known revisions It is possible for the git repository to have commits on branches that are ahead of the SRCREVs for those branches. Since the kern tools will simply checkout and build, we can end up building a different kernel than what is expected. It is up to the recipe to ensure that the branches are at the correct commits. To do this, we simply check the current machine branch against the SRCREV and if they don't match we move the existing branch and do a checkout at the desired commit. Note: This probably needs to be disabled with AUTOREV. Signed-off-by: Bruce Ashfield --- diff --git a/meta/recipes-kernel/linux/linux-wrs_git.bb b/meta/recipes-kernel/linux/linux-wrs_git.bb index 2978ed95cb..696b7d407a 100644 --- a/meta/recipes-kernel/linux/linux-wrs_git.bb +++ b/meta/recipes-kernel/linux/linux-wrs_git.bb @@ -29,6 +29,9 @@ PR = "r6" S = "${WORKDIR}/linux" B = "${WORKDIR}/linux-${WRMACHINE}-${LINUX_KERNEL_TYPE}-build" +# functionality flags +force_revisions = "t" + do_patch() { cd ${S} if [ -f ${WORKDIR}/defconfig ]; then @@ -54,6 +57,29 @@ do_patch() { fi } +validate_branches() { + branch_head=`git show-ref -s --heads ${WRMACHINE}-${LINUX_KERNEL_TYPE}` + meta_head=`git show-ref -s --heads wrs_meta` + target_branch_head="${SRCREV_pn-linux-wrs_machine}" + target_meta_head="${SRCREV_pn-linux-wrs_meta}" + + 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} + 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} + fi + fi +} + do_wrlinux_checkout() { if [ -d ${WORKDIR}/.git/refs/remotes/origin ]; then echo "Fixing up git directory for ${WRMACHINE}-${LINUX_KERNEL_TYPE}" @@ -79,6 +105,15 @@ IFS=' fi fi cd ${S} + + # checkout and clobber and unimportant files + git checkout -f ${WRMACHINE}-${LINUX_KERNEL_TYPE} + + validate_branches + + # this second checkout is intentional, we want to leave ourselves + # on the branch to be built, but validate_branches could have changed + # our initial checkout. So we do it a second time to be sure git checkout -f ${WRMACHINE}-${LINUX_KERNEL_TYPE} } do_wrlinux_checkout[dirs] = "${S}"