[Yum-devel] [PATCH] Fix /var/lib/rpm/Packages mtime race. BZ 973375

James Antill james at fedoraproject.org
Wed Jun 19 15:29:49 UTC 2013


On Wed, 2013-06-19 at 06:15 -0400, Zdenek Pavlas wrote:
> > So, again, I'm heavily inclined to just say "stop
> > doing that" unless we really need to come up with some workaround.
> 
> Came up with this..  We can prefix rpmdb version with h_nelem
> loaded from the Berkeley DB header.  This way, most additions
> and removals should be detected.  But yes, it's ugly.
> 
> diff --git a/yum/rpmsack.py b/yum/rpmsack.py
> index 56c3793..96f4fc1 100644
> --- a/yum/rpmsack.py
> +++ b/yum/rpmsack.py
> @@ -31,6 +31,7 @@ from packageSack import PackageSackBase, PackageSackVersion
>  # For returnPackages(patterns=)
>  import fnmatch
>  import re
> +import struct
>  
>  from yum.i18n import to_unicode, _
>  import constants
> @@ -1157,7 +1158,10 @@ class RPMDBPackageSack(PackageSackBase):
>                  if fo is None:
>                      return None
>                  rpmdbv = fo.readline()[:-1]
> -                self._have_cached_rpmdbv_data  = rpmdbv
> +                rpmdbv_nrec, rpmdbv = rpmdbv.split(':', 1)
> +                nrec = struct.unpack('<88xI', open(rpmdbfname).read(92))[0]

 If Panu signs off on this, I don't mind ... but please put the nrec
getter line in a function :).
 Also you can't store/get the nrec data like that. I guess you just
deleted your cached data and tested? But we'll be deploying to a lot of
users and pretty much everyone using yum currently has a stored rpmdb
version file, so we have to make sure things work for at least two cases
and it'd be nice to make sure it works for the 3rd one too:

1. User has old /version file, and new code (yum upgrade).

2. User has new /version file, and new code.

3. User has new /version file, and old code (yum downgrade).

...putting the new nrec data at the front of the file breaks #1 and #3.
I _think_ we can just add a second line to the file with just the nrec
data, and it'll pass all three of the above.




More information about the Yum-devel mailing list