diff options
author | Ismael Luceno | 2020-04-04 20:08:51 +0200 |
---|---|---|
committer | Ismael Luceno | 2020-04-04 20:33:08 +0200 |
commit | 5e972bbad34aeff123263347bdb07d0658881f3e (patch) | |
tree | 2259dec4fa9a24bdc23ca3e6a8ad139eed3cb9ef /FUNCTIONS | |
parent | 8f13565be0bbf58e72dac8121862137a7e695313 (diff) |
FUNCTIONS: Add vdepends for version checking
It replaces simple_version_check_force_depends with a more powerful
mechanic that combines the call to depends with several checks.
It's designed to take all dependencies at once.
Usage example:
vdepends << !
gdk-pixbuf2 >= 2.30
atk >= 2.15
pango >= 1.41
!
Supports following operators:
* '>' (Greater than)
* '>=' (Greater than or equal to)
* '<' (Less than)
* '<=' (Less than or equal to)
* '=' (Equal to)
* '!=' (Not equal to)
Diffstat (limited to 'FUNCTIONS')
-rwxr-xr-x | FUNCTIONS | 36 |
1 files changed, 24 insertions, 12 deletions
@@ -934,19 +934,31 @@ function check_tmp_noexec() { } #--- -## Simple version check with force depends -## @params $1 - the spell to check the version of -## @params $2 - the simple version to check against -## (if proper is 2.1.0 then this is 210) -## @params $3 - how many digits to compare against from left to right -## defaults to 99 digits +## Versioned dependency list from stdin. +## Takes one dependency per line. Format: +## <dependency> <comparison operator> <version> <flags> #--- -function simple_version_check_force_depends(){ -if spell_ok $1 && - [[ $(installed_version $1|sed -e 's:^0\.::' -e 's:\.::g' | cut -c-${3:=99}) -lt $2 ]] - then - force_depends $1 -fi +vdepends(){ + while read dep op depver flags; do + case "$op" in + '>'|'>='|'<'|'<='|'='|'!=') ;; + *) + message "${PROBLEM_COLOR}Unsupported operator \"$op\".$DEFAULT_COLOR" + return 1 + ;; + esac + depends "$dep" "$flags" || return + spell_ok "$dep" || continue + local iver="$(installed_version "$dep")" + case "$op" in + '>') ! is_version_less "$iver" "$depver" && [ "x$iver" != "x$depver" ] ;; + '>=') ! is_version_less "$iver" "$depver" ;; + '<') is_version_less "$iver" "$depver" ;; + '<=') is_version_less "$iver" "$depver" || [ "x$iver" = "x$depver" ] ;; + '=') [ "x$iver" = "x$depver" ] ;; + '!=') [ "x$iver" != "x$depver" ] ;; + esac || force_depends "$dep" + done } #--- |