On Mon, 2010-12-06 at 15:34 -0500, James Antill wrote:
> ---
>  yum/__init__.py |    4 ++++
>  yum/packages.py |   34 +++++++++++++++++++++++++++++++++-
>  2 files changed, 37 insertions(+), 1 deletions(-)
> 
> diff --git a/yum/__init__.py b/yum/__init__.py
> index 58e4367..29e0284 100644
> --- a/yum/__init__.py
> +++ b/yum/__init__.py
> @@ -1524,6 +1524,9 @@ class YumBase(depsolve.Depsolve):
>                          po.yumdb_info.from_repo_timestamp = lp_mtime
>                      except: pass
>  
> +                if rpo.xattr_origin_url is not None:
> +                    po.yumdb_info.origin_url = rpo.xattr_origin_url
> +
>                  if not hasattr(rpo.repo, 'repoXML'):
>                      continue
>  
> @@ -2090,6 +2093,7 @@ class YumBase(depsolve.Depsolve):
>              if local:
>                  filelist.extend([txmbr.po.localHdr()])
>              else:
> +                txmbr.po.xattr_origin_url # Load this, before we rm the file.
>                  filelist.extend([txmbr.po.localPkg(), txmbr.po.localHdr()])
>  
>          # now remove them
> diff --git a/yum/packages.py b/yum/packages.py
> index 093d3c8..6f61fea 100644
> --- a/yum/packages.py
> +++ b/yum/packages.py
> @@ -41,6 +41,13 @@ import urlparse
>  urlparse.uses_fragment.append("media")
>  from urlgrabber.grabber import URLGrabber, URLGrabError
>  
> +try:
> +    import xattr
> +    if not hasattr(xattr, 'get'):
> +        xattr = None # This is a "newer" API.
> +except ImportError:
> +    xattr = None
> +
>  # For verify
>  import pwd
>  import grp
> @@ -879,7 +886,32 @@ class YumAvailablePackage(PackageObject, RpmBase):
>          self._verify_local_pkg_cache = nst
>  
>          return True
> -        
> +
> +    # See: http://www.freedesktop.org/wiki/CommonExtendedAttributes
> +    def _localXattrUrl(self):
> +        """ Get the user.xdg.origin.url value from the local pkg. ... if it's
> +            present. We cache this so we can access it after the file has 
> been
> +            deleted (keepcache=False). """
> +
> +        if xattr is None:
> +            return None
> +
> +        if hasattr(self, '__cached_localXattrUrl'):
> +            return getattr(self, '__cached_localXattrUrl')
> +
> +        if not self.verifyLocalPkg():
> +            return None
> +
> +        try:
> +            ret = xattr.get(self.localPkg(), 'user.xdg.origin.url')
> +        except: # Documented to be "EnvironmentError", but make sure
> +            return None
> +
> +        setattr(self, '__cached_localXattrUrl', ret)
> +        return ret
> +
> +    xattr_origin_url = property(lambda x: x._localXattrUrl())
> +
>      def prcoPrintable(self, prcoTuple):
>          """convert the prco tuples into a nicer human string"""
>          warnings.warn('prcoPrintable() will go away in a future version of 
> Yum.\n',

ACK
-sv


_______________________________________________
Yum-devel mailing list
[email protected]
http://lists.baseurl.org/mailman/listinfo/yum-devel

Reply via email to