[elbe-devel] [PATCH v2 4/4] Fix pkg list validation error on version wildcards

Bastian Germann bage at linutronix.de
Thu Mar 11 10:36:45 CET 2021


Am 11.03.21 um 10:20 schrieb Torben Hohn:
> When version is specified using wildcards (glob), the simple comparison
> of versions fails, and the build fails.
> 
> Use fnmatchcase, which is the actual matcher used in pythons glob module,
> to match version strings. re is not used, because + is a special character
> there and versions containing + doe not match themselves, when interpreted

Typo: doe -> do

> as re.
> 
> Fixes: #276
> 
> Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>

With the typo fixed:
Reviewed-by: Bastian Germann <bage at linutronix.de>

> ---
>   elbepack/dump.py | 5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
> 
> diff --git a/elbepack/dump.py b/elbepack/dump.py
> index edc6637f6..56ce54d60 100644
> --- a/elbepack/dump.py
> +++ b/elbepack/dump.py
> @@ -7,6 +7,7 @@
>   
>   import logging
>   
> +from fnmatch import fnmatchcase
>   from datetime import datetime
>   
>   from apt import Cache
> @@ -106,7 +107,7 @@ def check_full_pkgs(pkgs, fullpkgs, cache):
>   
>               ver = p.et.get('version')
>               pkg = cache.get_pkg(nomulti_name)
> -            if ver and (pkg.installed_version != ver):
> +            if ver and fnmatchcase(pkg.installed_version, ver):
>                   validation.error("Package '%s' version '%s' does not match installed version %s",
>                                    name, ver, pkg.installed_version)
>                   errors += 1
> @@ -143,7 +144,7 @@ def check_full_pkgs(pkgs, fullpkgs, cache):
>   
>           pkg = cache.get_pkg(name)
>   
> -        if pkg.installed_version != ver:
> +        if fnmatchcase(pkg.installed_version, ver):
>               validation.error("Package '%s' version %s does not match installed version %s",
>                                name, ver, pkg.installed_version)
>               errors += 1
> 


More information about the elbe-devel mailing list