On 12/21/2008 06:49 PM, Alexander 'Leo' Bergolth wrote: > On 12/20/2008 03:13 PM, seth vidal wrote: >> On Sat, 2008-12-20 at 01:22 +0100, Alexander 'Leo' Bergolth wrote: >>> I'm trying to do a distro-upgrade using yum. >>> >>> However I'm experiencing a problem replacing a package in the yum shell >>> transaction: >>> >>> I tried the following commands: >>> -------------------- 8< -------------------- >>> erase java-1.6.0-sun-compat jdk >>> install java-1.6.0-openjdk >>> upgrade >>> -------------------- 8< -------------------- >>> >>> But the upgrade command seems the place java-1.6.0-sun-compat in the >>> list of packages to upgrade again. Now it is found both in the list of >>> packages to update and remove! > [...] > If it's ok, maybe other commands like erase or install should also > modify potentially existing transaction set members? Here is my naive approach of removing existing transaction set entries when doing an install or erase. It works, at least for the common cases. I hope you'll find it useful... Cheers, --leo -- e-mail ::: Leo.Bergolth (at) wu-wien.ac.at fax ::: +43-1-31336-906050 location ::: Computer Center | Vienna University of Economics | Austria
--- yum/__init__.py.orig 2008-12-23 20:06:53.368318051 +0100 +++ yum/__init__.py 2008-12-23 20:08:26.985380508 +0100 @@ -2457,7 +2457,12 @@ po.name, obsoleting_pkg.name, obsoleting_pkg) self.install(po=obsoleting_pkg) continue - + + # naive handling of packages that are already in the transaction set + if not self.allowedMultipleInstalls(po): + for tsmember in self.tsInfo.matchNaevr(name = po.name): + self.tsInfo.remove(tsmember.pkgtup) + txmbr = self.tsInfo.addInstall(po) tx_return.append(txmbr) @@ -2703,10 +2708,11 @@ tx_return = [] pkgs = [] - + tspkgs = [] if po: pkgs = [po] + tspkgs = self.tsInfo.getMembers(po.pkgtup) else: if kwargs.has_key('pattern'): if kwargs['pattern'][0] == '@': @@ -2727,7 +2733,10 @@ self.logger.critical(_('No Match for argument: %s') % arg) else: pkgs.extend(depmatches) - + + (e,m,u) = self.tsInfo.matchPackageNames([kwargs['pattern']]) + tspkgs.extend(e) + tspkgs.extend(m) else: nevra_dict = self._nevra_kwarg_parse(kwargs) @@ -2739,6 +2748,14 @@ if not kwargs.get('silence_warnings', False): self.logger.warning(_("No package matched to remove")) + tspkgs = self.tsInfo.matchNaevr(name=nevra_dict['name'], + arch=nevra_dict['arch'], epoch=nevra_dict['epoch'], + ver=nevra_dict['version'], rel=nevra_dict['release']) + + # naive handling of packages that are already in the transaction set + for txmbr in tspkgs: + self.tsInfo.remove(txmbr.pkgtup) + for po in pkgs: txmbr = self.tsInfo.addErase(po) tx_return.append(txmbr) --- yum/transactioninfo.py.orig 2008-12-23 19:20:54.629318085 +0100 +++ yum/transactioninfo.py 2008-12-23 20:07:18.248317994 +0100 @@ -31,6 +31,9 @@ from sqlitesack import YumAvailablePackageSqlite import Errors import warnings +import re +import fnmatch +import misc class TransactionData: """Data Structure designed to hold information on a yum Transaction Set""" @@ -152,6 +155,45 @@ return result + def matchPackageNames(self, pkgspecs): + # Setup match() for the search we're doing + matched = [] + exactmatch = [] + unmatched = set(pkgspecs) + + specs = {} + for p in pkgspecs: + if misc.re_glob(p): + restring = fnmatch.translate(p) + specs[p] = re.compile(restring) + else: + specs[p] = p + + for txmbr in self.getMembers(): + pkgtup = txmbr.pkgtup + (n,a,e,v,r) = pkgtup + names = set(( + n, + '%s.%s' % (n, a), + '%s-%s-%s.%s' % (n, v, r, a), + '%s-%s' % (n, v), + '%s-%s-%s' % (n, v, r), + '%s:%s-%s-%s.%s' % (e, n, v, r, a), + '%s-%s:%s-%s.%s' % (n, e, v, r, a), + )) + + for (term,query) in specs.items(): + if term == query: + if query in names: + exactmatch.append(txmbr) + unmatched.discard(term) + else: + for n in names: + if query.match(n): + matched.append(txmbr) + unmatched.discard(term) + return misc.unique(exactmatch), misc.unique(matched), list(unmatched) + def _isLocalPackage(self, txmember): # Is this the right criteria? return txmember.ts_state in ('u', 'i') and not isinstance(txmember.po, (YumInstalledPackage, YumAvailablePackageSqlite))
_______________________________________________ Yum mailing list Yum@xxxxxxxxxxxxxxxxx http://lists.baseurl.org/mailman/listinfo/yum