diff options
author | Bruce Ashfield <bruce.ashfield@windriver.com> | 2012-08-02 14:12:33 -0400 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-09-28 16:53:04 +0100 |
commit | 5427f5d70f188c9bd4cc22795560ae967ff766d4 (patch) | |
tree | 1ec179543e4f68e8820c6807f1e5cb883cb063f5 /meta/classes | |
parent | 4624b5eefb54dc5129dc3cd5656e9d1b41207f30 (diff) | |
download | poky-5427f5d70f188c9bd4cc22795560ae967ff766d4.tar.gz |
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.
(From OE-Core rev: 790f6441851fd4b2b84129340c438092f058135b)
Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/kernel-yocto.bbclass | 119 |
1 files changed, 80 insertions, 39 deletions
diff --git a/meta/classes/kernel-yocto.bbclass b/meta/classes/kernel-yocto.bbclass index c995a2ef57..d859d763d4 100644 --- a/meta/classes/kernel-yocto.bbclass +++ b/meta/classes/kernel-yocto.bbclass | |||
@@ -214,63 +214,104 @@ python do_kernel_configcheck() { | |||
214 | bb.plain( "%s" % result ) | 214 | bb.plain( "%s" % result ) |
215 | } | 215 | } |
216 | 216 | ||
217 | 217 | # Ensure that the branches (BSP and meta) are on the locations specified by | |
218 | # Ensure that the branches (BSP and meta) are on the locatios specified by | ||
219 | # their SRCREV values. If they are NOT on the right commits, the branches | 218 | # their SRCREV values. If they are NOT on the right commits, the branches |
220 | # are reset to the correct commit. | 219 | # are corrected to the proper commit. |
221 | do_validate_branches() { | 220 | do_validate_branches() { |
222 | cd ${S} | 221 | cd ${S} |
222 | export KMETA=${KMETA} | ||
223 | 223 | ||
224 | # nothing to do if bootstrapping | 224 | set +e |
225 | if [ -n "${YOCTO_KERNEL_EXTERNAL_BRANCH}" ]; then | 225 | # if SRCREV is AUTOREV it shows up as AUTOINC there's nothing to |
226 | return | 226 | # check and we can exit early |
227 | fi | ||
228 | |||
229 | # nothing to do if SRCREV is AUTOREV | ||
230 | if [ "${SRCREV_machine}" = "AUTOINC" ]; then | 227 | if [ "${SRCREV_machine}" = "AUTOINC" ]; then |
231 | # restore the branch for builds | ||
232 | git checkout -f ${KBRANCH} | ||
233 | return | 228 | return |
234 | fi | 229 | fi |
235 | 230 | ||
236 | branch_head=`git show-ref -s --heads ${KBRANCH}` | 231 | # If something other than the default branch was requested, it must |
232 | # exist in the tree, and it's a hard error if it wasn't | ||
233 | git show-ref --quiet --verify -- "refs/heads/${KBRANCH}" | ||
234 | if [ $? -eq 1 ]; then | ||
235 | if [ -n "${KBRANCH_DEFAULT}" ] && | ||
236 | [ "${KBRANCH}" != "${KBRANCH_DEFAULT}" ]; then | ||
237 | echo "ERROR: branch ${KBRANCH} was set for kernel compilation, " | ||
238 | echo " but it does not exist in the kernel repository." | ||
239 | echo " Check the value of KBRANCH and ensure that it describes" | ||
240 | echo " a valid banch in the source kernel repository" | ||
241 | exit 1 | ||
242 | fi | ||
243 | fi | ||
244 | |||
245 | if [ -z "${SRCREV_machine}" ]; then | ||
246 | target_branch_head="${SRCREV}" | ||
247 | else | ||
248 | target_branch_head="${SRCREV_machine}" | ||
249 | fi | ||
250 | |||
251 | # $SRCREV could have also been AUTOINC, so check again | ||
252 | if [ "${target_branch_head}" = "AUTOINC" ]; then | ||
253 | return | ||
254 | fi | ||
255 | |||
256 | containing_branches=`git branch --contains $target_branch_head | sed 's/^..//'` | ||
257 | if [ -z "$containing_branches" ]; then | ||
258 | echo "ERROR: SRCREV was set to \"$target_branch_head\", but no branches" | ||
259 | echo " contain this commit" | ||
260 | exit 1 | ||
261 | fi | ||
262 | ref=`git show ${target_branch_head} 2>&1 | head -n1 || true` | ||
263 | if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then | ||
264 | echo "ERROR ${target_branch_head} is not a valid commit ID." | ||
265 | echo "The kernel source tree may be out of sync" | ||
266 | exit 1 | ||
267 | fi | ||
268 | |||
269 | # force the SRCREV in each branch that contains the specified | ||
270 | # SRCREV (if it isn't the current HEAD of that branch) | ||
271 | git checkout -q master | ||
272 | for b in $containing_branches; do | ||
273 | branch_head=`git show-ref -s --heads ${b}` | ||
274 | if [ "$branch_head" != "$target_branch_head" ]; then | ||
275 | echo "[INFO] Setting branch $b to ${target_branch_head}" | ||
276 | git branch -D $b > /dev/null | ||
277 | git branch $b $target_branch_head > /dev/null | ||
278 | fi | ||
279 | done | ||
280 | |||
281 | ## KMETA branch validation | ||
237 | meta_head=`git show-ref -s --heads ${KMETA}` | 282 | meta_head=`git show-ref -s --heads ${KMETA}` |
238 | target_branch_head="${SRCREV_machine}" | ||
239 | target_meta_head="${SRCREV_meta}" | 283 | target_meta_head="${SRCREV_meta}" |
284 | git show-ref --quiet --verify -- "refs/heads/${KMETA}" | ||
285 | if [ $? -eq 1 ]; then | ||
286 | return | ||
287 | fi | ||
240 | 288 | ||
241 | current=`git branch |grep \*|sed 's/^\* //'` | 289 | if [ "${target_meta_head}" = "AUTOINC" ]; then |
242 | if [ -n "$target_branch_head" ] && [ "$branch_head" != "$target_branch_head" ]; then | 290 | return |
243 | if [ -n "${KERNEL_REVISION_CHECKING}" ]; then | ||
244 | ref=`git show ${target_meta_head} 2>&1 | head -n1 || true` | ||
245 | if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then | ||
246 | echo "ERROR ${target_branch_head} is not a valid commit ID." | ||
247 | echo "The kernel source tree may be out of sync" | ||
248 | exit 1 | ||
249 | else | ||
250 | echo "Forcing branch $current to ${target_branch_head}" | ||
251 | git branch -m $current $current-orig | ||
252 | git checkout -b $current ${target_branch_head} | ||
253 | fi | ||
254 | fi | ||
255 | fi | 291 | fi |
256 | 292 | ||
257 | if [ "$meta_head" != "$target_meta_head" ]; then | 293 | if [ "$meta_head" != "$target_meta_head" ]; then |
258 | if [ -n "${KERNEL_REVISION_CHECKING}" ]; then | 294 | ref=`git show ${target_meta_head} 2>&1 | head -n1 || true` |
259 | ref=`git show ${target_meta_head} 2>&1 | head -n1 || true` | 295 | if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then |
260 | if [ "$ref" = "fatal: bad object ${target_meta_head}" ]; then | 296 | echo "ERROR ${target_meta_head} is not a valid commit ID" |
261 | echo "ERROR ${target_meta_head} is not a valid commit ID" | 297 | echo "The kernel source tree may be out of sync" |
262 | echo "The kernel source tree may be out of sync" | 298 | exit 1 |
299 | else | ||
300 | echo "[INFO] Setting branch ${KMETA} to ${target_meta_head}" | ||
301 | git branch -m ${KMETA} ${KMETA}-orig | ||
302 | git checkout -q -b ${KMETA} ${target_meta_head} | ||
303 | if [ $? -ne 0 ];then | ||
304 | echo "ERROR: could not checkout ${KMETA} branch from known hash ${target_meta_head}" | ||
263 | exit 1 | 305 | exit 1 |
264 | else | 306 | fi |
265 | echo "Forcing branch meta to ${target_meta_head}" | ||
266 | git branch -m ${KMETA} ${KMETA}-orig | ||
267 | git checkout -b ${KMETA} ${target_meta_head} | ||
268 | fi | ||
269 | fi | 307 | fi |
270 | fi | 308 | fi |
271 | 309 | ||
272 | # restore the branch for builds | 310 | git show-ref --quiet --verify -- "refs/heads/${KBRANCH}" |
273 | git checkout -f ${KBRANCH} | 311 | if [ $? -eq 0 ]; then |
312 | # restore the branch for builds | ||
313 | git checkout -q -f ${KBRANCH} | ||
314 | fi | ||
274 | } | 315 | } |
275 | 316 | ||
276 | # Many scripts want to look in arch/$arch/boot for the bootable | 317 | # Many scripts want to look in arch/$arch/boot for the bootable |