Skip to content

Commit fb69fdd

Browse files
committed
Updated ci-install-android-sdk.sh. Step 3.
1 parent 78c6fa8 commit fb69fdd

1 file changed

Lines changed: 14 additions & 21 deletions

File tree

script/ci-install-android-sdk.sh

Lines changed: 14 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -37,29 +37,27 @@ SDK_ARCHIVE="commandlinetools-linux-14742923_latest.zip"
3737
check_cmdline_tools_latest_or_fail() {
3838
local STUDIO_URL="https://developer.android.com/studio#command-tools"
3939

40-
# Validate SDK_ARCHIVE format
41-
if [[ -z "${SDK_ARCHIVE:-}" ]]; then
42-
return 0
43-
fi
44-
if [[ ! "$SDK_ARCHIVE" =~ ^commandlinetools-linux-([0-9]+)_latest\.zip$ ]]; then
45-
return 0
46-
fi
40+
[[ -n "${SDK_ARCHIVE:-}" ]] || return 0
41+
[[ "$SDK_ARCHIVE" =~ ^commandlinetools-linux-([0-9]+)_latest\.zip$ ]] || return 0
4742
local CURRENT_VER="${BASH_REMATCH[1]}"
4843

49-
# Temporarily disable xtrace to avoid printing HTML content
44+
# If required tools are missing -> skip (do NOT fail CI)
45+
command -v curl >/dev/null 2>&1 || return 0
46+
command -v grep >/dev/null 2>&1 || return 0
47+
command -v sed >/dev/null 2>&1 || return 0
48+
command -v sort >/dev/null 2>&1 || return 0
49+
command -v tail >/dev/null 2>&1 || return 0
50+
51+
# Disable xtrace only for the fetch/parse section (avoid dumping HTML)
5052
local xtrace_was_on=0
51-
case "$-" in
52-
*x*) xtrace_was_on=1; set +x ;;
53-
esac
53+
case "$-" in *x*) xtrace_was_on=1; set +x ;; esac
5454

55-
# Try to fetch page (fail = skip)
5655
local HTML
5756
if ! HTML="$(curl -fsSL --connect-timeout 3 --max-time 8 "$STUDIO_URL" 2>/dev/null)"; then
5857
[[ "$xtrace_was_on" -eq 1 ]] && set -x
5958
return 0
6059
fi
6160

62-
# Parse latest version (fail = skip)
6361
local LATEST_VER
6462
LATEST_VER="$(
6563
printf '%s' "$HTML" \
@@ -70,19 +68,14 @@ check_cmdline_tools_latest_or_fail() {
7068
)"
7169

7270
[[ "$xtrace_was_on" -eq 1 ]] && set -x
71+
[[ -n "$LATEST_VER" ]] || return 0
7372

74-
if [[ -z "$LATEST_VER" ]]; then
75-
return 0
76-
fi
77-
78-
# Compare versions
7973
if (( CURRENT_VER < LATEST_VER )); then
8074
echo "ERROR: Outdated Android SDK Command-line Tools detected."
8175
echo "ERROR: Current pinned version: $CURRENT_VER ($SDK_ARCHIVE)"
8276
echo "ERROR: Latest available version: $LATEST_VER (commandlinetools-linux-${LATEST_VER}_latest.zip)"
83-
echo "ERROR: Reason: Google updated SDK repository metadata and older cmdline-tools"
84-
echo "ERROR: may fail or produce warnings (eg. SDK XML v4 incompatibility)."
85-
echo "ERROR: Fix: update SDK_ARCHIVE to the latest version and re-run the script."
77+
echo "ERROR: Reason: The official Android SDK repository metadata was updated; older pinned cmdline-tools may break or warn."
78+
echo "ERROR: Fix: Update SDK_ARCHIVE to the latest version and re-run CI."
8679
exit 1
8780
fi
8881
}

0 commit comments

Comments
 (0)