def rebuild_use(self): if not self.options["quiet"]: print() print(" -- Scanning installed packages for USE flag settings that") print(" do not match the default settings") system_use = portage.settings["USE"].split() output = RebuildPrinter( "use", self.options["pretend"], self.options["exact"], self.options["slot"] ) pkgs, cp_counts = cpv_all_diff_use(system_flags=system_use) pkg_count = len(pkgs) if self.options["verbose"]: print() print( ( pp.emph(" -- Found ") + pp.number(str(pkg_count)) + pp.emph(" packages that need entries") ) ) # print pp.emph(" package.use to maintain their current setting") pkg_keys = [] if pkgs: pkg_keys = sorted(pkgs) # print len(pkgs) if self.options["pretend"] and not self.options["quiet"]: print() print( pp.globaloption( " -- These are the installed packages & use flags " + "that were detected" ) ) print( pp.globaloption( " to need use flag settings other " + "than the defaults." ) ) print() elif not self.options["quiet"]: print(" -- preparing pkgs for file entries") for pkg in pkg_keys: output(pkg, pkgs[pkg], cp_counts[pkg]) if self.options["verbose"]: message = ( pp.emph(" ") + pp.number(str(pkg_count)) + pp.emph(" different packages") ) print() print(pp.globaloption(" -- Totals")) print(message) # print # unique = list(unique_flags) # unique.sort() # print unique if not self.options["pretend"]: filepath = os.path.expanduser("~/package.use.test") self.save_file(filepath, output.lines)
def print_help(with_description=True): """Print description, usage and a detailed help message. @param with_description (bool): Option to print module's __doc__ or not """ if with_description: print(__doc__) print(main_usage()) print() print(pp.globaloption("global options")) print(format_options(( (" -h, --help", "display this help message"), (" -q, --quiet", "minimal output"), (" -C, --no-color", "turn off colors"), (" -N, --no-pipe", "turn off pipe detection"), (" -V, --version", "display version info") ))) print() print(pp.command("modules") + " (" + pp.command("short name") + ")") print(format_options(( (" (b)estkeywords", "display the best keywords for a given package"), (" (d)ependencies", "display the direct dependencies for a given package"), (" (m)askedkeywords", "display keywords for a given package converting to masked as unstable"), )))
def rebuild_use(self): if not self.options["quiet"]: print() print(" -- Scanning installed packages for USE flag settings that") print(" do not match the default settings") system_use = portage.settings["USE"].split() output = RebuildPrinter( "use", self.options["pretend"], self.options["exact"], self.options['slot']) pkgs, cp_counts = cpv_all_diff_use(system_flags=system_use) pkg_count = len(pkgs) if self.options["verbose"]: print() print((pp.emph(" -- Found ") + pp.number(str(pkg_count)) + pp.emph(" packages that need entries"))) #print pp.emph(" package.use to maintain their current setting") pkg_keys = [] if pkgs: pkg_keys = sorted(pkgs) #print len(pkgs) if self.options["pretend"] and not self.options["quiet"]: print() print(pp.globaloption( " -- These are the installed packages & use flags " + "that were detected")) print(pp.globaloption(" to need use flag settings other " + "than the defaults.")) print() elif not self.options["quiet"]: print(" -- preparing pkgs for file entries") for pkg in pkg_keys: output(pkg, pkgs[pkg], cp_counts[pkg]) if self.options['verbose']: message = (pp.emph(" ") + pp.number(str(pkg_count)) + pp.emph(" different packages")) print() print(pp.globaloption(" -- Totals")) print(message) #print #unique = list(unique_flags) #unique.sort() #print unique if not self.options["pretend"]: filepath = os.path.expanduser('~/package.use.test') self.save_file(filepath, output.lines)
def main_usage(module_info): """Return the main usage message for analyse""" return "%(usage)s %(product)s [%(g_opts)s] %(mod_name)s [%(mod_opts)s]" % { 'usage': pp.emph("Usage:"), 'product': pp.productname(module_info["__productname__"]), 'g_opts': pp.globaloption("global-options"), 'mod_name': pp.command("module-name"), 'mod_opts': pp.localoption("module-options") }
def print_pkg_quiet(self, cpv, flags): """Verbosely prints the pkg's use flag info.""" (plus, minus, unset) = flags _flags = [] for flag in plus: _flags.append(pp.useflag((flag), True)) for flag in minus: _flags.append(pp.useflag(("-" + flag), False)) for flag in unset: _flags.append(pp.globaloption("-" + flag)) print(self._format_values(cpv, ", ".join(_flags)))
def print_pkg_quiet(self, cpv, flags): """Verbosely prints the pkg's use flag info. """ (plus, minus, unset) = flags _flags = [] for flag in plus: _flags.append(pp.useflag((flag), True)) for flag in minus: _flags.append(pp.useflag(("-" + flag), False)) for flag in unset: _flags.append(pp.globaloption("-" + flag)) print(self._format_values(cpv, ", ".join(_flags)))
def print_help(module_info, formatted_options=None, with_description=True): """Print description, usage and a detailed help message. @param with_description (bool): Option to print module's __doc__ or not """ if with_description: print() print(module_info["__doc__"]) print() print(main_usage(module_info)) print() print(pp.globaloption("global options")) print(format_options(GLOBAL_OPTIONS)) print() if formatted_options: print(pp.command("modules") + " (" + pp.command("short name") + ")") print(format_options(formatted_options)) else: print("Error: calling function did not supply formatted options") print()
def print_help(with_description=True): """Print description, usage and a detailed help message. @param with_description (bool): Option to print module's __doc__ or not """ if with_description: print(__doc__) print(main_usage()) print() print(pp.globaloption("global options")) print( format_options( ((" -h, --help", "display this help message"), (" -q, --quiet", "minimal output"), (" -C, --no-color", "turn off colors"), (" -N, --no-pipe", "turn off pipe detection"), (" -V, --version", "display version info")))) print() print(pp.command("modules") + " (" + pp.command("short name") + ")") print( format_options(( (" (b)elongs", "list what package FILES belong to"), (" (c)hanges", "list changelog entries for ATOM"), (" chec(k)", "verify checksums and timestamps for PKG"), (" (d)epends", "list all packages directly depending on ATOM"), (" dep(g)raph", "display a tree of all dependencies for PKG"), (" (f)iles", "list all files installed by PKG"), (" h(a)s", "list all packages for matching ENVIRONMENT data stored in /var/db/pkg" ), (" (h)asuse", "list all packages that have USE flag"), (" ke(y)words", "display keywords for specified PKG"), (" (l)ist", "list package matching PKG"), (" (m)eta", "display metadata about PKG"), (" (s)ize", "display total size of all files owned by PKG"), (" (u)ses", "display USE flags for PKG"), (" (w)hich", "print full path to ebuild for PKG"))))
def print_help(with_description=True): """Print description, usage and a detailed help message. @param with_description (bool): Option to print module's __doc__ or not """ if with_description: print(__doc__) print(main_usage()) print() print(pp.globaloption("global options")) print(format_options(( (" -h, --help", "display this help message"), (" -q, --quiet", "minimal output"), (" -C, --no-color", "turn off colors"), (" -N, --no-pipe", "turn off pipe detection"), (" -V, --version", "display version info") ))) print() print(pp.command("modules") + " (" + pp.command("short name") + ")") print(format_options(( (" (b)elongs", "list what package FILES belong to"), (" (c)hanges", "list changelog entries for ATOM"), (" chec(k)", "verify checksums and timestamps for PKG"), (" (d)epends", "list all packages directly depending on ATOM"), (" dep(g)raph", "display a tree of all dependencies for PKG"), (" (f)iles", "list all files installed by PKG"), (" h(a)s", "list all packages for matching ENVIRONMENT data stored in /var/db/pkg"), (" (h)asuse", "list all packages that have USE flag"), (" ke(y)words", "display keywords for specified PKG"), (" (l)ist", "list package matching PKG"), (" (m)eta", "display metadata about PKG"), (" (s)ize", "display total size of all files owned by PKG"), (" (u)ses", "display USE flags for PKG"), (" (w)hich", "print full path to ebuild for PKG") )))
def rebuild_keywords(self): # print("Module action not yet available") # print() """This will scan the installed packages db and analyze the keywords used for installation and produce a report on them. """ system_keywords = portage.settings["ACCEPT_KEYWORDS"].split() output = RebuildPrinter( "keywords", self.options["pretend"], self.options["exact"], self.options["slot"], ) arch = portage.settings["ARCH"] if self.options["prefix"]: # build a new keyword for testing system_keywords = "~" + arch + "-linux" if self.options["verbose"] or self.options["prefix"]: print("Current system ARCH =", arch) print("Current system ACCEPT_KEYWORDS =", system_keywords) self.analyser = KeywordAnalyser( arch, system_keywords, portage.db[portage.root]["vartree"].dbapi ) # self.analyser.set_order(portage.settings["USE"].split()) # only for testing test_use = portage.settings["USE"].split() if self.options["prefix"] and "prefix" not in test_use: print( "REBUILD_KEYWORDS() 'prefix' flag not found in system", "USE flags!!! appending for testing", ) print() test_use.append("prefix") self.analyser.set_order(test_use) # /end testing cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all() # print "Total number of installed ebuilds =", len(cpvs) pkgs, cp_counts = cpv_all_diff_keywords( cpvs=cpvs, system_keywords=system_keywords, use_portage=self.options["portage"], analyser=self.analyser, ) # print([pkgs[p][0].cpv for p in pkgs]) pkg_keys = [] if pkgs: pkg_keys = sorted(pkgs) # print(len(pkgs)) if self.options["pretend"] and not self.options["quiet"]: print() print( pp.globaloption( " -- These are the installed packages & keywords " + "that were detected" ) ) print( pp.globaloption( " to need keyword settings other " + "than the defaults." ) ) print() elif not self.options["quiet"]: print(" -- preparing pkgs for file entries") for pkg in pkg_keys: output(pkg, pkgs[pkg], cp_counts[pkg]) if not self.options["quiet"]: if self.analyser.mismatched: print("_________________________________________________") print( ( "The following packages were found to have a \n" + "different recorded ARCH than the current system ARCH" ) ) for cpv in self.analyser.mismatched: print("\t", pp.cpv(cpv)) print("===================================================") print( "Total number of entries in report =", pp.output.red(str(len(pkg_keys))) ) if self.options["verbose"]: print( "Total number of installed ebuilds =", pp.output.red(str(len(cpvs))) ) print() if not self.options["pretend"]: filepath = os.path.expanduser("~/package.keywords.test") self.save_file(filepath, output.lines)
def rebuild_keywords(self): #print("Module action not yet available") #print() """This will scan the installed packages db and analyze the keywords used for installation and produce a report on them. """ system_keywords = portage.settings["ACCEPT_KEYWORDS"].split() output = RebuildPrinter( "keywords", self.options["pretend"], self.options["exact"], self.options['slot']) arch = portage.settings["ARCH"] if self.options["prefix"]: # build a new keyword for testing system_keywords = "~" + arch + "-linux" if self.options["verbose"] or self.options["prefix"]: print("Current system ARCH =", arch) print("Current system ACCEPT_KEYWORDS =", system_keywords) self.analyser = KeywordAnalyser( arch, system_keywords, portage.db[portage.root]["vartree"].dbapi) #self.analyser.set_order(portage.settings["USE"].split()) # only for testing test_use = portage.settings["USE"].split() if self.options['prefix'] and 'prefix' not in test_use: print("REBUILD_KEYWORDS() 'prefix' flag not found in system", "USE flags!!! appending for testing") print() test_use.append('prefix') self.analyser.set_order(test_use) # /end testing cpvs = portage.db[portage.root]["vartree"].dbapi.cpv_all() #print "Total number of installed ebuilds =", len(cpvs) pkgs, cp_counts = cpv_all_diff_keywords( cpvs=cpvs, system_keywords=system_keywords, use_portage=self.options['portage'], analyser = self.analyser ) #print([pkgs[p][0].cpv for p in pkgs]) pkg_keys = [] if pkgs: pkg_keys = sorted(pkgs) #print(len(pkgs)) if self.options["pretend"] and not self.options["quiet"]: print() print(pp.globaloption( " -- These are the installed packages & keywords " + "that were detected")) print(pp.globaloption(" to need keyword settings other " + "than the defaults.")) print() elif not self.options["quiet"]: print(" -- preparing pkgs for file entries") for pkg in pkg_keys: output(pkg, pkgs[pkg], cp_counts[pkg]) if not self.options['quiet']: if self.analyser.mismatched: print("_________________________________________________") print(("The following packages were found to have a \n" + "different recorded ARCH than the current system ARCH")) for cpv in self.analyser.mismatched: print("\t", pp.cpv(cpv)) print("===================================================") print("Total number of entries in report =", pp.output.red(str(len(pkg_keys)))) if self.options["verbose"]: print("Total number of installed ebuilds =", pp.output.red(str(len(cpvs)))) print() if not self.options["pretend"]: filepath = os.path.expanduser('~/package.keywords.test') self.save_file(filepath, output.lines)