[yum-commits] 7 commits - yum/comps.py yum/config.py yum/update_md.py yum/yumRepo.py
James Antill
james at osuosl.org
Wed Aug 29 15:37:27 UTC 2012
yum/comps.py | 5 ++++-
yum/config.py | 23 +++++++++++++++--------
yum/update_md.py | 49 ++++++++++++++++++++++++++++++++++++++++++++++++-
yum/yumRepo.py | 43 ++++++++++++++++++++++++++++++++++++-------
4 files changed, 103 insertions(+), 17 deletions(-)
New commits:
commit 7082fea2e87a96a410eedaf22766b36738574451
Merge: e59202a 25804df
Author: James Antill <james at and.org>
Date: Wed Aug 29 11:37:23 2012 -0400
Merge branch 'master' of ssh://yum.baseurl.org/srv/projects/yum/git/yum
* 'master' of ssh://yum.baseurl.org/srv/projects/yum/git/yum: (2 commits)
Report empty/invalid BZ2/GZ files.
...
commit e59202ad141c2fe6ad5d9f14057b9664c48c3b2a
Author: James Antill <james at and.org>
Date: Wed Aug 29 10:39:34 2012 -0400
Fix problem with auto str() on repo. objects and + in python.
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index 4c63bf2..fc002b9 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -808,7 +808,7 @@ class YumRepository(Repository, config.RepoConf):
ugopts = self._default_grabopts(cache=self.http_caching=='all')
try:
ug = URLGrabber(progress_obj = self.callback, **ugopts)
- result = ug.urlgrab(url, local, text=self + "/metalink")
+ result = ug.urlgrab(url, local, text="%s/metalink" % self)
except urlgrabber.grabber.URLGrabError, e:
if not os.path.exists(self.metalink_filename):
commit f291a34772a5d843e27b00720ea96a25306a300b
Merge: 04a44ca 88fc201
Author: James Antill <james at and.org>
Date: Tue Aug 28 16:17:44 2012 -0400
Fix merge on mirror errors.
diff --cc yum/yumRepo.py
index b5db2e1,ec68b6a..4c63bf2
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@@ -940,11 -908,9 +937,9 @@@ Insufficient space in download director
**kwargs
)
except URLGrabError, e:
- errstr = "failure: %s from %s: %s" % (relative, self.id, e)
+ errstr = "failure: %s from %s: %s" % (relative, self, e)
- if e.errno == 256:
- raise Errors.NoMoreMirrorsRepoError, errstr
- else:
- raise Errors.RepoError, errstr
+ errors = getattr(e, 'errors', None)
+ raise Errors.NoMoreMirrorsRepoError(errstr, errors)
return result
__get = _getFile
commit 04a44caeb395e3dfed4a6074b4223b99e34234d5
Author: Jesse Keating <jkeating at redhat.com>
Date: Tue Aug 28 12:35:26 2012 -0700
Include environments when writing comps (rhbz#852240)
Environments are new, and we need to include those when writing out a
merged comps. This just wires up the existing infrastructure that came
from previous patches.
diff --git a/yum/comps.py b/yum/comps.py
index cf671b6..08e66b9 100755
--- a/yum/comps.py
+++ b/yum/comps.py
@@ -790,7 +790,8 @@ class Comps(object):
def xml(self):
"""returns the xml of the comps files in this class, merged"""
- if not self._groups and not self._categories:
+ if not self._groups and not self._categories and \
+ not self._environments:
return ""
msg = """<?xml version="1.0" encoding="UTF-8"?>
@@ -802,6 +803,8 @@ class Comps(object):
msg += g.xml()
for c in self.get_categories():
msg += c.xml()
+ for e in self.get_environments():
+ msg += e.xml()
msg += """\n</comps>\n"""
commit 2ebc8ab8e9043985acb9da530af8269e1aafc446
Author: James Antill <james at and.org>
Date: Mon Aug 27 15:24:42 2012 -0400
Add code to merge the refs/pkgs of two "identical" updateinfo errata. BZ 737173.
diff --git a/yum/update_md.py b/yum/update_md.py
index 7da6a08..0586c1c 100644
--- a/yum/update_md.py
+++ b/yum/update_md.py
@@ -90,6 +90,20 @@ class UpdateNotice(object):
def __setitem__(self, item, val):
self._md[item] = val
+ def __eq__(self, other):
+ # Tests to see if it's "the same data", which means that the
+ # packages can be different (see add_notice).
+
+ if not other or not hasattr(other, '_md'):
+ return False
+
+ for data in ('type', 'update_id', 'status', 'rights',
+ 'issued', 'updated', 'version', 'pushcount',
+ 'from', 'title', 'summary', 'description', 'solution'):
+ if self._md[data] != other._md[data]:
+ return False
+ return True
+
def text(self, skip_data=('files', 'summary', 'rights', 'solution')):
head = """
===============================================================================
@@ -429,9 +443,42 @@ class UpdateMetadata(object):
def add_notice(self, un):
""" Add an UpdateNotice object. This should be fully populated with
data, esp. update_id and pkglist/packages. """
- if not un or not un["update_id"] or un['update_id'] in self._notices:
+ if not un or not un["update_id"]:
return
+ # This is "special", the main thing we want to deal with here is
+ # having one errata that has multiple packages in it rpmA and rpmB, but
+ # the packages are in repos. repoA and repoB. So instead of doing a
+ # single errata pointing to both rpmA and rpmB and put the same thing
+ # in both repodata (which is legal, and works fine) people want to have
+ # just the packages from repoA in the repodata for repoA and vice versa.
+ if un['update_id'] in self._notices:
+ oun = self._notices[un['update_id']]
+ if oun != un:
+ return
+
+ # Ok, main parts of errata are the same, so now merge references:
+ seen = set()
+ for ref in oun['references']:
+ seen.add(ref['id'])
+ for ref in un['references']:
+ if ref['id'] in seen:
+ continue
+ seen.add(ref['id'])
+ oun['references'].append(ref)
+
+ # ...and pkglist (this assumes that a pkglist name XYZ is the same):
+ seen = set()
+ for pkg in oun['pkglist']:
+ seen.add(pkg['name'])
+ for pkg in un['pkglist']:
+ if pkg['name'] in seen:
+ continue
+ seen.add(pkg['name'])
+ oun['pkglist'].append(pkg)
+
+ un = oun
+
self._notices[un['update_id']] = un
for pkg in un['pkglist']:
for filedata in pkg['packages']:
commit e42ea3dc0b02ba73a11211de4062e87abfb77a6a
Author: James Antill <james at and.org>
Date: Mon Aug 27 16:27:44 2012 -0400
Add .ui_id to repos. showing $releasever/$basearch. Use it for str().
diff --git a/yum/yumRepo.py b/yum/yumRepo.py
index b7b4357..b5db2e1 100644
--- a/yum/yumRepo.py
+++ b/yum/yumRepo.py
@@ -366,6 +366,35 @@ class YumRepository(Repository, config.RepoConf):
return self._sack
sack = property(_getSack)
+ def _ui_id(self):
+ """ Show self.id, but include any $releasever/$basearch/etc. data. """
+ if hasattr(self, '__cached_ui_id'):
+ return getattr(self, '__cached_ui_id')
+
+ val = config._readRawRepoFile(self)
+ if not val:
+ val = ''
+ else:
+ ini, section_id = val
+ ini = ini[section_id]
+ if 'metalink' in ini:
+ val = ini['metalink']
+ elif 'mirrorlist' in ini:
+ val = ini['mirrorlist']
+ else:
+ val = ini['baseurl']
+ ret = self.id
+ if '$releasever' in val:
+ ret += '/'
+ ret += str(self.yumvar['releasever'])
+ if '$basearch' in val:
+ ret += '/'
+ ret += str(self.yumvar['basearch'])
+ # Could maybe list some other things here too?
+ setattr(self, '__cached_ui_id', ret)
+ return ret
+ ui_id = property(_ui_id)
+
def close(self):
if self._sack is not None:
self.sack.close()
@@ -405,7 +434,7 @@ class YumRepository(Repository, config.RepoConf):
return thisdata.location
def __str__(self):
- return self.id
+ return self.ui_id
def _checksum(self, sumtype, file, CHUNK=2**16, checksum_can_fail=False,
datasize=None):
@@ -779,7 +808,7 @@ class YumRepository(Repository, config.RepoConf):
ugopts = self._default_grabopts(cache=self.http_caching=='all')
try:
ug = URLGrabber(progress_obj = self.callback, **ugopts)
- result = ug.urlgrab(url, local, text=self.id + "/metalink")
+ result = ug.urlgrab(url, local, text=self + "/metalink")
except urlgrabber.grabber.URLGrabError, e:
if not os.path.exists(self.metalink_filename):
@@ -830,7 +859,7 @@ class YumRepository(Repository, config.RepoConf):
if local is None or relative is None:
raise Errors.RepoError, \
- "get request for Repo %s, gave no source or dest" % self.id
+ "get request for Repo %s, gave no source or dest" % self
if self.cache == 1:
if os.path.exists(local): # FIXME - we should figure out a way
@@ -887,7 +916,7 @@ Insufficient space in download directory %s
range=(start, end),
)
except URLGrabError, e:
- errstr = "failed to retrieve %s from %s\nerror was %s" % (relative, self.id, e)
+ 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."
@@ -911,7 +940,7 @@ Insufficient space in download directory %s
**kwargs
)
except URLGrabError, e:
- errstr = "failure: %s from %s: %s" % (relative, self.id, e)
+ errstr = "failure: %s from %s: %s" % (relative, self, e)
if e.errno == 256:
raise Errors.NoMoreMirrorsRepoError, errstr
else:
@@ -1554,7 +1583,7 @@ Insufficient space in download directory %s
result = self._getFile(relative='repodata/repomd.xml.asc',
copy_local=1,
local = sigfile,
- text='%s/signature' % self.id,
+ text='%s/signature' % self,
reget=None,
checkfunc=None,
cache=self.http_caching == 'all',
@@ -1684,7 +1713,7 @@ Insufficient space in download directory %s
def checkfunc(obj):
self.checkMD(obj, mdtype)
self.retrieved[mdtype] = 1
- text = "%s/%s" % (self.id, mdtype)
+ text = "%s/%s" % (self, mdtype)
if thisdata.size is None:
reget = None
else:
commit 3518dc7797ca49cf5e1c9de1b15d27448435854d
Author: James Antill <james at and.org>
Date: Mon Aug 27 16:26:09 2012 -0400
Add _readRawRepoFile() so we can get at the raw config. data easily.
diff --git a/yum/config.py b/yum/config.py
index 2bf4f45..b81020f 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -1169,15 +1169,9 @@ def _getsysver(installroot, distroverpkg):
del ts
return releasever
-def writeRawRepoFile(repo,only=None):
- """Write changes in a repo object back to a .repo file.
-
- :param repo: the Repo Object to write back out
- :param only: list of attributes to work on. If *only* is None, all
- options will be written out
- """
+def _readRawRepoFile(repo):
if not _use_iniparse:
- return
+ return None
ini = INIConfig(open(repo.repofile))
# b/c repoids can have $values in them we need to map both ways to figure
@@ -1187,6 +1181,19 @@ def writeRawRepoFile(repo,only=None):
for sect in ini._sections.keys():
if varReplace(sect, repo.yumvar) == repo.id:
section_id = sect
+ return ini, section_id
+
+def writeRawRepoFile(repo,only=None):
+ """Write changes in a repo object back to a .repo file.
+
+ :param repo: the Repo Object to write back out
+ :param only: list of attributes to work on. If *only* is None, all
+ options will be written out
+ """
+ if not _use_iniparse:
+ return
+
+ ini, section_id = _readRawRepoFile(repo)
# Updated the ConfigParser with the changed values
cfgOptions = repo.cfg.options(repo.id)
More information about the Yum-commits
mailing list