[Yum-devel] small fix for marking more updates as simple ones

James Antill james at fedoraproject.org
Thu Aug 20 18:54:04 UTC 2009


On Thu, 2009-08-20 at 07:10 +0300, Dimitrios Apostolou wrote:
> Hello list,
> 
> while trying to understand and optimize doUpdates() (which is the next big 
> bottleneck) I realised that the majority of packages are marked as complex 
> updates. If I undestand correctly (great possibility that I don't though), 
> only multilib and multiarch packages should be complex. If so the next 
> small fix I think is valid:
> 
> 
> diff --git a/rpmUtils/updates.py b/rpmUtils/updates.py
> index 3ce1eba..b748366 100644
> --- a/rpmUtils/updates.py
> +++ b/rpmUtils/updates.py
> @@ -321,6 +321,9 @@ class Updates:
>               for (e, v, r) in newpkgs[(n, a)]:
>                   if (new_e, new_v, new_r) != (e, v, r):
>                       newpkgs[(n, a)].remove((e, v, r))
> +            for (a2, e, v, r) in newpkgs[(n, None)]:
> +                if (new_e, new_v, new_r) != (e, v, r) and a == a2:
> +                    newpkgs[(n, None)].remove((a2, e, v, r))
> 
> 
>           for (n, a) in newpkgs:
> 
> 
> 
> It seems that line 364 - availarchs.append(a) - was being executed even 
> for package versions excluded in the previous step because 
> newpkgs[(n,None)] didn't only include latest versions. I think this fixes 
> it.

 So I'm pretty sure doUpdates() is wrong on a few levels here, I'm 99%¹
sure you want:

            for (e, v, r) in newpkgs[(n, a)][:]:
                if (new_e, new_v, new_r) != (e, v, r):
                    newpkgs[(n, a)].remove((e, v, r))

...instead of:

            for (e, v, r) in newpkgs[(n, a)]:
                if (new_e, new_v, new_r) != (e, v, r):
                    newpkgs[(n, a)].remove((e, v, r))


...then I think instead of doing all the operations twice (once for
(n,a) and then again for each arch in (n, None)) we can just do
everything for (n,a) and merge. Attached is a full patch to do that.


¹ Eg.

% cat /tmp/abcd.py
x = [1,2,3,4,5,6,7,8]
print x
for y in x:
    if y < 7:
        x.remove(y)
print x
% /tmp/abcd.py
[1, 2, 3, 4, 5, 6, 7, 8]
[2, 4, 6, 7, 8]

...the "simple" fix is to put [:] at the end of each for loop.

-- 
James Antill <james at fedoraproject.org>
Fedora
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.baseurl.org/pipermail/yum-devel/attachments/20090820/3c4e3f32/attachment-0001.htm>


More information about the Yum-devel mailing list