[yum] update to latest HEAD.
James Antill
james at fedoraproject.org
Mon Feb 18 22:16:43 UTC 2013
commit fc162fc0f00044ae92512f038d4e0db038b9c56f
Author: James Antill <james at and.org>
Date: Mon Feb 18 17:16:03 2013 -0500
update to latest HEAD.
- Auto expire caches on repo errors.
- Use xattrs for cache checksum speedup.
yum-HEAD.patch | 371 ++++++++++++++++++++++++++++++++++++++-----------------
yum.spec | 32 ++++-
2 files changed, 283 insertions(+), 120 deletions(-)
---
diff --git a/yum-HEAD.patch b/yum-HEAD.patch
index 51c7668..dddee9c 100644
--- a/yum-HEAD.patch
+++ b/yum-HEAD.patch
@@ -175963,15 +175963,21 @@ index 1ce4720..25e3022
gobject.threads_init()
dbus.glib.threads_init()
diff --git a/yum.spec b/yum.spec
-index abd203f..f18cce8 100644
+index abd203f..734f0a7 100644
--- a/yum.spec
+++ b/yum.spec
-@@ -1,24 +1,55 @@
+@@ -1,24 +1,61 @@
-Summary: RPM installer/updater
+%define move_yum_conf_back 1
+%define auto_sitelib 1
+%define yum_updatesd 0
+%define disable_check 0
++%define yum_cron 1
++
++%if 0%{?rhel} == 6
++# rhel-6 doesn't have the systemd stuff, so won't build...
++%define yum_cron 0
++%endif
+
+%if %{auto_sitelib}
+
@@ -176028,7 +176034,7 @@ index abd203f..f18cce8 100644
Conflicts: rpm >= 5-0
# Zif is a re-implementation of yum in C, however:
#
-@@ -34,18 +65,28 @@ Conflicts: rpm >= 5-0
+@@ -34,18 +71,28 @@ Conflicts: rpm >= 5-0
# zif experts).
#
# ...so we have two sane choices: i) Conflict with it. 2) Stop developing yum.
@@ -176064,7 +176070,7 @@ index abd203f..f18cce8 100644
%description
Yum is a utility that can check for and automatically download and
-@@ -58,9 +99,11 @@ Group: Applications/System
+@@ -58,9 +105,11 @@ Group: Applications/System
Requires: yum = %{version}-%{release}
Requires: dbus-python
Requires: pygobject2
@@ -176078,7 +176084,12 @@ index abd203f..f18cce8 100644
Requires(postun): /sbin/service
-@@ -72,29 +115,56 @@ can notify you when they are available via email, syslog or dbus.
+@@ -68,20 +117,21 @@ Requires(postun): /sbin/service
+ yum-updatesd provides a daemon which checks for available updates and
+ can notify you when they are available via email, syslog or dbus.
+
+-
++%if %{yum_cron}
%package cron
Summary: Files needed to run yum updates as a cron job
Group: System Environment/Base
@@ -176097,12 +176108,12 @@ index abd203f..f18cce8 100644
%description cron
These are the files needed to run yum updates as a cron job.
Install this package if you want auto yum updates nightly via cron.
-
-+
++%endif
+
+
%prep
%setup -q
-
+@@ -89,12 +139,38 @@ Install this package if you want auto yum updates nightly via cron.
%build
make
@@ -176144,7 +176155,7 @@ index abd203f..f18cce8 100644
# Ghost files:
mkdir -p $RPM_BUILD_ROOT/var/lib/yum/history
-@@ -102,12 +172,18 @@ mkdir -p $RPM_BUILD_ROOT/var/lib/yum/plugins
+@@ -102,12 +178,27 @@ mkdir -p $RPM_BUILD_ROOT/var/lib/yum/plugins
mkdir -p $RPM_BUILD_ROOT/var/lib/yum/yumdb
touch $RPM_BUILD_ROOT/var/lib/yum/uuid
@@ -176155,6 +176166,15 @@ index abd203f..f18cce8 100644
+
%find_lang %name
++%if ! %{yum_cron}
++# Remove the yum-cron stuff to make rpmbuild happy..
++rm -f $RPM_BUILD_ROOT/%{_unitdir}/yum-cron.service
++rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/cron.daily/0yum-update.cron
++rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/yum/yum-cron.conf
++rm -f $RPM_BUILD_ROOT/%{_sbindir}/yum-cron
++rm -f $RPM_BUILD_ROOT/%{_mandir}/man*/yum-cron.*
++%endif
++
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
@@ -176163,13 +176183,14 @@ index abd203f..f18cce8 100644
%post updatesd
/sbin/chkconfig --add yum-updatesd
/sbin/service yum-updatesd condrestart >/dev/null 2>&1
-@@ -119,67 +195,61 @@ if [ $1 = 0 ]; then
+@@ -119,67 +210,61 @@ if [ $1 = 0 ]; then
/sbin/service yum-updatesd stop >/dev/null 2>&1
fi
exit 0
+%endif
-
+-
++%if %{yum_cron}
%post cron
-# Make sure chkconfig knows about the service
-/sbin/chkconfig --add yum-cron
@@ -176213,23 +176234,24 @@ index abd203f..f18cce8 100644
+ systemctl enable yum-cron >/dev/null 2>&1
fi
-exit 0
-+fi
-+
-+# Also note:
-+# systemctl list-unit-files | fgrep yum-cron
-+
-+%preun cron
-+%systemd_preun yum-cron.service
-
- %postun cron
+-
+-%postun cron
-# If there's a yum-cron package left after uninstalling one, do a
-# conditional restart of the service
-if [ "$1" -ge "1" ]; then
- /sbin/service yum-cron condrestart 1> /dev/null 2>&1
--fi
+ fi
-exit 0
-+%systemd_postun_with_restart yum-cron.service
++# Also note:
++# systemctl list-unit-files | fgrep yum-cron
++
++%preun cron
++%systemd_preun yum-cron.service
++
++%postun cron
++%systemd_postun_with_restart yum-cron.service
++%endif
%files -f %{name}.lang
@@ -176265,16 +176287,17 @@ index abd203f..f18cce8 100644
%dir /var/cache/yum
%dir /var/lib/yum
%ghost /var/lib/yum/uuid
-@@ -188,20 +258,21 @@ exit 0
+@@ -188,20 +273,23 @@ exit 0
%ghost /var/lib/yum/yumdb
%{_mandir}/man*/yum.*
%{_mandir}/man*/yum-shell*
--
+# plugin stuff
+%dir %{_sysconfdir}/yum/pluginconf.d
+%dir %{yum_pluginslib}
+%dir %{yum_pluginsshare}
+-
++%if %{yum_cron}
%files cron
%defattr(-,root,root)
%doc COPYING
@@ -176286,17 +176309,19 @@ index abd203f..f18cce8 100644
-
-
-
+-
+%{_sysconfdir}/cron.daily/0yum-update.cron
+%config(noreplace) %{_sysconfdir}/yum/yum-cron.conf
+%{_unitdir}/yum-cron.service
+%{_sbindir}/yum-cron
+%{_mandir}/man*/yum-cron.*
-
++%endif
++
+%if %{yum_updatesd}
%files updatesd
%defattr(-, root, root)
%config(noreplace) %{_sysconfdir}/yum/yum-updatesd.conf
-@@ -210,8 +281,12 @@ exit 0
+@@ -210,8 +298,12 @@ exit 0
%{_datadir}/yum-cli/yumupd.py*
%{_sbindir}/yum-updatesd
%{_mandir}/man*/yum-updatesd*
@@ -185499,7 +185524,7 @@ index 2cb1acb..3ac0010 100644
def __unicode__(self):
ret = u''
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
-index e5e9ece..efbc42a 100644
+index e5e9ece..ce34a29 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -20,10 +20,12 @@ import time
@@ -185523,7 +185548,71 @@ index e5e9ece..efbc42a 100644
from constants import *
import metalink
-@@ -104,7 +107,7 @@ class YumPackageSack(packageSack.PackageSack):
+@@ -49,15 +52,54 @@ import stat
+ import errno
+ import tempfile
+
+-# If you want yum to _always_ check the MD .sqlite files then set this to
+-# False (this doesn't affect .xml files or .sqilte files derived from them).
+-# With this as True yum will only check when a new repomd.xml or
+-# new MD is downloaded.
+-# Note that with atomic MD, we can't have old MD lying around anymore so
+-# the only way we need this check is if someone does something like:
+-# cp primary.sqlite /var/cache/yum/blah
+-# ...at which point you lose.
+-skip_old_DBMD_check = True
++# This is unused now, probably nothing uses it but it was global/public.
++skip_old_DBMD_check = False
++
++try:
++ import xattr
++ if not hasattr(xattr, 'get') or not hasattr(xattr, 'set'):
++ xattr = None # This is a "newer" API.
++except ImportError:
++ xattr = None
++
++# The problem we are trying to solve here is that:
++#
++# 1. We rarely want to be downloading MD/pkgs/etc.
++# 2. We want to check those files are valid (match checksums) when we do
++# download them.
++# 3. We _really_ don't want to checksum all the files everytime we
++# run (100s of MBs).
++# 4. We can continue to download files from bad mirrors, or retry files due to
++# C-c etc.
++#
++# ...we used to solve this by just checking the file size, and assuming the
++# files had been downloaded and checksumed as correct if that matched. But that
++# was error prone on bad mirrors, so now we store the checksum in an
++# xattr ... this does mean that if you can't store xattrs (Eg. NFS) you will
++# rechecksum everything constantly.
++
++def _xattr_get_chksum(filename, chktype):
++ if not xattr:
++ return None
++
++ try:
++ ret = xattr.get(filename, 'user.yum.checksum.' + chktype)
++ except: # Documented to be "EnvironmentError", but make sure
++ return None
++
++ return ret
++
++def _xattr_set_chksum(filename, chktype, chksum):
++ if not xattr:
++ return None
++
++ try:
++ xattr.set(filename, 'user.yum.checksum.' + chktype, chksum)
++ except:
++ return False # Data too long. = IOError ... ignore everything.
++
++ return True
++
+
+ warnings.simplefilter("ignore", Errors.YumFutureDeprecationWarning)
+
+@@ -104,7 +146,7 @@ class YumPackageSack(packageSack.PackageSack):
if repo in self.added:
if 'metadata' not in self.added[repo]:
raise Errors.RepoError, '%s md for %s imported before primary' \
@@ -185532,7 +185621,7 @@ index e5e9ece..efbc42a 100644
current = 0
for pkgid in dataobj:
current += 1
-@@ -121,6 +124,26 @@ class YumPackageSack(packageSack.PackageSack):
+@@ -121,6 +163,26 @@ class YumPackageSack(packageSack.PackageSack):
# umm, wtf?
pass
@@ -185559,7 +185648,7 @@ index e5e9ece..efbc42a 100644
def populate(self, repo, mdtype='metadata', callback=None, cacheonly=0):
if mdtype == 'all':
data = ['metadata', 'filelists', 'otherdata']
-@@ -138,8 +161,6 @@ class YumPackageSack(packageSack.PackageSack):
+@@ -138,8 +200,6 @@ class YumPackageSack(packageSack.PackageSack):
if item in self.added[repo]:
continue
@@ -185568,7 +185657,7 @@ index e5e9ece..efbc42a 100644
if item == 'metadata':
mydbtype = 'primary_db'
mymdtype = 'primary'
-@@ -162,25 +183,39 @@ class YumPackageSack(packageSack.PackageSack):
+@@ -162,25 +222,39 @@ class YumPackageSack(packageSack.PackageSack):
continue
if self._check_db_version(repo, mydbtype):
@@ -185616,11 +185705,11 @@ index e5e9ece..efbc42a 100644
xmldata = repo.repoXML.getData(mymdtype)
(ctype, csum) = xmldata.checksum
dobj = repo_cache_function(xml, csum)
-@@ -193,6 +228,25 @@ class YumPackageSack(packageSack.PackageSack):
+@@ -193,6 +267,25 @@ class YumPackageSack(packageSack.PackageSack):
# get rid of all this stuff we don't need now
del repo.cacheHandler
-+ def _check_uncompressed_db_gen(self, repo, mdtype, fast=True):
++ def _check_uncompressed_db_gen(self, repo, mdtype):
+ """return file name of db in gen/ dir if good, None if not"""
+
+ mydbdata = repo.repoXML.getData(mdtype)
@@ -185630,7 +185719,7 @@ index e5e9ece..efbc42a 100644
+ db_un_fn = mdtype + '.sqlite'
+
+ if not repo._checkMD(compressed_fn, mdtype, data=mydbdata,
-+ check_can_fail=fast, fast=fast):
++ check_can_fail=True):
+ return None
+
+ ret = misc.repo_gen_decompress(compressed_fn, db_un_fn,
@@ -185642,7 +185731,7 @@ index e5e9ece..efbc42a 100644
def _check_uncompressed_db(self, repo, mdtype):
"""return file name of uncompressed db is good, None if not"""
mydbdata = repo.repoXML.getData(mdtype)
-@@ -201,9 +255,11 @@ class YumPackageSack(packageSack.PackageSack):
+@@ -201,12 +294,13 @@ class YumPackageSack(packageSack.PackageSack):
compressed_fn = repo.cachedir + '/' + fname
db_un_fn = misc.decompress(compressed_fn, fn_only=True)
@@ -185653,9 +185742,21 @@ index e5e9ece..efbc42a 100644
- repo._preload_md_from_system_cache(os.path.basename(db_un_fn))
if os.path.exists(db_un_fn):
- if skip_old_DBMD_check and repo._using_old_MD:
- return db_un_fn
-@@ -260,10 +316,11 @@ class YumRepository(Repository, config.RepoConf):
+- if skip_old_DBMD_check and repo._using_old_MD:
+- return db_un_fn
++
+
+ try:
+ repo.checkMD(db_un_fn, mdtype, openchecksum=True)
+@@ -240,7 +334,6 @@ class YumRepository(Repository, config.RepoConf):
+ # eventually want
+ self.repoMDFile = 'repodata/repomd.xml'
+ self._repoXML = None
+- self._using_old_MD = None
+ self._oldRepoMDData = {}
+ self.cache = 0
+ self.mirrorlistparsed = 0
+@@ -260,10 +353,11 @@ class YumRepository(Repository, config.RepoConf):
self.copy_local = 0
# holder for stuff we've grabbed
self.retrieved = { 'primary':0, 'filelists':0, 'other':0, 'group':0,
@@ -185668,7 +185769,7 @@ index e5e9ece..efbc42a 100644
self.failure_obj = None
self.mirror_failure_obj = None
self.interrupt_callback = None
-@@ -285,6 +342,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -285,6 +379,7 @@ class YumRepository(Repository, config.RepoConf):
self._grabfunc = None
self._grab = None
@@ -185676,7 +185777,7 @@ index e5e9ece..efbc42a 100644
def __cmp__(self, other):
""" Sort yum repos. by cost, and then by alphanumeric on their id. """
-@@ -311,6 +369,36 @@ class YumRepository(Repository, config.RepoConf):
+@@ -311,6 +406,36 @@ class YumRepository(Repository, config.RepoConf):
return self._sack
sack = property(_getSack)
@@ -185713,7 +185814,7 @@ index e5e9ece..efbc42a 100644
def close(self):
if self._sack is not None:
self.sack.close()
-@@ -350,6 +438,10 @@ class YumRepository(Repository, config.RepoConf):
+@@ -350,6 +475,10 @@ class YumRepository(Repository, config.RepoConf):
return thisdata.location
def __str__(self):
@@ -185724,7 +185825,7 @@ index e5e9ece..efbc42a 100644
return self.id
def _checksum(self, sumtype, file, CHUNK=2**16, checksum_can_fail=False,
-@@ -378,7 +470,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -378,7 +507,7 @@ class YumRepository(Repository, config.RepoConf):
'basecachedir', 'http_headers', 'metadata_cookie',
'metadata_cookie_fn', 'quick_enable_disable',
'repoMDFile', 'timestamp_check', 'urls', 'mirrorurls',
@@ -185733,7 +185834,7 @@ index e5e9ece..efbc42a 100644
for attr in dir(self):
if attr.startswith('_'):
continue
-@@ -422,7 +514,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -422,7 +551,7 @@ class YumRepository(Repository, config.RepoConf):
on then raise a repo error"""
if len(self._urls) < 1 and not self.mediaid:
raise Errors.RepoError, \
@@ -185742,7 +185843,7 @@ index e5e9ece..efbc42a 100644
def doProxyDict(self):
if self._proxy_dict:
-@@ -431,25 +523,18 @@ class YumRepository(Repository, config.RepoConf):
+@@ -431,25 +560,18 @@ class YumRepository(Repository, config.RepoConf):
self._proxy_dict = {} # zap it
proxy_string = None
empty = (None, '_none_', '')
@@ -185776,7 +185877,7 @@ index e5e9ece..efbc42a 100644
if proxy_string is not None:
self._proxy_dict['http'] = proxy_string
-@@ -483,13 +568,30 @@ class YumRepository(Repository, config.RepoConf):
+@@ -483,13 +605,30 @@ class YumRepository(Repository, config.RepoConf):
ugopts = self._default_grabopts()
self._grabfunc = URLGrabber(progress_obj=self.callback,
@@ -185808,7 +185909,7 @@ index e5e9ece..efbc42a 100644
failure_callback=self.mirror_failure_obj)
def _default_grabopts(self, cache=True):
-@@ -499,6 +601,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -499,6 +638,7 @@ class YumRepository(Repository, config.RepoConf):
'throttle': self.throttle,
'proxies': self.proxy_dict,
'timeout': self.timeout,
@@ -185816,7 +185917,7 @@ index e5e9ece..efbc42a 100644
'http_headers': tuple(self.__headersListFromDict(cache=cache)),
'ssl_verify_peer': self.sslverify,
'ssl_verify_host': self.sslverify,
-@@ -561,7 +664,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -561,7 +701,7 @@ class YumRepository(Repository, config.RepoConf):
cookie = self.cachedir + '/' + self.metadata_cookie_fn
self.setAttribute('_dir_setup_metadata_cookie', cookie)
@@ -185825,7 +185926,7 @@ index e5e9ece..efbc42a 100644
self._dirSetupMkdir_p(dir)
# persistdir is really root-only but try the make anyway and just
-@@ -714,15 +817,15 @@ class YumRepository(Repository, config.RepoConf):
+@@ -714,15 +854,15 @@ class YumRepository(Repository, config.RepoConf):
local = self.metalink_filename + '.tmp'
if not self._metalinkCurrent():
url = misc.to_utf8(self.metalink)
@@ -185845,7 +185946,7 @@ index e5e9ece..efbc42a 100644
raise Errors.RepoError, msg
# Now, we have an old usable metalink, so we can't move to
# a newer repomd.xml ... or checksums won't match.
-@@ -749,9 +852,22 @@ class YumRepository(Repository, config.RepoConf):
+@@ -749,9 +889,22 @@ class YumRepository(Repository, config.RepoConf):
value),
fdel=lambda self: setattr(self, "_metalink", None))
@@ -185869,7 +185970,7 @@ index e5e9ece..efbc42a 100644
"""retrieve file from the mirrorgroup for the repo
relative to local, optionally get range from
start to end, also optionally retrieve from a specific baseurl"""
-@@ -768,7 +884,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -768,7 +921,7 @@ class YumRepository(Repository, config.RepoConf):
if local is None or relative is None:
raise Errors.RepoError, \
@@ -185878,7 +185979,7 @@ index e5e9ece..efbc42a 100644
if self.cache == 1:
if os.path.exists(local): # FIXME - we should figure out a way
-@@ -778,7 +894,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -778,7 +931,7 @@ class YumRepository(Repository, config.RepoConf):
raise Errors.RepoError, \
"Caching enabled but no local cache of %s from %s" % (local,
@@ -185887,7 +185988,7 @@ index e5e9ece..efbc42a 100644
if url:
(scheme, netloc, path, query, fragid) = urlparse.urlsplit(url)
-@@ -796,6 +912,16 @@ class YumRepository(Repository, config.RepoConf):
+@@ -796,6 +949,16 @@ class YumRepository(Repository, config.RepoConf):
except Errors.MediaError, e:
verbose_logger.log(logginglevels.DEBUG_2, "Error getting package from media; falling back to url %s" %(e,))
@@ -185904,25 +186005,25 @@ index e5e9ece..efbc42a 100644
if url and scheme != "media":
ugopts = self._default_grabopts(cache=cache)
ug = URLGrabber(progress_obj = self.callback,
-@@ -815,14 +941,12 @@ class YumRepository(Repository, config.RepoConf):
+@@ -815,14 +978,9 @@ class YumRepository(Repository, config.RepoConf):
range=(start, end),
)
except URLGrabError, e:
- errstr = "failed to retrieve %s from %s\nerror was %s" % (relative, self.id, e)
-+ self._del_dl_file(local, size)
-+ errstr = "failed to retrieve %s from %s\nerror was %s" % (relative, self, e)
- if self.mirrorurls:
- errstr +="\n You could try running: yum clean expire-cache"
- errstr +="\n To get a new set of mirrors."
+- if self.mirrorurls:
+- errstr +="\n You could try running: yum clean expire-cache"
+- errstr +="\n To get a new set of mirrors."
- if e.errno == 256:
- raise Errors.NoMoreMirrorsRepoError, errstr
- else:
- raise Errors.RepoError, errstr
++ self._del_dl_file(local, size)
++ errstr = "failed to retrieve %s from %s\nerror was %s" % (relative, self, e)
+ raise Errors.RepoError, errstr
else:
-@@ -835,19 +959,19 @@ class YumRepository(Repository, config.RepoConf):
+@@ -835,19 +993,19 @@ class YumRepository(Repository, config.RepoConf):
reget = reget,
checkfunc=checkfunc,
http_headers=headers,
@@ -185949,7 +186050,7 @@ index e5e9ece..efbc42a 100644
remote = package.relativepath
local = package.localPkg()
basepath = package.basepath
-@@ -857,15 +981,30 @@ class YumRepository(Repository, config.RepoConf):
+@@ -857,15 +1015,30 @@ class YumRepository(Repository, config.RepoConf):
return local
misc.unlink_f(local)
@@ -185981,7 +186082,7 @@ index e5e9ece..efbc42a 100644
def getHeader(self, package, checkfunc = None, reget = 'simple',
cache = True):
-@@ -933,7 +1072,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -933,7 +1106,7 @@ class YumRepository(Repository, config.RepoConf):
self._metadataCurrent = False
return self._metadataCurrent
@@ -185990,7 +186091,7 @@ index e5e9ece..efbc42a 100644
"""check if any file is older than a certain amount of time. Used for
the cachecookie and the mirrorlist
return True if w/i the expiration time limit
-@@ -943,6 +1082,24 @@ class YumRepository(Repository, config.RepoConf):
+@@ -943,6 +1116,24 @@ class YumRepository(Repository, config.RepoConf):
file. If any of them are newer then invalidate the cache
"""
@@ -186015,7 +186116,7 @@ index e5e9ece..efbc42a 100644
# -1 is special and should never get refreshed
if expiration_time == -1 and os.path.exists(myfile):
return True
-@@ -991,7 +1148,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -991,7 +1182,7 @@ class YumRepository(Repository, config.RepoConf):
def _cachingRepoXML(self, local):
""" Should we cache the current repomd.xml """
if self.cache and not os.path.exists(local):
@@ -186024,7 +186125,7 @@ index e5e9ece..efbc42a 100644
if self.cache or self.metadataCurrent():
return True
return False
-@@ -1020,7 +1177,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1020,7 +1211,7 @@ class YumRepository(Repository, config.RepoConf):
if grab_can_fail:
return None
raise Errors.RepoError, 'Error downloading file %s: %s' % (local, e)
@@ -186033,7 +186134,7 @@ index e5e9ece..efbc42a 100644
misc.unlink_f(tfname)
if grab_can_fail:
return None
-@@ -1047,7 +1204,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1047,7 +1238,7 @@ class YumRepository(Repository, config.RepoConf):
parse_can_fail = 'old_repo_XML' in self._oldRepoMDData
if parse_can_fail:
return None
@@ -186042,7 +186143,7 @@ index e5e9ece..efbc42a 100644
def _saveOldRepoXML(self, local):
""" If we have an older repomd.xml file available, save it out. """
-@@ -1074,7 +1231,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1074,7 +1265,7 @@ class YumRepository(Repository, config.RepoConf):
# We still want the old data, so we don't download twice. So we
# pretend everything is good until the revert.
if not self.timestamp_check:
@@ -186051,7 +186152,15 @@ index e5e9ece..efbc42a 100644
if 'old_repo_XML' not in self._oldRepoMDData:
self._oldRepoMDData = {}
-@@ -1260,6 +1417,9 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1250,7 +1441,6 @@ class YumRepository(Repository, config.RepoConf):
+ self._revertOldRepoXML()
+ return False
+
+- self._using_old_MD = caching
+ if caching:
+ return False # Skip any work.
+
+@@ -1260,6 +1450,9 @@ class YumRepository(Repository, config.RepoConf):
return True
def _check_db_version(self, mdtype, repoXML=None):
@@ -186061,7 +186170,7 @@ index e5e9ece..efbc42a 100644
if repoXML is None:
repoXML = self.repoXML
if mdtype in repoXML.repoData:
-@@ -1277,11 +1437,11 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1277,11 +1470,11 @@ class YumRepository(Repository, config.RepoConf):
return None
if not file_check:
@@ -186076,7 +186185,7 @@ index e5e9ece..efbc42a 100644
if not os.path.exists(local):
local = misc.decompress(local, fn_only=True)
compressed = True
-@@ -1302,6 +1462,17 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1302,6 +1495,17 @@ class YumRepository(Repository, config.RepoConf):
into the delete list, this means metadata can change filename
without us leaking it. """
@@ -186094,7 +186203,7 @@ index e5e9ece..efbc42a 100644
def _mdtype_eq(omdtype, odata, nmdtype, ndata):
""" Check if two returns from _get_mdtype_data() are equal. """
if ndata is None:
-@@ -1321,6 +1492,14 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1321,6 +1525,14 @@ class YumRepository(Repository, config.RepoConf):
return True
all_mdtypes = self.retrieved.keys()
@@ -186109,7 +186218,7 @@ index e5e9ece..efbc42a 100644
if mdtypes is None:
mdtypes = all_mdtypes
-@@ -1333,8 +1512,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1333,8 +1545,7 @@ class YumRepository(Repository, config.RepoConf):
# Inited twice atm. ... sue me
self._oldRepoMDData['new_MD_files'] = []
@@ -186119,7 +186228,7 @@ index e5e9ece..efbc42a 100644
for mdtype in all_mdtypes:
(nmdtype, ndata) = self._get_mdtype_data(mdtype)
-@@ -1371,43 +1549,16 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1371,43 +1582,16 @@ class YumRepository(Repository, config.RepoConf):
# No old repomd data, but we might still have uncompressed MD
if self._groupCheckDataMDValid(ndata, nmdtype, mdtype):
continue
@@ -186134,7 +186243,9 @@ index e5e9ece..efbc42a 100644
- if len(downloading_with_size) == 1:
- downloading_no_size.extend(downloading_with_size)
- downloading_with_size = []
--
++ def _commonRetrieveDataMD_done(self, downloading):
++ """ Uncompress the downloaded metadata """
+
- remote_size = 0
- local_size = 0
- for (ndata, nmdtype) in downloading_with_size: # Get total size...
@@ -186151,9 +186262,7 @@ index e5e9ece..efbc42a 100644
- if not self._retrieveMD(nmdtype, retrieve_can_fail=True):
- self._revertOldRepoXML()
- return False
-+ def _commonRetrieveDataMD_done(self, downloading):
-+ """ Uncompress the downloaded metadata """
-
+-
- for (ndata, nmdtype) in downloading_with_size + downloading_no_size:
+ for (ndata, nmdtype) in downloading:
local = self._get_mdtype_fname(ndata, False)
@@ -186168,7 +186277,7 @@ index e5e9ece..efbc42a 100644
def _groupLoadRepoXML(self, text=None, mdtypes=None):
""" Retrieve the new repomd.xml from the repository, then check it
-@@ -1421,7 +1572,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1421,7 +1605,7 @@ class YumRepository(Repository, config.RepoConf):
self._commonRetrieveDataMD(mdtypes)
def _mdpolicy2mdtypes(self):
@@ -186177,7 +186286,7 @@ index e5e9ece..efbc42a 100644
'group:primary' : ['primary'],
'group:small' : ["primary", "updateinfo"],
'group:main' : ["primary", "group", "filelists",
-@@ -1436,6 +1587,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1436,6 +1620,7 @@ class YumRepository(Repository, config.RepoConf):
if not mdtypes or 'group:all' in mdtypes:
mdtypes = None
else:
@@ -186185,7 +186294,7 @@ index e5e9ece..efbc42a 100644
mdtypes = sorted(list(mdtypes))
return mdtypes
-@@ -1446,17 +1598,12 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1446,17 +1631,12 @@ class YumRepository(Repository, config.RepoConf):
except KeyboardInterrupt:
self._revertOldRepoXML() # Undo metadata cookie?
raise
@@ -186205,7 +186314,7 @@ index e5e9ece..efbc42a 100644
return self._repoXML
-@@ -1480,7 +1627,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1480,7 +1660,7 @@ class YumRepository(Repository, config.RepoConf):
result = self._getFile(relative='repodata/repomd.xml.asc',
copy_local=1,
local = sigfile,
@@ -186214,7 +186323,7 @@ index e5e9ece..efbc42a 100644
reget=None,
checkfunc=None,
cache=self.http_caching == 'all',
-@@ -1508,13 +1655,25 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1508,6 +1688,18 @@ class YumRepository(Repository, config.RepoConf):
raise URLGrabError(-1, 'repomd.xml does not match metalink for %s' %
self)
@@ -186233,34 +186342,32 @@ index e5e9ece..efbc42a 100644
def checkMD(self, fn, mdtype, openchecksum=False):
"""check the metadata type against its checksum"""
- return self._checkMD(fn, mdtype, openchecksum)
-
- def _checkMD(self, fn, mdtype, openchecksum=False,
-- data=None, check_can_fail=False):
-+ data=None, check_can_fail=False, fast=False):
- """ Internal function, use .checkMD() from outside yum. """
-
- thisdata = data # So the argument name is nicer
-@@ -1537,6 +1696,18 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1537,6 +1729,17 @@ class YumRepository(Repository, config.RepoConf):
if size is not None:
size = int(size)
-+ if fast and skip_old_DBMD_check:
++ l_csum = _xattr_get_chksum(file, r_ctype)
++ if l_csum:
+ fsize = misc.stat_f(file)
+ if fsize is None: # File doesn't exist...
+ return None
-+ if size is None:
++ if size is None and l_csum == r_csum:
+ return 1
-+ if size == fsize.st_size:
++ if size == fsize.st_size and l_csum == r_csum:
+ return 1
-+ if check_can_fail:
-+ return None
-+ raise URLGrabError(-1, 'Metadata file does not match size')
++ # Redo it ... just to make sure...
+
try: # get the local checksum
l_csum = self._checksum(r_ctype, file, datasize=size)
except Errors.RepoError, e:
-@@ -1551,15 +1722,13 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1545,21 +1748,20 @@ class YumRepository(Repository, config.RepoConf):
+ raise URLGrabError(-3, 'Error performing checksum')
+
+ if l_csum == r_csum:
++ _xattr_set_chksum(file, r_ctype, l_csum)
+ return 1
+ else:
+ if check_can_fail:
return None
raise URLGrabError(-1, 'Metadata file does not match checksum')
@@ -186277,7 +186384,7 @@ index e5e9ece..efbc42a 100644
""" Internal function, use .retrieveMD() from outside yum. """
# Note that this can raise Errors.RepoMDError if mdtype doesn't exist
# for this repo.
-@@ -1580,15 +1749,19 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1580,15 +1782,19 @@ class YumRepository(Repository, config.RepoConf):
try:
self.checkMD(local, mdtype)
except URLGrabError, e:
@@ -186298,7 +186405,7 @@ index e5e9ece..efbc42a 100644
if (os.path.exists(local) or
self._preload_md_from_system_cache(os.path.basename(local))):
-@@ -1597,15 +1770,22 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1597,15 +1803,22 @@ class YumRepository(Repository, config.RepoConf):
return local # it's the same return the local one
try:
@@ -186326,7 +186433,7 @@ index e5e9ece..efbc42a 100644
local = self._getFile(relative=remote,
local=local,
copy_local=1,
-@@ -1613,8 +1793,9 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1613,8 +1826,9 @@ class YumRepository(Repository, config.RepoConf):
checkfunc=checkfunc,
text=text,
cache=self.http_caching == 'all',
@@ -186338,7 +186445,7 @@ index e5e9ece..efbc42a 100644
if retrieve_can_fail:
return None
raise
-@@ -1622,9 +1803,8 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1622,9 +1836,8 @@ class YumRepository(Repository, config.RepoConf):
if retrieve_can_fail:
return None
raise Errors.RepoError, \
@@ -186349,7 +186456,7 @@ index e5e9ece..efbc42a 100644
return local
-@@ -1646,13 +1826,21 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1646,13 +1859,21 @@ class YumRepository(Repository, config.RepoConf):
def getGroups(self):
"""gets groups and returns group file path for the repository, if there
@@ -186374,7 +186481,7 @@ index e5e9ece..efbc42a 100644
self._callbacks_changed = True
def setFailureObj(self, failure_obj):
-@@ -1681,7 +1869,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1681,7 +1902,7 @@ class YumRepository(Repository, config.RepoConf):
print "Could not read mirrorlist %s, error was \n%s" %(url, e)
content = []
for line in content:
@@ -186383,7 +186490,7 @@ index e5e9ece..efbc42a 100644
continue
mirror = line.rstrip() # no more trailing \n's
mirror = mirror.replace('$ARCH', '$BASEARCH')
-@@ -1701,7 +1889,8 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1701,7 +1922,8 @@ class YumRepository(Repository, config.RepoConf):
fo = None
cacheok = False
@@ -186393,7 +186500,7 @@ index e5e9ece..efbc42a 100644
cacheok = True
fo = open(self.mirrorlist_file, 'r')
url = 'file://' + self.mirrorlist_file # just to keep self._readMirrorList(fo,url) happy
-@@ -1713,7 +1902,7 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1713,7 +1935,7 @@ class YumRepository(Repository, config.RepoConf):
ugopts = self._default_grabopts()
try:
fo = urlgrabber.grabber.urlopen(url, **ugopts)
@@ -186402,7 +186509,7 @@ index e5e9ece..efbc42a 100644
print "Could not retrieve mirrorlist %s error was\n%s: %s" % (url, e.args[0], misc.to_unicode(e.args[1]))
fo = None
-@@ -1740,7 +1929,11 @@ class YumRepository(Repository, config.RepoConf):
+@@ -1740,7 +1962,11 @@ class YumRepository(Repository, config.RepoConf):
if os.path.exists(destfn):
if os.stat(fn)[stat.ST_CTIME] <= os.stat(destfn)[stat.ST_CTIME]:
return False
@@ -186415,7 +186522,7 @@ index e5e9ece..efbc42a 100644
return True
def _preload_file_from_system_cache(self, filename, subdir='',
-@@ -1877,7 +2070,7 @@ def getMirrorList(mirrorlist, pdict = None):
+@@ -1877,7 +2103,7 @@ def getMirrorList(mirrorlist, pdict = None):
try:
fo = urlresolver.urlopen(url, proxies=pdict)
@@ -189596,7 +189703,7 @@ index 4dcbea7..1cc4fdf 100644
+ return InfoCommand().cacheRequirement(base, cmd, extcmds[2:])
+ return 'write'
diff --git a/yummain.py b/yummain.py
-index 9f79f4f..a9f001b 100755
+index 9f79f4f..ac94f65 100755
--- a/yummain.py
+++ b/yummain.py
@@ -29,13 +29,13 @@ from yum import Errors
@@ -189640,7 +189747,7 @@ index 9f79f4f..a9f001b 100755
# our core object for the cli
base = cli.YumBaseCli()
-@@ -100,41 +117,10 @@ def main(args):
+@@ -100,46 +117,20 @@ def main(args):
return exPluginExit(e)
except Errors.YumBaseError, e:
return exFatal(e)
@@ -189685,7 +189792,17 @@ index 9f79f4f..a9f001b 100755
try:
result, resultmsgs = base.doCommands()
-@@ -154,7 +140,7 @@ def main(args):
+ except plugins.PluginYumExit, e:
+ return exPluginExit(e)
++ except Errors.RepoError, e:
++ result = 1
++ resultmsgs = [exception2msg(e)]
++ # For RepoErrors ... help out by forcing new repodata next time.
++ base.cleanExpireCache()
+ except Errors.YumBaseError, e:
+ result = 1
+ resultmsgs = [exception2msg(e)]
+@@ -154,7 +145,7 @@ def main(args):
for msg in resultmsgs:
verbose_logger.log(logginglevels.INFO_2, '%s', msg)
if unlock(): return 200
@@ -189694,7 +189811,19 @@ index 9f79f4f..a9f001b 100755
elif result == 1:
# Fatal error
for msg in resultmsgs:
-@@ -193,7 +179,7 @@ def main(args):
+@@ -181,6 +172,11 @@ def main(args):
+ (result, resultmsgs) = base.buildTransaction()
+ except plugins.PluginYumExit, e:
+ return exPluginExit(e)
++ except Errors.RepoError, e:
++ result = 1
++ resultmsgs = [exception2msg(e)]
++ # For RepoErrors ... help out by forcing new repodata next time.
++ base.cleanExpireCache()
+ except Errors.YumBaseError, e:
+ result = 1
+ resultmsgs = [exception2msg(e)]
+@@ -193,7 +189,7 @@ def main(args):
if result == 0:
# Normal exit
if unlock(): return 200
@@ -189703,7 +189832,19 @@ index 9f79f4f..a9f001b 100755
elif result == 1:
# Fatal error
for msg in resultmsgs:
-@@ -238,16 +224,27 @@ def main(args):
+@@ -223,6 +219,11 @@ def main(args):
+ return_code = base.doTransaction()
+ except plugins.PluginYumExit, e:
+ return exPluginExit(e)
++ except Errors.RepoError, e:
++ result = 1
++ resultmsgs = [exception2msg(e)]
++ # For RepoErrors ... help out by forcing new repodata next time.
++ base.cleanExpireCache()
+ except Errors.YumBaseError, e:
+ return exFatal(e)
+ except KeyboardInterrupt:
+@@ -238,16 +239,27 @@ def main(args):
rpmdb_warn_checks()
return_code = result
if base._ts_save_file:
@@ -189733,7 +189874,7 @@ index 9f79f4f..a9f001b 100755
import hotshot.stats
fn = os.path.expanduser("~/yum.prof")
prof = hotshot.Profile(fn)
-@@ -257,6 +254,11 @@ def hotshot(func, *args, **kwargs):
+@@ -257,6 +269,11 @@ def hotshot(func, *args, **kwargs):
return rc
def cprof(func, *args, **kwargs):
@@ -189745,7 +189886,7 @@ index 9f79f4f..a9f001b 100755
import cProfile, pstats
fn = os.path.expanduser("~/yum.prof")
prof = cProfile.Profile()
-@@ -266,6 +268,10 @@ def cprof(func, *args, **kwargs):
+@@ -266,6 +283,10 @@ def cprof(func, *args, **kwargs):
return rc
def print_stats(stats):
@@ -189756,7 +189897,7 @@ index 9f79f4f..a9f001b 100755
stats.strip_dirs()
stats.sort_stats('time', 'calls')
stats.print_stats(20)
-@@ -273,7 +279,14 @@ def print_stats(stats):
+@@ -273,7 +294,14 @@ def print_stats(stats):
stats.print_stats(40)
def user_main(args, exit_code=False):
diff --git a/yum.spec b/yum.spec
index 1aa4dfc..d142e4c 100644
--- a/yum.spec
+++ b/yum.spec
@@ -2,6 +2,12 @@
%define auto_sitelib 1
%define yum_updatesd 0
%define disable_check 1
+%define yum_cron 1
+
+%if 0%{?rhel} == 6
+# rhel-6 doesn't have the systemd stuff, so won't build...
+%define yum_cron 0
+%endif
%if %{auto_sitelib}
@@ -18,7 +24,7 @@
Summary: RPM package installer/updater/manager
Name: yum
Version: 3.4.3
-Release: 59%{?dist}
+Release: 60%{?dist}
License: GPLv2+
Group: System Environment/Base
Source0: http://yum.baseurl.org/download/3.4/%{name}-%{version}.tar.gz
@@ -121,7 +127,7 @@ Requires(postun): /sbin/service
yum-updatesd provides a daemon which checks for available updates and
can notify you when they are available via email, syslog or dbus.
-
+%if %{yum_cron}
%package cron
Summary: Files needed to run yum updates as a cron job
Group: System Environment/Base
@@ -134,7 +140,7 @@ Requires(postun): systemd
%description cron
These are the files needed to run yum updates as a cron job.
Install this package if you want auto yum updates nightly via cron.
-
+%endif
%prep
@@ -197,6 +203,15 @@ chmod +x $RPM_BUILD_ROOT/%{python_sitelib}/rpmUtils/*.py
%find_lang %name
+%if ! %{yum_cron}
+# Remove the yum-cron stuff to make rpmbuild happy..
+rm -f $RPM_BUILD_ROOT/%{_unitdir}/yum-cron.service
+rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/cron.daily/0yum-update.cron
+rm -f $RPM_BUILD_ROOT/%{_sysconfdir}/yum/yum-cron.conf
+rm -f $RPM_BUILD_ROOT/%{_sbindir}/yum-cron
+rm -f $RPM_BUILD_ROOT/%{_mandir}/man*/yum-cron.*
+%endif
+
%clean
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf $RPM_BUILD_ROOT
@@ -215,7 +230,7 @@ fi
exit 0
%endif
-
+%if %{yum_cron}
%post cron
#systemd_post yum-cron.service
@@ -240,7 +255,7 @@ fi
%postun cron
%systemd_postun_with_restart yum-cron.service
-
+%endif
%files -f %{name}.lang
@@ -281,6 +296,7 @@ fi
%dir %{yum_pluginslib}
%dir %{yum_pluginsshare}
+%if %{yum_cron}
%files cron
%defattr(-,root,root)
%doc COPYING
@@ -289,6 +305,7 @@ fi
%{_unitdir}/yum-cron.service
%{_sbindir}/yum-cron
%{_mandir}/man*/yum-cron.*
+%endif
%if %{yum_updatesd}
%files updatesd
@@ -302,6 +319,11 @@ fi
%endif
%changelog
+* Mon Feb 18 2013 James Antill <james at fedoraproject.org> - 3.4.3-60
+- update to latest HEAD.
+- Auto expire caches on repo errors.
+- Use xattrs for cache checksum speedup.
+
* Fri Feb 15 2013 James Antill <james at fedoraproject.org> - 3.4.3-59
- update to latest HEAD.
- Add load-ts helper.
More information about the scm-commits
mailing list