[Yum-devel] [PATCH 27/27] Needed the versionlock plugin to accept similar input for add and delete. Checks if arch is given, assumes arch=0 if not.

Frode Svendsen frodes at basefarm.no
Mon Apr 15 10:23:26 UTC 2013


On 15. april 2013 11:13, Zdenek Pavlas wrote:
>> Checks if arch is given, assumes arch=0 if not.
>
> 'versionlock add' does not assume epoch==0, it pattern-matches
> installed packages.  So we should probably prepend '*:' instead.
> Dtto for -ver-rel.arch suffix, but that's more difficult.
>

Sorry if my comment was unclear. The comment was meant to explain the 
changes in my (small) patch. My initial problem was that accepted input 
for the add and the delete command was not the same. 'yum versionlock 
add mysql-5.1.47-4.el6*' is accepted, 'yum versionlock delete 
mysql-5.1.47-4.el6*' is not.

> diff --git a/plugins/versionlock/versionlock.py b/plugins/versionlock/versionlock.py
> index ddc5d73..de1168f 100644
> --- a/plugins/versionlock/versionlock.py
> +++ b/plugins/versionlock/versionlock.py
> @@ -56,6 +56,23 @@ def _read_locklist():
>           raise PluginYumExit('Unable to read version lock configuration: %s' % e)
>       return locklist
>
> +def _match(ent, patterns):
> +    # there should be an API for this in Yum
> +    (n, v, r, e, a) = splitFilename(ent)
> +    for name in (
> +        '%s' % n,
> +        '%s.%s' % (n, a),
> +        '%s-%s' % (n, v),
> +        '%s-%s-%s' % (n, v, r),
> +        '%s-%s-%s.%s' % (n, v, r, a),
> +        '%s:%s-%s-%s.%s' % (e, n, v, r, a),
> +        '%s-%s:%s-%s.%s' % (n, e, v, r, a),
> +    ):
> +        for pat in patterns:
> +            if fnmatch.fnmatch(name, pat):
> +                return True
> +    return False
> +
>   class VersionLockCommand:
>       created = 1247693044
>
> @@ -159,12 +176,7 @@ class VersionLockCommand:
>               out = os.fdopen(out, 'w', -1)
>               count = 0
>               for ent in _read_locklist():
> -                found = False
> -                for match in extcmds:
> -                    if fnmatch.fnmatch(ent, match):
> -                        found = True
> -                        break
> -                if found:
> +                if _match(ent, extcmds):
>                       print "Deleting versionlock for:", ent
>                       count += 1
>                       continue
> _______________________________________________
> Yum-devel mailing list
> Yum-devel at lists.baseurl.org
> http://lists.baseurl.org/mailman/listinfo/yum-devel
>


-- 
--
Frode Svendsen
System Consultant

Basefarm AS
Nydalen Allé 37a, 0484 Oslo
+47 4000 4100 | +47 47 83 38 38
frodes at basefarm.no | www.basefarm.no

technical excellence - caring for your business


More information about the Yum-devel mailing list