Fabián Cañas | 29252f8 | 2024-04-29 22:58:11 +0000 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | # TODO: Currently only checks trunk_staging. Should check trunk_staging first, |
| 4 | # then use the product-specfic releases. Only applies to -c though. |
| 5 | |
| 6 | function Help() { |
| 7 | cat <<@EOF@ |
| 8 | Usage: lunchable [options] |
| 9 | |
| 10 | Lists products that have no functioning lunch combo. |
| 11 | |
| 12 | options: |
| 13 | -c prints all failing lunch combos for all targets; |
| 14 | -w why? Prints the error message after each failed lunch combo. Only |
| 15 | works with -c |
| 16 | |
| 17 | @EOF@ |
| 18 | } |
| 19 | |
| 20 | complete=0 |
| 21 | why=0 |
| 22 | while getopts "cwh" option; do |
| 23 | case $option in |
| 24 | c) |
| 25 | complete=1;; |
| 26 | w) |
| 27 | why=1;; |
| 28 | h) |
| 29 | Help |
| 30 | exit;; |
| 31 | esac |
| 32 | done |
| 33 | |
| 34 | # Getting all named products can fail if we haven't lunched anything |
| 35 | source $(pwd)/build/envsetup.sh &> /dev/null |
| 36 | all_named_products=( $(get_build_var all_named_products 2> /dev/null) ) |
| 37 | if [[ $? -ne 0 ]]; then |
| 38 | echo "get_build_var all_named_products failed. Lunch something first?" >&2 |
| 39 | exit 1 |
| 40 | fi |
| 41 | total_products=${#all_named_products[@]} |
| 42 | current_product=0 |
| 43 | |
| 44 | for product in "${all_named_products[@]}"; do |
| 45 | (( current_product += 1 )) |
| 46 | single_pass=0 |
| 47 | printf " Checking ${current_product}/${total_products} \r" >&2 |
| 48 | for release in trunk_staging; do |
| 49 | for variant in eng user userdebug; do |
| 50 | lunchcombo="${product}-${release}-${variant}" |
| 51 | lunch_error="$(lunch $lunchcombo 2>&1 > /dev/null)" |
| 52 | if [[ $? -ne 0 ]]; then |
| 53 | # Lunch failed |
| 54 | if [[ $complete -eq 1 ]]; then |
| 55 | echo -e "${product} : ${lunchcombo}" |
| 56 | if [[ $why -eq 1 ]]; then |
| 57 | echo -e "$(sed 's/^/ /g' <<<$lunch_error)" |
| 58 | fi |
| 59 | fi |
| 60 | elif [[ $complete -ne 1 ]]; then |
| 61 | single_pass=1 |
| 62 | break # skip variant |
| 63 | fi |
| 64 | done |
| 65 | if [[ $single_pass -eq 1 ]]; then |
| 66 | break # skip release |
| 67 | fi |
| 68 | done |
| 69 | if [[ $complete -eq 0 ]] && [[ $single_pass -eq 0 ]]; then |
| 70 | echo "${product}" |
| 71 | fi |
| 72 | done |