Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/bin/bash | |
| 2 | |
| 3 # Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | |
| 4 # Use of this source code is governed by a BSD-style license that can be | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 # Mark all ebuilds in chromiumos-overlay and chromeos-overlay as stable and | |
| 8 # point them at the current version we have checked out. | |
| 9 # | |
| 10 # This is useful in case we want to verify that all ebuilds are pointing at the | |
| 11 # right commit hash when we are doing a build on a branch. It is intended to be | |
| 12 # used prior to tagging and can be used instead of a preflight queue. It is an | |
| 13 # alternative to cros_mark_all_as_stable that does not require a chroot and | |
| 14 # does not increase the revision number on ebuilds. | |
| 15 # | |
| 16 # Unlike cros_mark_all_as_stable, which only updates the latest stable ebuild | |
| 17 # for a given board, this script updates all stable ebuilds for all boards, | |
| 18 # including unused stable ebuilds. We do this for the sake of simplicity | |
| 19 # because it's hard to know in advance which ebuilds are truly unused, and it | |
| 20 # shouldn't hurt to update unused ebuilds. | |
| 21 # | |
| 22 # This script does not support cros_mark_as_stable_blacklist. If there are any | |
| 23 # packages in the blacklist, this script exits with an error message. | |
| 24 # | |
| 25 # Long term, the plan is to get rid of this script and replace it with | |
| 26 # cros_mark_all_as_stable. This script is only present to help with branching. | |
| 27 # | |
| 28 # Example usage: ./cros_mark_branch_as_stable | |
| 29 | |
| 30 # Load common constants. This should be the first executable line. | |
| 31 # The path to common.sh should be relative to your script's location. | |
| 32 . "$(dirname "$0")/common.sh" | |
| 33 | |
| 34 function is_workon() { xargs grep -lE '^inherit.*cros-workon'; } | |
| 35 function is_stable() { xargs grep -lE '^KEYWORDS=[^~]*$'; } | |
| 36 function is_unstable() { xargs grep -lE '^KEYWORDS=.*~'; } | |
| 37 | |
| 38 function get_workon_commit() { | |
| 39 # Get the latest workon commit associated with an ebuild. | |
| 40 ebuild="$1" | |
| 41 dir=$(dirname $ebuild) | |
| 42 CATEGORY=$(basename $(dirname "$dir")) | |
| 43 CROS_WORKON_LOCALNAME=$(basename "$dir") | |
| 44 CROS_WORKON_SUBDIR= | |
| 45 | |
| 46 # Grab the code from the ebuild that initializes the CROS_WORKON_* | |
| 47 # variables, and eval it. Note that this only works if the variables are at | |
| 48 # the start of the line (i.e. it doesn't work for "if" statements). | |
| 49 eval $(grep -E '^CROS_WORKON' $ebuild) | |
|
djmm
2010/10/11 22:02:50
Bash's elegant simplicity. :)
| |
| 50 | |
| 51 SUFFIX="$CROS_WORKON_LOCALNAME/$CROS_WORKON_SUBDIR" | |
| 52 if [[ "$CATEGORY" = "chromeos-base" ]]; then | |
| 53 SRCDIR="$GCLIENT_ROOT/src/platform/$SUFFIX" | |
| 54 else | |
| 55 SRCDIR="$GCLIENT_ROOT/src/third_party/$SUFFIX" | |
| 56 fi | |
| 57 | |
| 58 # TODO(anush): This hack is only necessary because the kernel ebuild has "if" | |
| 59 # statements, so we can't grab the CROS_WORKON_LOCALNAME properly. We should | |
| 60 # clean up the kernel ebuild and remove this hack. | |
| 61 if ! [[ -d "$SRCDIR" ]] && [[ "$CROS_WORKON_LOCALNAME" = "kernel" ]]; then | |
| 62 SRCDIR="$GCLIENT_ROOT/src/third_party/kernel/files" | |
| 63 fi | |
| 64 | |
| 65 cd $SRCDIR && git rev-parse HEAD | |
| 66 } | |
| 67 | |
| 68 BLACKLIST_FILE=$(dirname "$0")/cros_mark_as_stable_blacklist | |
| 69 BLACKLIST=$(cat "$BLACKLIST_FILE") | |
| 70 if [[ -n "$BLACKLIST" ]]; then | |
| 71 die "$0 does not support cros_mark_as_stable_blacklist" | |
| 72 fi | |
| 73 | |
| 74 for overlay in "$GCLIENT_ROOT/src/private-overlays/chromeos-overlay" \ | |
| 75 "$GCLIENT_ROOT/src/third_party/chromiumos-overlay"; do | |
| 76 if [[ -d "$overlay" ]]; then | |
| 77 ebuilds=$(find "$overlay" -type f -name "*.ebuild" | is_workon | is_stable) | |
| 78 for ebuild in $ebuilds; do | |
| 79 dir=$(dirname "$ebuild") | |
| 80 unstable_ebuild=$(echo "$dir"/*-9999.ebuild | is_workon | is_unstable) | |
| 81 if [[ -f "$unstable_ebuild" ]]; then | |
| 82 COMMIT=$(get_workon_commit $unstable_ebuild) | |
| 83 sed -e '/^KEYWORDS="/s/~//g' -e '/^CROS_WORKON_COMMIT=/d' \ | |
| 84 -e "/^EAPI/s/\$/\nCROS_WORKON_COMMIT=\"$COMMIT\"/g" \ | |
| 85 "$unstable_ebuild" > "$ebuild" | |
| 86 else | |
| 87 echo "No 9999 ebuild for $ebuild" >&2 | |
| 88 COMMIT=$(get_workon_commit $ebuild) | |
| 89 sed -i -e "/^CROS_WORKON_COMMIT/s|=.*|=\"$COMMIT\"|" "$ebuild" | |
| 90 fi | |
| 91 if [[ -z "$COMMIT" ]]; then | |
| 92 die "No commit hash for $ebuild" | |
| 93 fi | |
| 94 done | |
| 95 fi | |
| 96 done | |
| 97 | |
| 98 echo Updated all ebuilds | |
| OLD | NEW |