mirror of
https://github.com/termux/termux-packages
synced 2024-06-18 05:47:06 +00:00
enhance(scripts/termux_pkg_upgrade_version): adding an ability to process sed regexps for transformating version during automatic updates
This commit is contained in:
parent
a3ef208599
commit
5f14e97ade
|
@ -10,11 +10,12 @@ set -u
|
|||
# Push changes to remote.
|
||||
: "${GIT_PUSH_PACKAGES:=false}"
|
||||
|
||||
export TERMUX_PKG_UPDATE_METHOD="" # Which method to use for updating? (repology, github or gitlab)
|
||||
export TERMUX_PKG_UPDATE_TAG_TYPE="" # Whether to use latest-release-tag or newest-tag.
|
||||
export TERMUX_GITLAB_API_HOST="gitlab.com" # Default host for gitlab-ci.
|
||||
export TERMUX_PKG_AUTO_UPDATE=false # Whether to auto-update or not. Disabled by default.
|
||||
export TERMUX_PKG_UPDATE_VERSION_REGEXP="" # Regexp to extract version.
|
||||
export TERMUX_PKG_UPDATE_METHOD="" # Which method to use for updating? (repology, github or gitlab)
|
||||
export TERMUX_PKG_UPDATE_TAG_TYPE="" # Whether to use latest-release-tag or newest-tag.
|
||||
export TERMUX_GITLAB_API_HOST="gitlab.com" # Default host for gitlab-ci.
|
||||
export TERMUX_PKG_AUTO_UPDATE=false # Whether to auto-update or not. Disabled by default.
|
||||
export TERMUX_PKG_UPDATE_VERSION_REGEXP="" # Regexp to extract version with `grep -oP`.
|
||||
export TERMUX_PKG_UPDATE_VERSION_SED_REGEXP="" # Regexp to extract version with `sed`.
|
||||
export TERMUX_REPOLOGY_DATA_FILE
|
||||
TERMUX_REPOLOGY_DATA_FILE="$(mktemp -t termux-repology.XXXXXX)" # File to store repology data.
|
||||
|
||||
|
|
|
@ -17,16 +17,32 @@ termux_pkg_upgrade_version() {
|
|||
EPOCH=""
|
||||
fi
|
||||
|
||||
# If needed, filter version numbers using regexp.
|
||||
# If needed, filter version numbers using grep regexp.
|
||||
if [[ -n "${TERMUX_PKG_UPDATE_VERSION_REGEXP}" ]]; then
|
||||
# Extract version numbers.
|
||||
LATEST_VERSION="$(grep -oP "${TERMUX_PKG_UPDATE_VERSION_REGEXP}" <<<"${LATEST_VERSION}" || true)"
|
||||
local OLD_LATEST_VERSION="${LATEST_VERSION}"
|
||||
LATEST_VERSION="$(grep -oP "${TERMUX_PKG_UPDATE_VERSION_REGEXP}" <<< "${LATEST_VERSION}" || true)"
|
||||
if [[ -z "${LATEST_VERSION}" ]]; then
|
||||
termux_error_exit <<-EndOfError
|
||||
ERROR: failed to filter version numbers using regexp '${TERMUX_PKG_UPDATE_VERSION_REGEXP}'.
|
||||
Ensure that it is works correctly with ${LATEST_VERSION}.
|
||||
Ensure that it is works correctly with ${OLD_LATEST_VERSION}.
|
||||
EndOfError
|
||||
fi
|
||||
unset OLD_LATEST_VERSION
|
||||
fi
|
||||
|
||||
# If needed, filter version numbers using sed regexp.
|
||||
if [[ -n "${TERMUX_PKG_UPDATE_VERSION_SED_REGEXP}" ]]; then
|
||||
# Extract version numbers.
|
||||
local OLD_LATEST_VERSION="${LATEST_VERSION}"
|
||||
LATEST_VERSION="$(sed "${TERMUX_PKG_UPDATE_VERSION_SED_REGEXP}" <<< "${LATEST_VERSION}" || true)"
|
||||
if [[ -z "${LATEST_VERSION}" ]]; then
|
||||
termux_error_exit <<-EndOfError
|
||||
ERROR: failed to filter version numbers using regexp '${TERMUX_PKG_UPDATE_VERSION_SED_REGEXP}'.
|
||||
Ensure that it is works correctly with ${OLD_LATEST_VERSION}.
|
||||
EndOfError
|
||||
fi
|
||||
unset OLD_LATEST_VERSION
|
||||
fi
|
||||
|
||||
# Translate "_" into ".": some packages use underscores to seperate
|
||||
|
|
Loading…
Reference in New Issue
Block a user