aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-04-29 23:57:36 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-29 23:57:36 +0000
commit15967616cad50f3bee007c2bf420e8dba6c94ebb (patch)
treef243c241cb0f396159521a435c65beb4620b9da7
parentcc1dd590fd60cec6eef80c2ab95d236a2175c96d (diff)
parent29252f8001f4fbdaf4977d32f6b64fdecc5f5224 (diff)
downloadbuild-15967616cad50f3bee007c2bf420e8dba6c94ebb.tar.gz
Merge "Add tool to determine if products can be lunched" into main
-rwxr-xr-xtools/lunchable72
1 files changed, 72 insertions, 0 deletions
diff --git a/tools/lunchable b/tools/lunchable
new file mode 100755
index 0000000000..fce2c2719d
--- /dev/null
+++ b/tools/lunchable
@@ -0,0 +1,72 @@
+#!/bin/bash
+
+# TODO: Currently only checks trunk_staging. Should check trunk_staging first,
+# then use the product-specfic releases. Only applies to -c though.
+
+function Help() {
+cat <<@EOF@
+Usage: lunchable [options]
+
+Lists products that have no functioning lunch combo.
+
+options:
+-c prints all failing lunch combos for all targets;
+-w why? Prints the error message after each failed lunch combo. Only
+ works with -c
+
+@EOF@
+}
+
+complete=0
+why=0
+while getopts "cwh" option; do
+ case $option in
+ c)
+ complete=1;;
+ w)
+ why=1;;
+ h)
+ Help
+ exit;;
+ esac
+done
+
+# Getting all named products can fail if we haven't lunched anything
+source $(pwd)/build/envsetup.sh &> /dev/null
+all_named_products=( $(get_build_var all_named_products 2> /dev/null) )
+if [[ $? -ne 0 ]]; then
+ echo "get_build_var all_named_products failed. Lunch something first?" >&2
+ exit 1
+fi
+total_products=${#all_named_products[@]}
+current_product=0
+
+for product in "${all_named_products[@]}"; do
+ (( current_product += 1 ))
+ single_pass=0
+ printf " Checking ${current_product}/${total_products} \r" >&2
+ for release in trunk_staging; do
+ for variant in eng user userdebug; do
+ lunchcombo="${product}-${release}-${variant}"
+ lunch_error="$(lunch $lunchcombo 2>&1 > /dev/null)"
+ if [[ $? -ne 0 ]]; then
+ # Lunch failed
+ if [[ $complete -eq 1 ]]; then
+ echo -e "${product} : ${lunchcombo}"
+ if [[ $why -eq 1 ]]; then
+ echo -e "$(sed 's/^/ /g' <<<$lunch_error)"
+ fi
+ fi
+ elif [[ $complete -ne 1 ]]; then
+ single_pass=1
+ break # skip variant
+ fi
+ done
+ if [[ $single_pass -eq 1 ]]; then
+ break # skip release
+ fi
+ done
+ if [[ $complete -eq 0 ]] && [[ $single_pass -eq 0 ]]; then
+ echo "${product}"
+ fi
+done