Skip to content

Commit 8752666

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

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,44 @@ TERMUX_PKG_ON_DEVICE_BUILD_NOT_SUPPORTED=true
1919
SYSTEM_LIBRARIES=" fontconfig"
2020
# TERMUX_PKG_DEPENDS="fontconfig"
2121

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

0 commit comments

Comments
 (0)