[yum-commits] 5 commits - cli.py docs/yum.8 yumcommands.py yum/update_md.py yum/yumRepo.py

James Antill james at osuosl.org
Fri Sep 6 20:36:49 UTC 2013


 cli.py           |   41 +++++++++++++++++++++++++++++++++++++++--
 docs/yum.8       |   11 ++++++-----
 yum/update_md.py |    3 ++-
 yum/yumRepo.py   |    3 ---
 yumcommands.py   |    5 +++++
 5 files changed, 52 insertions(+), 11 deletions(-)

New commits:
commit ed0218a505309adb5c91682db321a8a18350489a
Author: James Antill <james at and.org>
Date:   Fri Sep 6 16:26:59 2013 -0400

     Try to smooth out the edge cases for cacheReq not ever updating data.
    
     Main problems are:
    
    1. User doesn't know cache is N months old.
    
    2. User uses --enablerepo=updates-testing and that's N months older than
    current fedora+updates.

diff --git a/cli.py b/cli.py
index afe158a..e679546 100755
--- a/cli.py
+++ b/cli.py
@@ -394,6 +394,43 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         cacheReq = 'write'
         if hasattr(cmd, 'cacheRequirement'):
             cacheReq = cmd.cacheRequirement(self, self.basecmd, self.extcmds)
+
+        #  The main thing we want to do here is that if the user has done a
+        # "yum makecache fast" or has yum-cron running or something, then try
+        # not to update the repo. caches ... thus. not turning 0.5s ops. into
+        # 100x longer ops.
+        #  However if the repos. are not in sync. that's probably not going to
+        # work well (Eg. user enables updates-testing). Also give a warning if
+        # they are _really_ old.
+        ts_min = None
+        ts_max = None
+        for repo in self.repos.sort():
+            if not os.path.exists(repo.metadata_cookie):
+                ts_min = None
+                break
+
+            rts = os.stat(repo.metadata_cookie).st_mtime
+            if not ts_min:
+                ts_min = rts
+                ts_max = rts
+            elif rts > ts_max:
+                ts_max = rts
+            elif rts < ts_min:
+                ts_min = rts
+
+        if ts_min:
+            #  If caches are within 5 days of each other, they are ok to work
+            # together (lol, random numbers)...
+            if (ts_max - ts_min) > (60 * 60 * 24 * 5):
+                ts_min = None
+            elif ts_max > time.time():
+                ts_min = None
+
+        if not ts_min:
+            cacheReq = 'write'
+        elif (time.time() - ts_max) > (60 * 60 * 24 * 14):
+            self.logger.warning(_("Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast"))
+
         for repo in self.repos.sort():
             repo._metadata_cache_req = cacheReq
 
commit 23fcae6e7770e7df49fd2cff9e1261690506246a
Author: James Antill <james at and.org>
Date:   Fri Sep 6 16:26:12 2013 -0400

    Add missing translation hooks for ignored -c option message.

diff --git a/cli.py b/cli.py
index 8358c55..afe158a 100755
--- a/cli.py
+++ b/cli.py
@@ -302,11 +302,11 @@ class YumBaseCli(yum.YumBase, output.YumOutput):
         if opts.verbose:
             opts.debuglevel = opts.errorlevel = 6
         if opts.debuglevel != pc.debuglevel or opts.errorlevel != pc.errorlevel:
-            self.logger.warning("Ignored option -q, -v, -d or -e (probably due to merging: -yq != -y -q)")
+            self.logger.warning(_("Ignored option -q, -v, -d or -e (probably due to merging: -yq != -y -q)"))
         #  getRoot() changes it, but then setupYumConfig() changes it back. So
         # don't test for this, if we are using --installroot.
         if root == '/' and opts.conffile != pc.fn:
-            self.logger.warning("Ignored option -c (probably due to merging -yc != -y -c)")
+            self.logger.warning(_("Ignored option -c (probably due to merging -yc != -y -c)"))
 
         if opts.version:
             self.conf.cache = 1
commit c4f244ec65f36cb004589b51358606ed4fe4a0f8
Author: James Antill <james at and.org>
Date:   Fri Sep 6 16:25:26 2013 -0400

    Don't cache metadataCurrent = False, it will be eventually.

diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 3b44eaa..b98d3cf 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -1090,19 +1090,16 @@ Insufficient space in download directory %s
 
         mC_def = self.withinCacheAge(self.metadata_cookie, self.metadata_expire)
         if not mC_def: # Normal path...
-            self._metadataCurrent = mC_def
             return mC_def
 
         # Edge cases, both repomd.xml and metalink (if used). Must exist.
         repomdfn = self.cachedir + '/' + 'repomd.xml'
         if not os.path.exists(repomdfn):
-            self._metadataCurrent = False
             return False
 
         self._hack_mirrorlist_for_anaconda()
         mlfn = self.cachedir + '/' + 'metalink.xml'
         if self.metalink and not os.path.exists(mlfn):
-            self._metadataCurrent = False
             return False
 
         self._metadataCurrent = True
commit bd351efeac0e5d81af900150defcb8e2a9e0497c
Author: James Antill <james at and.org>
Date:   Fri Sep 6 09:34:05 2013 -0400

    Add epoch to updateinfo xml output.

diff --git a/yum/update_md.py b/yum/update_md.py
index 66cd93b..cf0b882 100644
--- a/yum/update_md.py
+++ b/yum/update_md.py
@@ -385,13 +385,14 @@ class UpdateNotice(object):
                       to_xml(coll['name']))
   
                 for pkg in coll['packages']:
-                    msg += """      <package arch="%s" name="%s" release="%s" src="%s" version="%s">
+                    msg += """      <package arch="%s" name="%s" release="%s" src="%s" version="%s" epoch="%s">
         <filename>%s</filename>
       </package>\n""" % (to_xml(pkg['arch'], attrib=True),
                                 to_xml(pkg['name'], attrib=True),
                                 to_xml(pkg['release'], attrib=True),
                                 to_xml(pkg['src'], attrib=True),
                                 to_xml(pkg['version'], attrib=True),
+                                pkg['epoch'] or '0',
                                 to_xml(pkg['filename']))
                 msg += """    </collection>\n"""
             msg += """  </pkglist>\n"""
commit d3b5c11926593c658a2f319b9bdcedd89e61c2db
Author: James Antill <james at and.org>
Date:   Thu Sep 5 15:19:24 2013 -0400

    Add cache check to repolist, using "!". Document repoinfo.

diff --git a/docs/yum.8 b/docs/yum.8
index 1885e15..3766882 100644
--- a/docs/yum.8
+++ b/docs/yum.8
@@ -381,18 +381,19 @@ version of each package that matches (this can be changed by
 using --showduplicates) and it only shows the newest providers (which can be
 changed by using --verbose).
 .IP
-.IP "\fBrepolist\fP"
+.IP "\fBrepolist\fP" "\fBrepoinfo\fP"
 Produces a list of configured repositories. The default is to list all
-enabled repositories. If you pass \-v, for verbose mode, more information is
-listed. If the first argument is 'enabled', 'disabled' or 'all' then the command
-will list those types of repos.
+enabled repositories. If you pass \-v, for verbose mode, or use repoinfo then
+more information is listed. If the first argument is 'enabled', 'disabled' or
+'all' then the command will list those types of repos.
 
 You can pass repo id or name arguments, or wildcards which to match against
 both of those. However if the id or name matches exactly then the repo will
 be listed even if you are listing enabled repos. and it is disabled.
 
 In non-verbose mode the first column will start with a '*' if the repo. has
-metalink data and the latest metadata is not local. For non-verbose mode the
+metalink data and the latest metadata is not local and will start with a
+'!' if the repo. has metadata that is expired. For non-verbose mode the
 last column will also display the number of packages in the repo. and (if there
 are any user specified excludes) the number of packages excluded.
 
diff --git a/yumcommands.py b/yumcommands.py
index 03fc58a..1530161 100644
--- a/yumcommands.py
+++ b/yumcommands.py
@@ -2174,6 +2174,11 @@ class RepoListCommand(YumCommand):
 
             if not verbose:
                 rid = repo.ui_id # can't use str()
+                if repo.metadata_expire >= 0:
+                    if os.path.exists(repo.metadata_cookie):
+                        last = os.stat(repo.metadata_cookie).st_mtime
+                        if last + repo.metadata_expire < time.time():
+                            rid = '!' + rid
                 if enabled and repo.metalink:
                     mdts = repo.metalink_data.repomd.timestamp
                     if mdts > repo.repoXML.timestamp:


More information about the Yum-commits mailing list