Skip to content

Commit 5cf493e

Browse files
committed
chromium-beta-host-tools: add auto-update checker
[skip ci]
1 parent f56b830 commit 5cf493e

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tur/chromium-beta-host-tools/build.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,50 @@ TERMUX_PKG_BUILD_DEPENDS="libffi-static"
1414
TERMUX_PKG_EXCLUDED_ARCHES="i686"
1515
TERMUX_PKG_NO_STRIP=true
1616
TERMUX_PKG_NO_ELF_CLEANER=true
17+
TERMUX_PKG_AUTO_UPDATE=true
1718
TERMUX_PKG_ON_DEVICE_BUILD_NOT_SUPPORTED=true
1819

1920
SYSTEM_LIBRARIES=" fontconfig"
2021
# TERMUX_PKG_DEPENDS="fontconfig"
2122

23+
termux_pkg_auto_update() {
24+
local latest_version="$(curl -s 'https://chromiumdash.appspot.com/fetch_releases?channel=Beta&platform=Linux&num=10&offset=0' | jq -rc '.[].version' | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n | tail -n 1)"
25+
26+
if ! termux_pkg_is_update_needed \
27+
"${TERMUX_PKG_VERSION#*:}" "${latest_version}"; then
28+
echo "INFO: No update needed. Already at version '${latest_version}'."
29+
return 0
30+
fi
31+
32+
local e=0
33+
local uptime_now=$(cat /proc/uptime)
34+
local uptime_s="${uptime_now//.*}"
35+
local uptime_h_limit=4
36+
local uptime_s_limit=$((uptime_h_limit*60*60))
37+
[[ -z "${uptime_s}" ]] && [[ "$(uname -o)" != "Android" ]] && e=1
38+
[[ "${uptime_s}" == 0 ]] && [[ "$(uname -o)" != "Android" ]] && e=1
39+
[[ "${uptime_s}" -gt "${uptime_s_limit}" ]] && e=1
40+
41+
if [[ "${e}" != 0 ]]; then
42+
cat <<- EOL >&2
43+
WARN: Auto update failure!
44+
latest_version=${latest_version}
45+
uptime_now=${uptime_now}
46+
uptime_s=${uptime_s}
47+
uptime_s_limit=${uptime_s_limit}
48+
EOL
49+
return
50+
fi
51+
52+
local tmpdir="$(mktemp -d)"
53+
curl -sLo "${tmpdir}/tmpfile" "https://commondatastorage.googleapis.com/chromium-browser-official/chromium-$latest_version.tar.xz"
54+
local sha="$(sha256sum "${tmpdir}/tmpfile" | cut -d ' ' -f 1)"
55+
rm -fr "${tmpdir}"
56+
printf '%s\n' 'INFO: Generated checksums:' "${sha}"
57+
58+
termux_error_exit "ERROR: current version '${TERMUX_PKG_VERSION}', latest version '${latest_version}'."
59+
}
60+
2261
termux_step_post_get_source() {
2362
# Apply patches related to chromium
2463
local f

0 commit comments

Comments
 (0)