[yum-git] 2 commits - docs/yum.conf.5 yum/config.py yum/sqlitesack.py
James Antill
james at linux.duke.edu
Tue Jan 22 14:31:52 UTC 2008
docs/yum.conf.5 | 2 +-
yum/config.py | 41 +++++++++++++++++++++++++++++++++++------
yum/sqlitesack.py | 51 ++++++++++++++++++++++++++++++++++++++++++---------
3 files changed, 78 insertions(+), 16 deletions(-)
New commits:
commit 5ab94b2528440200e271f5dd582354cf5fc34671
Author: James Antill <james at and.org>
Date: Tue Jan 22 09:19:56 2008 -0500
Fix speed problem with having src repos enabled
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 9209d52..aa23a21 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -227,6 +227,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
self.otherdb = {}
self.excludes = {}
self._excludes = set() # of (repo, pkgKey)
+ self._all_excludes = {}
self._search_cache = {
'provides' : { },
'requires' : { },
@@ -235,6 +236,15 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
@catchSqliteException
def __len__(self):
+ # First check if everything is excluded
+ all_excluded = True
+ for (repo, cache) in self.primarydb.items():
+ if repo not in self._all_excludes:
+ all_excluded = False
+ break
+ if all_excluded:
+ return 0
+
exclude_num = 0
for repo in self.excludes:
exclude_num += len(self.excludes[repo])
@@ -256,6 +266,8 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
self.filelistsdb = {}
self.otherdb = {}
self.excludes = {}
+ self._excludes = set()
+ self._all_excludes = {}
self._search_cache = {
'provides' : { },
'requires' : { },
@@ -282,18 +294,27 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
self.excludes[obj.repo][obj.pkgId] = 1
self._excludes.add( (obj.repo, obj.pkgKey) )
+ def _delAllPackages(self, repo):
+ """ Exclude all packages from the repo. """
+ self._all_excludes[repo] = True
+
def _excluded(self, repo, pkgId):
- if self.excludes.has_key(repo):
- if self.excludes[repo].has_key(pkgId):
- return True
+ if repo in self._all_excludes:
+ return True
+
+ if repo in self.excludes and pkgId in self.excludes[repo]:
+ return True
return False
def _pkgKeyExcluded(self, repo, pkgKey):
+ if repo in self._all_excludes:
+ return True
+
return (repo, pkgKey) in self._excludes
def _pkgExcluded(self, po):
- return (po.repo, po.pkgKey) in self._excludes
+ return self._pkgKeyExcluded(po.repo, po.pkgKey)
def _packageByKey(self, repo, pkgKey):
if not self._key2pkg.has_key(repo):
@@ -876,16 +897,28 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
def excludeArchs(self, archlist):
"""excludes incompatible arches - archlist is a list of compat arches"""
- archlist = map(lambda x: "'%s'" % x , archlist)
- arch_query = ",".join(archlist)
- arch_query = '(%s)' % arch_query
+ sarchlist = map(lambda x: "'%s'" % x , archlist)
+ arch_query = ",".join(sarchlist)
for (rep, cache) in self.primarydb.items():
cur = cache.cursor()
- myq = "select pkgId, pkgKey from packages where arch not in %s" % arch_query
+
+ # First of all, make sure this isn't a *-source repo or something
+ # where we'll be excluding everything.
+ has_arch = False
+ executeSQL(cur, "SELECT DISTINCT arch FROM packages")
+ for row in cur:
+ if row[0] in archlist:
+ has_arch = True
+ break
+ if not has_arch:
+ self._delAllPackages(rep)
+ return
+
+ myq = "select pkgId, pkgKey from packages where arch not in (%s)" % arch_query
executeSQL(cur, myq)
for row in cur:
- obj = self.pc(rep,row)
+ obj = self.pc(rep, row)
self.delPackage(obj)
# Simple helper functions
commit b31133149f5b25e0fb01d6bfa07f4d6f699c9142
Author: James Antill <james at and.org>
Date: Fri Jan 18 16:59:44 2008 -0500
Add ranges to IntOption.
Add PositiveIntOption, with names.
diff --git a/docs/yum.conf.5 b/docs/yum.conf.5
index 54bd720..fb68841 100644
--- a/docs/yum.conf.5
+++ b/docs/yum.conf.5
@@ -160,7 +160,7 @@ Used by the \fBlist recent\fR command. Default is `7'.
.IP \fBretries\fR
Set the number of times any attempt to retrieve a file should retry before
-returning an error. Setting this to `0' makes yum try forever. Default is `6'.
+returning an error. Setting this to `0' makes yum try forever. Default is `10'.
.IP \fBkeepalive \fR
Either `0' or `1'. Set whether HTTP keepalive should be used for HTTP/1.1
diff --git a/yum/config.py b/yum/config.py
index 6923946..0ee6c35 100644
--- a/yum/config.py
+++ b/yum/config.py
@@ -223,11 +223,36 @@ class IntOption(Option):
An option representing an integer value.
"""
+ def __init__(self, default=None, range_min=None, range_max=None):
+ super(IntOption, self).__init__(default)
+ self._range_min = range_min
+ self._range_max = range_max
+
def parse(self, s):
try:
- return int(s)
+ val = int(s)
except (ValueError, TypeError), e:
raise ValueError('invalid integer value')
+ if val > range_max or val < range_min:
+ raise ValueError('out of range integer value')
+ return val
+
+class PositiveIntOption(IntOption):
+
+ """
+ An option representing a positive integer value, where 0 can have a special
+ represention.
+ """
+
+ def __init__(self, default=None, range_min=0, range_max=None,
+ names_of_0=None):
+ super(PositiveIntOption, self).__init__(default, range_min, range_max)
+ self._names0 = names_of_0
+
+ def parse(self, s):
+ if s in self._names0:
+ return 0
+ return super(PositiveIntOption, self).parse(s)
class SecondsOption(Option):
@@ -526,8 +551,8 @@ class StartupConf(BaseConfig):
required early in the initialisation process or before the other [main]
options can be parsed.
'''
- debuglevel = IntOption(2)
- errorlevel = IntOption(2)
+ debuglevel = IntOption(2, 0, 10)
+ errorlevel = IntOption(2, 0, 10)
distroverpkg = Option('redhat-release')
installroot = Option('/')
@@ -542,8 +567,8 @@ class YumConf(StartupConf):
Note: see also options inherited from StartupConf
'''
- retries = IntOption(10)
- recent = IntOption(7)
+ retries = PositiveIntOption(10, names_of_0=["<forever>"])
+ recent = IntOption(7, range_min=0)
cachedir = Option('/var/cache/yum')
persistdir = Option('/var/lib/yum')
@@ -564,7 +589,11 @@ class YumConf(StartupConf):
'kernel-enterprise','kernel-smp', 'kernel-modules', 'kernel-debug',
'kernel-unsupported', 'kernel-source', 'kernel-devel', 'kernel-PAE',
'kernel-PAE-debug'])
- installonly_limit = IntOption(0)
+ # NOTE: If you set this to 2, then because it keeps the current kernel it
+ # means if you ever install an "old" kernel it'll get rid of the newest one
+ # so you probably want to use 3 as a minimum ... if you turn it on.
+ installonly_limit = PositiveIntOption(0, range_min=2,
+ names_of_0=[0, "<off>"])
kernelpkgnames = ListOption(['kernel','kernel-smp', 'kernel-enterprise',
'kernel-bigmem', 'kernel-BOOT', 'kernel-PAE', 'kernel-PAE-debug'])
exactarchlist = ListOption(['kernel', 'kernel-smp', 'glibc',
More information about the Yum-cvs-commits
mailing list