Index: cros_mark_branch_as_stable |
diff --git a/cros_mark_branch_as_stable b/cros_mark_branch_as_stable |
index a2dfd7a6932d49d66a06235a55f480e0cce00258..e5382354194efb7ba3a3756976107874cab5ffd7 100755 |
--- a/cros_mark_branch_as_stable |
+++ b/cros_mark_branch_as_stable |
@@ -27,9 +27,26 @@ |
# |
# Example usage: ./cros_mark_branch_as_stable |
-# Load common constants. This should be the first executable line. |
-# The path to common.sh should be relative to your script's location. |
-. "$(dirname "$0")/common.sh" |
+# --- BEGIN COMMON.SH BOILERPLATE --- |
+# Load common CrOS utilities. Inside the chroot this file is installed in |
+# /usr/lib/crosutils. Outside the chroot we find it relative to the script's |
+# location. |
+find_common_sh() { |
+ local common_paths=(/usr/lib/crosutils $(dirname "$(readlink -f "$0")")) |
+ local path |
+ |
+ SCRIPT_ROOT= |
+ for path in "${common_paths[@]}"; do |
+ if [ -r "${path}/common.sh" ]; then |
+ SCRIPT_ROOT=${path} |
+ break |
+ fi |
+ done |
+} |
+ |
+find_common_sh |
+. "${SCRIPT_ROOT}/common.sh" || (echo "Unable to load common.sh" && exit 1) |
+# --- END COMMON.SH BOILERPLATE --- |
function is_workon() { xargs grep -lE '^inherit.*cros-workon'; } |
function is_stable() { xargs grep -lE '^KEYWORDS=[^~]*$'; } |
@@ -38,8 +55,8 @@ function is_unstable() { xargs grep -lE '^KEYWORDS=.*~'; } |
function get_workon_commit() { |
# Get the latest workon commit associated with an ebuild. |
ebuild="$1" |
- dir=$(dirname $ebuild) |
- CATEGORY=$(basename $(dirname "$dir")) |
+ dir=$(dirname "$ebuild") |
+ CATEGORY=$(basename "$(dirname "$dir")") |
CROS_WORKON_LOCALNAME=$(basename "$dir") |
CROS_WORKON_SUBDIR= |
@@ -65,7 +82,7 @@ function get_workon_commit() { |
cd $SRCDIR && git rev-parse HEAD |
} |
-BLACKLIST_FILE=$(dirname "$0")/cros_mark_as_stable_blacklist |
+BLACKLIST_FILE="${SCRIPTS_DIR}/cros_mark_as_stable_blacklist" |
BLACKLIST=$(cat "$BLACKLIST_FILE") |
if [[ -n "$BLACKLIST" ]]; then |
die "$0 does not support cros_mark_as_stable_blacklist" |