2018-09-28 15:24:25 +02:00
|
|
|
#!/bin/bash
|
2018-09-28 14:58:48 +02:00
|
|
|
##
|
|
|
|
## Script for querying latest version of package.
|
|
|
|
##
|
|
|
|
|
|
|
|
if [ -z "${1}" ]; then
|
|
|
|
echo "Usage: check-pkg-version.sh [package name]"
|
|
|
|
echo
|
|
|
|
echo "This script retrieves current package version"
|
|
|
|
echo "from https://www.archlinux.org."
|
2018-09-28 15:01:33 +02:00
|
|
|
exit 1
|
2018-09-28 14:58:48 +02:00
|
|
|
fi
|
|
|
|
|
2018-09-28 15:24:25 +02:00
|
|
|
check_if_update_needed() {
|
|
|
|
local SCRIPT_DIR SCRIPT_PATH
|
|
|
|
SCRIPT_PATH=$(realpath "${0}")
|
|
|
|
SCRIPT_DIR=$(dirname "${SCRIPT_PATH}")
|
|
|
|
|
|
|
|
if [ -f "${SCRIPT_DIR}/${1}/build.sh" ]; then
|
|
|
|
CURRENT_VERSION=$(grep 'TERMUX_PKG_VERSION=' "${SCRIPT_DIR}/${1}/build.sh" | cut -d= -f2)
|
|
|
|
if [ "${CURRENT_VERSION}" != "${2}" ]; then
|
|
|
|
echo "Current version: ${CURRENT_VERSION}"
|
|
|
|
echo
|
|
|
|
echo "[!] Package should be updated."
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
elif [ -f "${SCRIPT_DIR}/lib${1}/build.sh" ]; then
|
|
|
|
## Same packages in ArchLinux and Termux may have different names.
|
|
|
|
## Example: GTK-2 in Termux has name 'libgtk2' but in ArchLinux it
|
|
|
|
## named as 'gtk2'.
|
|
|
|
CURRENT_VERSION=$(grep 'TERMUX_PKG_VERSION=' "${SCRIPT_DIR}/lib${1}/build.sh" | cut -d= -f2)
|
|
|
|
if [ "${CURRENT_VERSION}" != "${2}" ]; then
|
|
|
|
echo "Current version: ${CURRENT_VERSION}"
|
|
|
|
echo
|
|
|
|
echo "[!] Package should be updated."
|
|
|
|
echo
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
## If no 'build.sh' script found, then do nothing.
|
|
|
|
:
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-09-28 14:58:48 +02:00
|
|
|
for repo in extra community core; do
|
|
|
|
for arch in x86_64 any; do
|
2018-09-28 15:24:25 +02:00
|
|
|
VERSION=$(curl -s "https://www.archlinux.org/packages/${repo}/${arch}/${1}/" | grep 'itemprop="version"' | cut -d'"' -f4 | cut -d- -f1)
|
2018-09-28 14:58:48 +02:00
|
|
|
if [ -n "${VERSION}" ]; then
|
2018-09-28 15:24:25 +02:00
|
|
|
echo "Package: ${1}"
|
|
|
|
echo "Latest version: ${VERSION}"
|
|
|
|
check_if_update_needed "${1}" "${VERSION}"
|
2018-09-28 14:58:48 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
done
|
|
|
|
|
|
|
|
exit 1
|