allow setting offset in commandline

This commit is contained in:
fabolous005 2024-09-29 22:44:30 +02:00
parent 1fbfc141ee
commit 93c0283622
3 changed files with 9 additions and 7 deletions

View File

@ -23,7 +23,10 @@ etools_unset
etools_smart_find <package name> [repo]
# repo can be a path relative to /var/db/repos/ or a full path
# default will be /var/db/repos/ so all repos will be searched
# btw feel free to time it ;)
eools_get_version <package name> [offset]
# offset will output the <offset> latest version
# eg.: when 1.2.3 is latest offset 1 will result in a version 1 beneath 1.2.2-r2 for example
# btw feel free to time both of them ;)
```
## Configuration
@ -71,4 +74,3 @@ done <<< $(
done
);
```

8
etools
View File

@ -57,7 +57,7 @@ function etools_get_version() {
[ "$ETOOLS_CHECK_LIVE" ] && if _matches_live "$1"; then
# use ls over find for simplicity
# shellcheck disable=SC2012
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 -1 2>/dev/null)"
[ -n "$latest" ] && _extract_version "$latest" && ./helper.sh && return 0;
fi
if [ "$ETOOLS_CHECK_TESTING" ]; then
@ -68,14 +68,14 @@ function etools_get_version() {
arch="amd64"
fi
if [[ "$ACCEPT_KEYWORDS" == *"~$arch"* ]] || _matches_testing "$1" "\~$arch"; then
latest=$(_get_latest "$1" "${package_offset[$1]:-0}" "~$arch")
latest=$(_get_latest "$1" "${2:-${package_offset[$1]:-0}}" "~$arch")
fi
[ -n "$latest" ] && _extract_version "$latest" && ./helper.sh && return 0;
fi
_get_latest "$1" "${package_offset[$1]:-0}" "$arch"
_get_latest "$1" "${2:-${package_offset[$1]:-0}}" "$arch"
[ -n "$latest" ] && _extract_version "$latest" && ./helper.sh && return 0;
ewarn "No version found for package: $1$( (( ! ${package_offset[$1]:-0} == 0 )) && echo " with offset $offset")"
ewarn "No version found for package: $1$( (( ! ${2:-${package_offset[$1]:-0}} == 0 )) && echo " with offset $offset")"
}

View File

@ -200,7 +200,7 @@ function _get_latest() {
fi
fi
done
(( ! offset < 0 )) && ewarn "Unused offset of: $offset"
(( offset >= 0 )) && ewarn "Unused offset of: $(( offset + 1 )), from specified offset of: $2" "\n"
echo "$latest"
}