[yum-git] docs/yum.conf.5 rpmUtils/arch.py yum/config.py yum/__init__.py yum/rpmsack.py
Seth Vidal
skvidal at linux.duke.edu
Tue Jan 29 22:10:38 UTC 2008
docs/yum.conf.5 | 5 +++++
rpmUtils/arch.py | 23 +++++++++++++++++++----
yum/__init__.py | 31 +++++++++++++++++++++++++++++--
yum/config.py | 4 ++++
yum/rpmsack.py | 16 ++++++++++++++++
5 files changed, 73 insertions(+), 6 deletions(-)
New commits:
commit 50a8d997345c41567a11b28ed8c58216441272ec
Author: Seth Vidal <skvidal at fedoraproject.org>
Date: Tue Jan 29 17:10:28 2008 -0500
multlib_policy patch to handle installs by
wildcard or package name.
see yum.conf man page for details
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index 89dc152..8bd217a 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -288,6 +288,11 @@ group data is used in some graphical clients and for group operations like
not listed above is the other metadata, which contains the changelog information
which is used by yum-changelog. This is what "yum makecache" uses.
+.IP \fBmultilib_policy \fR
+Can be set to 'all' or 'best'. All means install all possible arches for any package you
+want to install. Therefore yum install foo will install foo.i386 and foo.x86_64 on x86_64,
+if it is available. Best means install the best arch for this platform, only.
+
.SH "[repository] OPTIONS"
.LP
The repository section(s) take the following form:
diff --git a/rpmUtils/arch.py b/rpmUtils/arch.py
index 02df57c..dc84178 100644
--- a/rpmUtils/arch.py
+++ b/rpmUtils/arch.py
@@ -9,7 +9,6 @@ multilibArches = { "x86_64": ( "athlon", "x86_64", "athlon" ),
"sparc64": ( "sparc", "sparcv9", "sparc64" ),
"ppc64": ( "ppc", "ppc", "ppc64" ),
"s390x": ( "s390", "s390x", "s390" ),
- "ia64": ( "i686", "ia64", "i686" )
}
arches = {
@@ -26,9 +25,6 @@ arches = {
"amd64": "x86_64",
"ia32e": "x86_64",
- # itanium
- "ia64": "i686",
-
# ppc
"ppc64pseries": "ppc64",
"ppc64iseries": "ppc64",
@@ -60,6 +56,25 @@ arches = {
"armv5tel": "noarch",
}
+def legitMultiArchesInSameLib(arch=None):
+ # this is completely crackrock - if anyone has a better way I
+ # am all ears
+
+ arch = getBestArch(arch)
+ if isMultiLibArch(arch):
+ arch = getBaseArch(myarch=arch)
+
+ results = [arch]
+
+ if arch == 'x86_64' or arch.startswith('sparcv9'):
+ for (k, v) in arches.items():
+ if v == arch:
+ results.append(k)
+ return results
+
+
+
+
# this computes the difference between myarch and targetarch
def archDifference(myarch, targetarch):
if myarch == targetarch:
diff --git a/yum/__init__.py b/yum/__init__.py
index c6f8750..65d2554 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -1288,9 +1288,8 @@ class YumBase(depsolve.Depsolve):
else:
avail = self.pkgSack.returnNewestByNameArch(patterns=patterns)
- self.rpmdb._make_header_dict()
for pkg in avail:
- if not self.rpmdb._header_dict.has_key(pkg.pkgtup):
+ if not self.rpmdb.contains(po=pkg):
available.append(pkg)
@@ -1979,6 +1978,7 @@ class YumBase(depsolve.Depsolve):
"""
pkgs = []
+ was_pattern = False
if po:
if isinstance(po, YumAvailablePackage) or isinstance(po, YumLocalPackage):
pkgs.append(po)
@@ -1990,6 +1990,7 @@ class YumBase(depsolve.Depsolve):
raise Errors.InstallError, _('Nothing specified to install')
if kwargs.has_key('pattern'):
+ was_pattern = True
exactmatch, matched, unmatched = \
parsePackages(self.pkgSack.returnPackages(),[kwargs['pattern']] , casematch=1)
pkgs.extend(exactmatch)
@@ -2018,6 +2019,31 @@ class YumBase(depsolve.Depsolve):
ver=nevra_dict['version'], rel=nevra_dict['release'])
if pkgs:
+ # if was_pattern or nevra-dict['arch'] is none, take the list
+ # of arches based on our multilib_compat config and
+ # toss out any pkgs of any arch NOT in that arch list
+
+
+ # only do these things if we're multilib
+ if rpmUtils.arch.isMultiLibArch():
+ if was_pattern or not nevra_dict['arch']: # and only if they
+ # they didn't specify an arch
+ if self.conf.multilib_policy == 'best':
+ pkgs_by_name = {}
+ use = []
+ not_added = []
+ for pkg in pkgs:
+ if pkg.arch in rpmUtils.arch.legitMultiArchesInSameLib():
+ pkgs_by_name[pkg.name] = 1
+ use.append(pkg)
+ else:
+ not_added.append(pkg)
+ for pkg in not_added:
+ if not pkg.name in pkgs_by_name:
+ use.append(pkg)
+
+ pkgs = use
+
pkgSack = ListPackageSack(pkgs)
pkgs = pkgSack.returnNewestByName()
del(pkgSack)
@@ -2043,6 +2069,7 @@ class YumBase(depsolve.Depsolve):
# - install instead of erase
# - better error handling/reporting
+
tx_return = []
for po in pkgs:
if self.tsInfo.exists(pkgtup=po.pkgtup):
diff --git a/yum/config.py b/yum/config.py
index 38b66ba..416187a 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -637,6 +637,10 @@ class YumConf(StartupConf):
mdpolicy = SelectionOption('group:primary',
('instant', 'group:all', 'group:main',
'group:small', 'group:primary'))
+ multilib_policy = SelectionOption('all',('best', 'all'))
+ # all == install any/all arches you can
+ # best == use the 'best arch' for the system
+
_reposlist = []
diff --git a/yum/rpmsack.py b/yum/rpmsack.py
index 6507fab..58e6b4b 100644
--- a/yum/rpmsack.py
+++ b/yum/rpmsack.py
@@ -205,6 +205,22 @@ class RPMDBPackageSack(PackageSackBase):
def searchNevra(self, name=None, epoch=None, ver=None, rel=None, arch=None):
return self._search(name, epoch, ver, rel, arch)
+ def contains(self, name=None, arch=None, epoch=None, ver=None, rel=None, po=None):
+ """return if there are any packages in the sack that match the given NAEVR
+ or the NAEVR of the given po"""
+ if po:
+ name = po.name
+ arch = po.arch
+ epoch = po.epoch
+ ver = po.version
+ rel = po.release
+
+ if name and arch and epoch and ver and rel: # cheater lookup
+ if (name, arch, epoch, ver, rel) in self._tup2pkg:
+ return True
+
+ return bool(self.searchNevra(name=name, arch=arch, epoch=epoch, ver=ver, rel=rel))
+
def excludeArchs(self, archlist):
pass
More information about the Yum-cvs-commits
mailing list