# Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 import logging from portage.util import writemsg_level def create_depgraph_params(myopts, myaction): #configure emerge engine parameters # # self: include _this_ package regardless of if it is merged. # selective: exclude the package if it is merged # recurse: go into the dependencies # deep: go into the dependencies of already merged packages # empty: pretend nothing is merged # complete: completely account for all known dependencies # remove: build graph for use in removing packages # rebuilt_binaries: replace installed packages with rebuilt binaries myparams = {"recurse" : True} bdeps = myopts.get("--with-bdeps") if bdeps is not None: myparams["bdeps"] = bdeps if myaction == "remove": myparams["remove"] = True myparams["complete"] = True myparams["selective"] = True return myparams if "--update" in myopts or \ "--newuse" in myopts or \ "--reinstall" in myopts or \ "--noreplace" in myopts or \ myopts.get("--selective", "n") != "n": myparams["selective"] = True deep = myopts.get("--deep") if deep is not None and deep != 0: myparams["deep"] = deep if ("--complete-graph" in myopts or "--rebuild-if-new-rev" in myopts or "--rebuild-if-new-ver" in myopts or "--rebuild-if-unbuilt" in myopts): myparams["complete"] = True if "--emptytree" in myopts: myparams["empty"] = True myparams["deep"] = True myparams.pop("selective", None) if "--nodeps" in myopts: myparams.pop("recurse", None) myparams.pop("deep", None) myparams.pop("complete", None) rebuilt_binaries = myopts.get('--rebuilt-binaries') if rebuilt_binaries is True or \ rebuilt_binaries != 'n' and \ '--usepkgonly' in myopts and \ myopts.get('--deep') is True and \ '--update' in myopts: myparams['rebuilt_binaries'] = True if myopts.get("--selective") == "n": # --selective=n can be used to remove selective # behavior that may have been implied by some # other option like --update. myparams.pop("selective", None) if '--debug' in myopts: writemsg_level('\n\nmyparams %s\n\n' % myparams, noiselevel=-1, level=logging.DEBUG) return myparams