add function to get current version
This commit is contained in:
parent
93c0283622
commit
ecc6c5fcd2
@ -26,7 +26,10 @@ etools_smart_find <package name> [repo]
|
||||
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 ;)
|
||||
etools_current_version <package> [index]
|
||||
# get currently installed version of a package
|
||||
# it'll show all version, by specifying the index the n'th version starting at 0 will be displayed
|
||||
# btw feel free to time all of them ;)
|
||||
```
|
||||
|
||||
## Configuration
|
||||
|
||||
31
etools
31
etools
@ -79,6 +79,36 @@ function etools_get_version() {
|
||||
}
|
||||
|
||||
|
||||
# NOTE: get currently installed version
|
||||
function etools_current_version() {
|
||||
[ -z "$1" ] && eerror "Pass a package name to this function" "\n" && return 2;
|
||||
# for packages with multiple version this errors
|
||||
[ ! -d /var/db/pkg/"$1"-[0-9]* ] 2>/dev/null && \
|
||||
[ "$ETOOLS_DEBUG" ] && einfo "checked path /var/db/pkg/$1-[0-9]*" "\n" && \
|
||||
eerror "Pass a package name to this function" "\n" && \
|
||||
return 2;
|
||||
local latest=:
|
||||
local files_content=()
|
||||
. ./helper.sh
|
||||
|
||||
for file in /var/db/pkg/"$1"-[0-9]*/; do
|
||||
if [[ -d "$file" ]]; then
|
||||
files_content+=("$(<"${file}PF")")
|
||||
fi
|
||||
done
|
||||
[ -z "${files_content[0]}" ] && eerror "Could not find any packages" "\n" && exit 1;
|
||||
if [[ -z "$2" ]]; then
|
||||
for package in "${files_content[@]}"; do
|
||||
_extract_version "$package"
|
||||
done
|
||||
./helper.sh
|
||||
else
|
||||
_extract_version "${files_content[$2]}"
|
||||
./helper.sh
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
# INFO: unset all variables
|
||||
# TODO: move config options to config unset
|
||||
function etools_unset() {
|
||||
@ -96,6 +126,7 @@ function etools_unset() {
|
||||
etools_configure \
|
||||
etools_smart_find \
|
||||
etools_get_version \
|
||||
etools_current_version \
|
||||
etools_unset \
|
||||
einfo \
|
||||
ewarn \
|
||||
|
||||
Loading…
Reference in New Issue
Block a user