diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-09-22 22:17:24 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-09-22 22:17:24 +0000 |
commit | 8f072533eba97f6135a6223285752741685ba66f (patch) | |
tree | b4612b678dcc6e8cf361e3d40236f22ee7da1fed /src | |
parent | c2353e78958419abcc490b619e2f11f450984318 (diff) | |
download | bcfg2-8f072533eba97f6135a6223285752741685ba66f.tar.gz bcfg2-8f072533eba97f6135a6223285752741685ba66f.tar.bz2 bcfg2-8f072533eba97f6135a6223285752741685ba66f.zip |
Packages: make package alternatives work properly when specified (Resolves Ticket #738)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5449 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Server/Plugins/Packages.py | 65 |
1 files changed, 48 insertions, 17 deletions
diff --git a/src/lib/Server/Plugins/Packages.py b/src/lib/Server/Plugins/Packages.py index a4ce88ae2..68eddbb62 100644 --- a/src/lib/Server/Plugins/Packages.py +++ b/src/lib/Server/Plugins/Packages.py @@ -133,33 +133,64 @@ class Source(object): while work: item = work.pop() seen.add(item) - if self.is_package(metadata, item): + item_is_pkg = self.is_package(metadata, item) + try: + pset = self.get_provides(metadata, item) + item_is_virt = True + except NoData: + item_is_virt = False + + if item_is_pkg and not item_is_virt: newpkg.add(item) try: - newdeps = [x for x in self.get_deps(metadata, item) \ - if x not in newpkg and x not in work] + newdeps = set(self.get_deps(metadata, item)) if debug and newdeps: logger.debug("Package %s: adding new deps %s" \ %(item, str(newdeps))) - work.update(newdeps) + work.update(newdeps.difference(newpkg)) except NoData: continue else: - # provides dep - try: - pset = self.get_provides(metadata, item) + # item_is_virt + if item_is_pkg: + pset.add(item) + if debug: + logger.debug("Package(s) %s provide(s) %s" \ + % (list(pset), item)) + + if len(pset) == 1: if debug: - logger.debug("Package(s) %s provide(s) %s" \ - % (list(pset), item)) - if len(pset) == 1: - work.update(pset) + logger.debug("Using package %s for requirement %s" \ + % (list(pset)[0], item)) + work.update(pset.difference(newpkg)) + else: + if True in [p in newpkg for p in pset]: + # dep satisfied + try: + newdeps = set(self.get_deps(metadata, item)) + if debug and newdeps: + logger.debug("Package %s: adding new deps %s" \ + %(item, str(newdeps))) + work.update(newdeps.difference(newpkg)) + except NoData: + pass + elif item_is_pkg: + # add this pkg as a default action + if debug: + logger.debug("Adding Package %s" % item) + newpkg.add(item) + try: + newdeps = set(self.get_deps(metadata, item)) + if debug and newdeps: + logger.debug("Package %s: adding new deps %s" \ + %(item, str(newdeps))) + work.update(newdeps.difference(newpkg)) + except NoData: + pass else: - if True not in [p in newpkg for p in pset]: - # FIXME: still hacky; unchosen multiple provides still not handled - unknown.add(item) - except NoData: - unknown.add(item) - work = work.difference(seen) + # dep unsatisfied + # FIXME: hacky; multiple provides still not handled + unknown.add(item) return (newpkg, unknown) class YUMSource(Source): |