From 735467255b3310380188dd3a01cdf5ae2dc4f4a2 Mon Sep 17 00:00:00 2001 From: Leonid Pliushch Date: Thu, 17 Dec 2020 14:59:00 +0200 Subject: [PATCH] initial version of check-updates script Compares local package versions with their upstream and notifies whether updates are needed. Limited to Github-based projects only and needs a personal access token to get a higher API requests rate limit. --- scripts/updates/check-updates.sh | 33 +++++++++++++++++++++++++++++ scripts/updates/github-projects.txt | 21 ++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100755 scripts/updates/check-updates.sh create mode 100644 scripts/updates/github-projects.txt diff --git a/scripts/updates/check-updates.sh b/scripts/updates/check-updates.sh new file mode 100755 index 000000000..e58e49c56 --- /dev/null +++ b/scripts/updates/check-updates.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash +set -e -u +BASEDIR=$(dirname "$(realpath "$0")") + +if [ -z "${GITHUB_API_TOKEN-}" ]; then + echo "You need a Github Personal Access Token be set in variable GITHUB_API_TOKEN." + exit 1 +fi + +if [ -f "${BASEDIR}/github-projects.txt" ]; then + while read -r line; do + package=$(echo "$line" | cut -d'|' -f1) + project=$(echo "$line" | cut -d'|' -f2-) + + if [ ! -d "${BASEDIR}/../../packages/${package}" ]; then + echo "Package '$package' is not available, skipping." + fi + + # Our local version of package. + termux_version=$(. "${BASEDIR}/../../packages/${package}/build.sh" 2>/dev/null; echo "$TERMUX_PKG_VERSION") + + # Latest version is the current release tag on Github. + latest_version=$(curl --silent -H "Authorization: token ${GITHUB_API_TOKEN}" "https://api.github.com/repos/${project}/releases/latest" | jq -r .tag_name) + + # Remove leading 'v' which is common in version tag. + latest_version=${latest_version#v} + + # We have no better choice for comparing versions. + if [ "$(echo -e "${termux_version}\n${latest_version}" | sort -V | head -n 1)" != "$latest_version" ] ;then + echo "Package '${package}' needs update to '${latest_version}'." + fi + done < "${BASEDIR}/github-projects.txt" +fi diff --git a/scripts/updates/github-projects.txt b/scripts/updates/github-projects.txt new file mode 100644 index 000000000..d2c4de8a5 --- /dev/null +++ b/scripts/updates/github-projects.txt @@ -0,0 +1,21 @@ +acr|radare/acr +antibody|getantibody/antibody +atomicparsley|wez/atomicparsley +axel|axel-download-accelerator/axel +bash-completion|scop/bash-completion +bat|sharkdp/bat +beanshell|beanshell/beanshell +binaryen|WebAssembly/binaryen +blackbox|StackExchange/blackbox +bmon|tgraf/bmon +brook|txthinking/brook +brotli|google/brotli +cava|karlstav/cava +ccnet|haiwen/ccnet +cicada|mitnk/cicada +clash|Dreamacro/clash +cmark|github/cmark +cmatrix|abishekvashok/cmatrix +cmusfm|Arkq/cmusfm +cpulimit|opsengine/cpulimit +croc|schollz/croc