File tree Expand file tree Collapse file tree 1 file changed +23
-5
lines changed
Expand file tree Collapse file tree 1 file changed +23
-5
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,26 @@ find_tool() {
7373 return 1
7474}
7575
76+ run_sdkmanager_noninteractive () {
77+ local description=" $1 "
78+ shift
79+ log " $description "
80+ # Temporarily disable errexit and pipefail so we can inspect the pipeline exit
81+ # codes manually without the shell aborting on the SIGPIPE emitted by `yes`.
82+ set +e
83+ set +o pipefail
84+ yes 2> /dev/null | " $SDKMANAGER " " $@ " > /dev/null
85+ local statuses=(" ${PIPESTATUS[@]} " )
86+ set -o pipefail
87+ set -e
88+ local sdk_status=" ${statuses[1]:- 1} "
89+ if [ " $sdk_status " -ne 0 ]; then
90+ log " sdkmanager command failed (exit $sdk_status ): $SDKMANAGER $* " >&2
91+ return " $sdk_status "
92+ fi
93+ return 0
94+ }
95+
7696cmdline_tool_dirs=(
7797 " $ANDROID_SDK_ROOT /cmdline-tools/latest/bin"
7898 " $ANDROID_SDK_ROOT /cmdline-tools/bin"
@@ -91,15 +111,13 @@ if [ -z "$SDKMANAGER" ] || [ -z "$AVDMANAGER" ]; then
91111 exit 1
92112fi
93113
94- log " Accepting Android SDK licenses"
95- yes | " $SDKMANAGER " --licenses > /dev/null 2>&1 || true
114+ run_sdkmanager_noninteractive " Accepting Android SDK licenses" --licenses
96115
97- log " Installing Android 35 ARM system image"
98- yes | " $SDKMANAGER " --install \
116+ run_sdkmanager_noninteractive " Installing Android 35 ARM system image" --install \
99117 " platform-tools" \
100118 " platforms;android-35" \
101119 " emulator" \
102- " system-images;android-35;google_apis;arm64-v8a" > /dev/null
120+ " system-images;android-35;google_apis;arm64-v8a"
103121
104122EMU_BIN=" $ANDROID_SDK_ROOT /emulator/emulator"
105123ADB_BIN=" $ANDROID_SDK_ROOT /platform-tools/adb"
You can’t perform that action at this time.
0 commit comments