[yum-commits] Branch 'yum-3_2_X' - 2 commits - yum/depsolve.py yum/history.py yum/__init__.py yum/misc.py yum/sqlitesack.py
James Antill
james at osuosl.org
Tue Sep 22 16:12:14 UTC 2009
yum/__init__.py | 5 +----
yum/depsolve.py | 2 +-
yum/history.py | 11 ++++++++---
yum/misc.py | 14 +++++++++++++-
yum/sqlitesack.py | 2 +-
5 files changed, 24 insertions(+), 10 deletions(-)
New commits:
commit 1eeae56337227d99020af5ae17a0d389590b899e
Author: James Antill <james at and.org>
Date: Tue Sep 22 11:47:06 2009 -0400
Don't traceback on TS_FAILED txmbrs comming out of the transaction
diff --git a/yum/history.py b/yum/history.py
index 9741d36..ea3a464 100644
--- a/yum/history.py
+++ b/yum/history.py
@@ -30,6 +30,9 @@ from yum.packages import YumInstalledPackage, YumAvailablePackage, PackageObject
_history_dir = '/var/lib/yum/history'
+# NOTE: That we don't list TS_FAILED, because pkgs shouldn't go into the
+# transaction with that. And if they come out with that we don't want to
+# match them to anything anyway.
_stcode2sttxt = {TS_UPDATE : 'Update',
TS_UPDATED : 'Updated',
TS_ERASE: 'Erase',
@@ -277,7 +280,7 @@ class YumHistory:
if txmbr.downgraded_by:
state = 'Downgraded'
if state is None:
- state = _stcode2sttxt[txmbr.output_state]
+ state = _stcode2sttxt.get(txmbr.output_state)
return state
def trans_with_pid(self, pid):
@@ -289,7 +292,8 @@ class YumHistory:
return cur.lastrowid
def trans_data_pid_beg(self, pid, state):
- if not hasattr(self, '_tid'):
+ assert state is not None
+ if not hasattr(self, '_tid') or state is None:
return # Not configured to run
cur = self._get_cursor()
res = executeSQL(cur,
@@ -298,7 +302,8 @@ class YumHistory:
VALUES (?, ?, ?)""", (self._tid, pid, state))
return cur.lastrowid
def trans_data_pid_end(self, pid, state):
- if not hasattr(self, '_tid'):
+ # State can be none here, Eg. TS_FAILED from rpmtrans
+ if not hasattr(self, '_tid') or state is None:
return # Not configured to run
cur = self._get_cursor()
commit 16c16593201cdc02a60c027094fc5e0424b0dced
Author: James Antill <james at and.org>
Date: Tue Sep 22 11:23:10 2009 -0400
Fix "yum install '[x/y]bin/zsh'". Also makes the code neater.
Because we need matching [], we can't just do a re_glob() of the first
char anymore. So we careate a new re_filename() function. This is also
clever enough that it doesn't match "[xy]bin/zsh", however negated
character classes and character class ranges are on their own (don't do
that).
Also add some doc comments to the re_* functions.
diff --git a/yum/__init__.py b/yum/__init__.py
index 90cdf8d..244f83f 100644
--- a/yum/__init__.py
+++ b/yum/__init__.py
@@ -2041,10 +2041,7 @@ class YumBase(depsolve.Depsolve):
canBeFile = True
else:
isglob = True
- if arg[0] != '/' and not misc.re_glob(arg[0]):
- canBeFile = False
- else:
- canBeFile = True
+ canBeFile = misc.re_filename(arg)
if not isglob:
usedDepString = True
diff --git a/yum/depsolve.py b/yum/depsolve.py
index 89adfda..c5baacb 100644
--- a/yum/depsolve.py
+++ b/yum/depsolve.py
@@ -174,7 +174,7 @@ class Depsolve(object):
for po in pkgs:
self.verbose_logger.log(logginglevels.DEBUG_2,
_('Potential match for %s from %s'), name, po)
- if (name[0] == '/' or misc.re_glob(name[0])) and r_v is None:
+ if misc.re_filename(name) and r_v is None:
# file dep add all matches to the defSack
defSack.addPackage(po)
continue
diff --git a/yum/misc.py b/yum/misc.py
index a092b65..17e5ef6 100644
--- a/yum/misc.py
+++ b/yum/misc.py
@@ -76,14 +76,25 @@ def unshare_data():
_re_compiled_glob_match = None
def re_glob(s):
""" Tests if a string is a shell wildcard. """
- # re.match('.*[\*\?\[\]].*', name)
global _re_compiled_glob_match
if _re_compiled_glob_match is None:
_re_compiled_glob_match = re.compile('.*([*?]|\[.+\])')
return _re_compiled_glob_match.match(s)
+_re_compiled_filename_match = None
+def re_filename(s):
+ """ Tests if a string could be a filename. We still get negated character
+ classes wrong (are they supported), and ranges in character classes. """
+ global _re_compiled_filename_match
+ if _re_compiled_filename_match is None:
+ _re_compiled_filename_match = re.compile('^(/|[*?]|\[[^]]*/[^]]*\])')
+ return _re_compiled_filename_match.match(s)
+
_re_compiled_pri_fnames_match = None
def re_primary_filename(filename):
+ """ Tests if a filename string, can be matched against just primary.
+ Note that this can produce false negatives (but not false
+ positives). """
global _re_compiled_pri_fnames_match
if _re_compiled_pri_fnames_match is None:
one = re.compile('.*bin\/.*')
@@ -97,6 +108,7 @@ def re_primary_filename(filename):
_re_compiled_pri_dnames_match = None
def re_primary_dirname(dirname):
+ """ Tests if a dirname string, can be matched against just primary. """
global _re_compiled_pri_dnames_match
if _re_compiled_pri_dnames_match is None:
one = re.compile('.*bin\/.*')
diff --git a/yum/sqlitesack.py b/yum/sqlitesack.py
index 3dd93a5..9bfcd93 100644
--- a/yum/sqlitesack.py
+++ b/yum/sqlitesack.py
@@ -1281,7 +1281,7 @@ class YumSqlitePackageSack(yumRepo.YumPackageSack):
# If it's not a provides or a filename, we are done
if prcotype != "provides":
return results
- if name[0] != '/' and (not glob or not misc.re_glob(name[0])):
+ if not misc.re_filename(name):
return results
# If it is a filename, search the primary.xml file info
More information about the Yum-commits
mailing list