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