[elbe-devel] [PATCH 3/3] dump: do not use regex in full pkglist validation

Torben Hohn torben.hohn at linutronix.de
Thu Mar 11 09:31:57 CET 2021


On Wed, Mar 10, 2021 at 06:06:52PM +0100, Bastian Germann wrote:
> Am 10.03.21 um 17:07 schrieb Torben Hohn:
> > The fullpkglist validation should not use regex because
> > there are no regex in the recorded versions.
> > So an exact match is sufficient.
> > 
> > This fixes problems where versions like '10.3+deb10u8'
> > do not match themselves, when one of the versions is
> > interpreted as a regexp.
> > 
> > > > > re.match('10.3+deb10u8', '10.3+deb10u8') is None
> > True
> > 
> > An escape would be required.
> > 
> > > > > re.match('10.3\+deb10u8', '10.3+deb10u8') is None
> > False
> 
> Does this affect the use case of the original change?
> https://github.com/Linutronix/elbe/issues/276

well. The original use case still works.

The versions specified in pkg-list are still treated like
regexps. 
However, the version fields in fullpkg-list are not.
This is very unfortunate and confusing.

The alternative is probably to properly escape the regexps.

Basically i would rather not change the semantics of version,
but just introduce another attribute (version_match or somthing).


> There are two regex matches introduced with that. You only reverted one
> here.

Yes. I revert one of the changes, because that change directly breaks
bin-cdrom rebuilds.

But now, that you pointed me on this, i have noticed, that the matching
in the apt_preferences file is done via globs.
So actually the other case is wrong too.
And with globs, we dont have the problem with the +

So we can just switch to fnmatch.fnmatchcase() and everybody should be
happy.

> 
> > Signed-off-by: Torben Hohn <torben.hohn at linutronix.de>
> > ---
> >   elbepack/dump.py | 2 +-
> >   1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/elbepack/dump.py b/elbepack/dump.py
> > index ec5e8fbfb..d2e157e70 100644
> > --- a/elbepack/dump.py
> > +++ b/elbepack/dump.py
> > @@ -144,7 +144,7 @@ def check_full_pkgs(pkgs, fullpkgs, cache):
> >           pkg = cache.get_pkg(name)
> > -        if not re.match(ver, pkg.installed_version):
> > +        if pkg.installed_version != ver:
> >               validation.error("Package '%s' version %s does not match installed version %s",
> >                                name, ver, pkg.installed_version)
> >               errors += 1
> > 
> _______________________________________________
> elbe-devel mailing list
> elbe-devel at linutronix.de
> https://lists.linutronix.de/mailman/listinfo/elbe-devel

-- 
Torben Hohn
Linutronix GmbH | Bahnhofstrasse 3 | D-88690 Uhldingen-Mühlhofen
Phone: +49 7556 25 999 18; Fax.: +49 7556 25 999 99

Hinweise zum Datenschutz finden Sie hier (Informations on data privacy 
can be found here): https://linutronix.de/kontakt/Datenschutz.php

Linutronix GmbH | Firmensitz (Registered Office): Uhldingen-Mühlhofen | 
Registergericht (Registration Court): Amtsgericht Freiburg i.Br., HRB700 
806 | Geschäftsführer (Managing Directors): Heinz Egger, Thomas Gleixner


More information about the elbe-devel mailing list