From c1155ec45f2c4ee5732baa90c033d98b308be1bc Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Tue, 3 Jul 2007 18:24:19 +0000 Subject: [PATCH] Unify depgraph favorites handling with the other args handling. (trunk r7137:7140) svn path=/main/branches/2.1.2/; revision=7141 --- bin/emerge | 67 ++++++++++++++++++------------------------------------ 1 file changed, 22 insertions(+), 45 deletions(-) diff --git a/bin/emerge b/bin/emerge index 99bfbb4d8..a77004d2c 100755 --- a/bin/emerge +++ b/bin/emerge @@ -1450,8 +1450,7 @@ class depgraph: if not self.create(["binary", myroot, mykey], None, "--onlydeps" not in self.myopts): return (0,myfavorites) - elif not "--oneshot" in self.myopts: - myfavorites.append("="+mykey) + arg_atoms.append((x, "="+mykey)) elif ext==".ebuild": x = os.path.realpath(x) mykey=os.path.basename(os.path.normpath(x+"/../.."))+"/"+os.path.splitext(os.path.basename(x))[0] @@ -1473,8 +1472,7 @@ class depgraph: if not self.create(["ebuild", myroot, mykey], None, "--onlydeps" not in self.myopts): return (0,myfavorites) - elif not "--oneshot" in self.myopts: - myfavorites.append("="+mykey) + arg_atoms.append((x, "="+mykey)) else: if not is_valid_package_atom(x): portage.writemsg("\n\n!!! '%s' is not a valid package atom.\n" % x, @@ -1489,16 +1487,12 @@ class depgraph: settings=pkgsettings) if (mykey and not mykey.startswith("null/")) or \ "--usepkgonly" in self.myopts: - if "--oneshot" not in self.myopts: - myfavorites.append(mykey) arg_atoms.append((x, mykey)) continue mykey = portage.dep_expand(x, mydb=portdb, settings=pkgsettings) arg_atoms.append((x, mykey)) - if "--oneshot" not in self.myopts: - myfavorites.append(mykey) except ValueError, errpkgs: print "\n\n!!! The short ebuild name \"" + x + "\" is ambiguous. Please specify" print "!!! one of the following fully-qualified ebuild names instead:\n" @@ -1556,10 +1550,15 @@ class depgraph: greedy_atoms.append((myarg, myslot_atom)) arg_atoms = greedy_atoms + oneshot = "--oneshot" in self.myopts or "--onlydeps" in self.myopts """ These are used inside self.create() in order to ensure packages that happen to match arguments are not incorrectly marked as nomerge.""" for myarg, myatom in arg_atoms: + if myatom in self._args_atoms: + continue self._args_atoms.add(myatom) + if not oneshot: + myfavorites.append(myatom) for myarg, myatom in arg_atoms: try: self.mysd = self.select_dep(myroot, myatom, arg=myarg) @@ -3118,61 +3117,39 @@ class depgraph: if release.endswith('-r0'): release = release[:-3] - def saveNomergeFavorites(self, mergelist, favorites): + def saveNomergeFavorites(self): """Find atoms in favorites that are not in the mergelist and add them to the world file if necessary.""" - for x in ("--onlydeps", "--pretend", "--fetchonly", "--fetch-all-uri"): + for x in ("--fetchonly", "--fetch-all-uri", + "--oneshot", "--onlydeps", "--pretend"): if x in self.myopts: return - favorites_set = AtomSet(favorites) system_set = SystemSet(self.settings) world_set = WorldSet(self.settings) world_set.lock() world_set.load() - merge_atoms = set() - atom_pkgs = {} - for x in mergelist: - pkg_type = x[0] - if pkg_type not in self.pkg_tree_map: - continue + added_favorites = set() + for x in self._args_nodes: pkg_type, root, pkg_key, pkg_status = x - if root != self.target_root: + if pkg_status != "nomerge": continue metadata = dict(izip(self._mydbapi_keys, self.mydbapi[root].aux_get(pkg_key, self._mydbapi_keys))) try: - atom = favorites_set.findAtomForPackage(pkg_key, metadata) + if not (system_set.findAtomForPackage(pkg_key, metadata) or \ + world_set.findAtomForPackage(pkg_key, metadata)): + myfavkey = portage.cpv_getkey(pkg_key) + if myfavkey in added_favorites: + continue + added_favorites.add(myfavkey) + world_set.add(myfavkey) + print ">>> Recording",myfavkey,"in \"world\" favorites file..." except portage_exception.InvalidDependString, e: writemsg("\n\n!!! '%s' has invalid PROVIDE: %s\n" % \ (pkg_key, str(e)), noiselevel=-1) writemsg("!!! see '%s'\n\n" % os.path.join( root, portage.VDB_PATH, pkg_key, "PROVIDE"), noiselevel=-1) del e - if atom: - merge_atoms.add(atom) - added_favorites = set() - root = self.target_root - for atom in set(favorites_set).difference(merge_atoms): - pkgs = self.mydbapi[root].match(atom) - for pkg_key in pkgs: - metadata = dict(izip(self._mydbapi_keys, - self.mydbapi[root].aux_get(pkg_key, self._mydbapi_keys))) - try: - if not (system_set.findAtomForPackage(pkg_key, metadata) or \ - world_set.findAtomForPackage(pkg_key, metadata)): - myfavkey = portage.cpv_getkey(pkg_key) - if myfavkey in added_favorites: - continue - added_favorites.add(myfavkey) - world_set.add(myfavkey) - modified = True - print ">>> Recording",myfavkey,"in \"world\" favorites file..." - except portage_exception.InvalidDependString, e: - writemsg("\n\n!!! '%s' has invalid PROVIDE: %s\n" % \ - (pkg_key, str(e)), noiselevel=-1) - writemsg("!!! see '%s'\n\n" % os.path.join( - root, portage.VDB_PATH, pkg_key, "PROVIDE"), noiselevel=-1) - del e if added_favorites: world_set.save() world_set.unlock() @@ -5405,7 +5382,7 @@ def action_build(settings, trees, mtimedb, else: pkglist = mydepgraph.altlist() if favorites: - mydepgraph.saveNomergeFavorites(pkglist, favorites) + mydepgraph.saveNomergeFavorites() del mydepgraph mergetask = MergeTask(settings, trees, myopts) retval = mergetask.merge(pkglist, favorites, mtimedb) -- 2.26.2