add revision support for versioning

This commit is contained in:
fabolous005 2024-09-29 19:28:21 +02:00
parent baaec5677f
commit 8ed70faaaa
2 changed files with 16 additions and 9 deletions

12
etools
View File

@ -52,9 +52,8 @@ function etools_get_version() {
local latest=: local latest=:
. ./helper.sh . ./helper.sh
[ "$ETOOLS_CHECK_LIVE" ] && if _matches_live "$1"; then [ "$ETOOLS_CHECK_LIVE" ] && if _matches_live "$1"; then
latest="$(ls -1vr ${ETOOLS_REPO_PATH:-/var/db/repos}/*/$1/*9999*.ebuild | head "-${2:-1}" 2>/dev/null)" latest="$(ls -1vr "${ETOOLS_REPO_PATH:-/var/db/repos}/*/$1/*9999*.ebuild" | head "-${2:-1}" 2>/dev/null)"
[ -n "$latest" ] && latest=${latest%.ebuild} && latest=${latest##*-} && \ [ -n "$latest" ] && _extract_version "$1" && ./helper.sh && return 0;
./helper.sh && echo "$latest" && return 0;
fi fi
if [ "$ETOOLS_CHECK_TESTING" ]; then if [ "$ETOOLS_CHECK_TESTING" ]; then
. /etc/portage/make.conf . /etc/portage/make.conf
@ -66,14 +65,11 @@ function etools_get_version() {
if [[ "$ACCEPT_KEYWORDS" == *"~$arch"* ]] || _matches_testing "$1" "\~$arch"; then if [[ "$ACCEPT_KEYWORDS" == *"~$arch"* ]] || _matches_testing "$1" "\~$arch"; then
latest=$(_get_latest "$1" "${package_offset[$1]:-0}" "~$arch") latest=$(_get_latest "$1" "${package_offset[$1]:-0}" "~$arch")
fi fi
[ -n "$latest" ] && latest=${latest%.ebuild} && latest=${latest##*-} && \ [ -n "$latest" ] && _extract_version "$1" && ./helper.sh && return 0;
./helper.sh && echo "$latest" && return 0;
fi fi
_get_latest "$1" "${package_offset[$1]:-0}" "$arch" _get_latest "$1" "${package_offset[$1]:-0}" "$arch"
# WARN: this will not work for revision, because of the second expansion [ -n "$latest" ] && _extract_version "$1" && ./helper.sh && return 0;
[ -n "$latest" ] && latest=${latest%.ebuild} && latest=${latest##*-} && \
./helper.sh && echo "$latest" && return 0;
ewarn "No version found for package: $1$( (( ! offset == 0 )) && echo " with offset $offset")" ewarn "No version found for package: $1$( (( ! offset == 0 )) && echo " with offset $offset")"
} }

View File

@ -14,6 +14,7 @@ if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
_matches_live \ _matches_live \
_matches_testing \ _matches_testing \
_get_latest \ _get_latest \
_extract_version \
_filter; _filter;
do do
unset $function || echo "failed to unset function: $function" unset $function || echo "failed to unset function: $function"
@ -198,3 +199,13 @@ function _get_latest() {
(( ! offset < 0 )) && ewarn "Unused offset of: $offset" (( ! offset < 0 )) && ewarn "Unused offset of: $offset"
echo "$latest" echo "$latest"
} }
function _extract_version() {
local ebuild="$1"
local revision=:
ebuild=${ebuild%.ebuild}
revision=$(echo "$ebuild" | sed -n 's/.*\(-r[0-9]\+\).*/\1/p')
ebuild=${ebuild/-r[[:digit:]]}
ebuild=${ebuild##*=}
echo "$ebuild$revision"
}