From acdf616efa73b77936963eaa8b5c715db97646d2 Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Tue, 8 Dec 2009 21:53:45 +0000 Subject: [PATCH] Merge rev 113 from djanderson's genscripts repo svn path=/trunk/gentoolkit/; revision=703 --- AUTHORS | 8 +- CREDITS | 16 + ChangeLog | 3 + MANIFEST.in | 11 +- README.dev | 25 + TODO | 39 +- bin/eclean | 30 +- bin/epkginfo | 4 +- bin/equery | 20 +- bin/euse | 84 +-- bin/revdep-rebuild | 7 + man/equery.1 | 759 ++++++++++++++------- pylintrc | 320 +++++++++ pym/gentoolkit/__init__.py | 43 +- pym/gentoolkit/atom.py | 195 ++++++ pym/gentoolkit/cpv.py | 144 ++++ pym/gentoolkit/dbapi.py | 17 + pym/gentoolkit/dependencies.py | 317 +++++++++ pym/gentoolkit/deprecated/helpers.py | 179 +++++ pym/gentoolkit/equery/__init__.py | 153 ++--- pym/gentoolkit/equery/belongs.py | 132 ++-- pym/gentoolkit/equery/changes.py | 236 ++----- pym/gentoolkit/equery/check.py | 323 +++++---- pym/gentoolkit/equery/depends.py | 242 +++---- pym/gentoolkit/equery/depgraph.py | 198 +++--- pym/gentoolkit/equery/files.py | 90 +-- pym/gentoolkit/equery/hasuse.py | 78 ++- pym/gentoolkit/equery/list_.py | 89 ++- pym/gentoolkit/equery/meta.py | 505 ++++++-------- pym/gentoolkit/equery/size.py | 70 +- pym/gentoolkit/equery/uses.py | 145 ++-- pym/gentoolkit/equery/which.py | 14 +- pym/gentoolkit/errors.py | 110 ++-- pym/gentoolkit/glsa/__init__.py | 144 ++-- pym/gentoolkit/helpers.py | 843 ++++++++++++++++++++---- pym/gentoolkit/metadata.py | 303 +++++++++ pym/gentoolkit/package.py | 666 ++++++++----------- pym/gentoolkit/pprinter.py | 181 ++--- pym/gentoolkit/test/__init__.py | 6 + pym/gentoolkit/test/equery/__init__.py | 6 + pym/gentoolkit/test/equery/test_init.py | 52 ++ pym/gentoolkit/test/test_helpers.py | 107 +++ pym/gentoolkit/test/test_syntax.py | 31 + pym/gentoolkit/textwrap_.py | 108 +-- pym/gentoolkit/versionmatch.py | 146 ++-- setup.py | 126 +++- 46 files changed, 4794 insertions(+), 2531 deletions(-) create mode 100644 CREDITS create mode 100644 README.dev create mode 100644 pylintrc create mode 100644 pym/gentoolkit/atom.py create mode 100644 pym/gentoolkit/cpv.py create mode 100644 pym/gentoolkit/dbapi.py create mode 100644 pym/gentoolkit/dependencies.py create mode 100644 pym/gentoolkit/deprecated/helpers.py create mode 100644 pym/gentoolkit/metadata.py create mode 100644 pym/gentoolkit/test/__init__.py create mode 100644 pym/gentoolkit/test/equery/__init__.py create mode 100644 pym/gentoolkit/test/equery/test_init.py create mode 100644 pym/gentoolkit/test/test_helpers.py create mode 100644 pym/gentoolkit/test/test_syntax.py diff --git a/AUTHORS b/AUTHORS index fa210a6..5b074e6 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,19 +1,19 @@ * gentoolkit Original author: Karl Trygve Kalleberg - Further additions: Douglas Anderson + Library additions and refactor: Douglas Anderson Current maintainer: Paul Varner * eclean Original author: Thomas de Grenier de Latour (tgl) - + * epkginfo Author: Ned Ludd earch: Eldad Zack - metadata: Olinger + metadata: Olinger * equery Original author: Karl Trygve Kalleberg - Modular redesign: Douglas Anderson + Modular redesign: Douglas Anderson * eread Original author: Donnie Berkholz diff --git a/CREDITS b/CREDITS new file mode 100644 index 0000000..3f9d6f0 --- /dev/null +++ b/CREDITS @@ -0,0 +1,16 @@ + + This is an incomplete list of people who have contributed non- + trivial patches to gentoolkit-0.3.0 and later, in the spirit of + the Linux kernel CREDITS file. It is sorted alphabetically by + name (N). Other fields are email (E) and description (D). + We'd like to thank: + +------------------------------------------------------------------------------- + +N: Brian Dolbec +E: dol-sen@users.sourceforge.net +D: Separating dependency gathering functionality from output in depends.py. + + + +# vim: set ts=8 sw=8 tw=80: diff --git a/ChangeLog b/ChangeLog index b5b0442..7d421a3 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2009-12-08: Paul Varner + * gentoolkit: Merge rev 113 from djanderson's genscripts repo + 2009-10-30: Christian Ruppert * revdep-rebuild: Speedup portageq queries. Include FuzzyRay's patch to respect EMERGE_DEFAULT_OPTS. diff --git a/MANIFEST.in b/MANIFEST.in index 9bb143e..35297eb 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,3 +1,12 @@ -include AUTHORS ChangeLog COPYING NEWS README README.Developer THANKS TODO VERSION +include AUTHORS +include ChangeLog +include COPYING +include CREDITS +include NEWS +include README +include TODO +include setup.py recursive-include data * +recursive-include bin * recursive-include man * +recursive-include pym *.py *.txt diff --git a/README.dev b/README.dev new file mode 100644 index 0000000..7a33d1c --- /dev/null +++ b/README.dev @@ -0,0 +1,25 @@ +Adding or modifying code: +========================= +- If you add new code, best practice is to write a test for it. +- If you're modifying code that doesn't have a test and you can write a test + for it, please do. +- Before committing your changes to a python file, please make sure it passes + pylint with: +pylint --rcfile=pylintrc yourfile.py +- If pylint raises a warning or error that you don't agree with, it's probably + better to just change your code. If you're sure you have a good reason for + doing what you're doing, you can add an exception to our pylintrc. + +Creating a release: +=================== +- Run Gentoolkit's test suite, make sure it passes: +./setup.py test +- Create a tag for the release +- Set the version of the release: +VERSION="0.3.0" ./setup set_version +- Create a source distribution (you need to add VERSION here, too): +VERSION="0.3.0" ./setup.py sdist +- Reset svn version to 'svn' (default): +./setup.py set_version +- Clean up temporary files: +./setup clean -a diff --git a/TODO b/TODO index d39ea85..04cfbf3 100644 --- a/TODO +++ b/TODO @@ -2,16 +2,8 @@ - add --overlay, --portdir to uses - add glsa pkgspec - query for current GLSAs on installed package(s) - - add changelog [--last] [--lastentry] [--current] - - displays changelog entries - - add check [--full] [--display=pkgnames,full] - - check md5 and timestamps (optionally also in CONFIG_PROTECT dirs) - - add which - - as ewhich -- fully deprecate dep-clean and pkg-clean - rewrite ekeywords and echangelog to use gentoolkit -- add deep depends to equery -- fully deprecate qpkg +- fully deprecate qpkg - fully deprecate pkg-size - merge change and echangelog - merge useflag and euse, have _one_ command line tool @@ -20,9 +12,6 @@ - merge generate-use and ufed? - rewrite revdep-rebuild to use gentoolkit - drop qpkg dependency; use equery instead -- rewrite distfiles-clean to use gentoolkit -- look through forums.gentoo.org for additional scripts -- write a Gentoolkit Guide - write efeatures for turning on/off FEATURES in make.conf - look at ekeys, ewatch - revision bump tool @@ -30,11 +19,23 @@ - -m for changelog entry - use ~/.gentoo/gentoolkit/ebump.conf - use /etc/gentoolkit/ebump.conf -- should be removed: - - etc-update - - epm - - useflag -- add 'clean' target -+ check esearch, eupdatedb: separate package for now - +equery: + Tests: + +helpers2 (FileOwner._extend_realpaths test probably doesn't clean up) + Run pylint and write test to run pylint + Write test to compile all modules (full syntax check). Take from portage. + Add more --debug stuff + Write tests for Dependencies._parser + Refactor each module to be useful for import. Done modules: + +depends + +belongs + +meta + +changes + +depgraph + +For Next Release: + - allow passing VERSION='123' in front of setup.py sdist and do version + mangling at dist creation time. + - find all commits to main gentoolkit svn after rc7 push and merge where + appropriate diff --git a/bin/eclean b/bin/eclean index 9953fa7..6fee381 100755 --- a/bin/eclean +++ b/bin/eclean @@ -9,7 +9,7 @@ from __future__ import with_statement # Meta: __author__ = "Thomas de Grenier de Latour (tgl)" __email__ = "degrenier@easyconnect.fr" -__version__ = open('/usr/share/gentoolkit/VERSION').read().strip() +__version__ = "svn" __productname__ = "eclean" __description__ = "A cleaning tool for Gentoo distfiles and binaries." @@ -206,14 +206,14 @@ def prettySize(size,justify=False): size = size / 1024. units.pop() sizestr = fpformat.fix(size,approx)+units[-1] - if justify: + if justify: sizestr = " " + blue("[ ") + " "*(7-len(sizestr)) \ + green(sizestr) + blue(" ]") return sizestr ############################################################################### -# yesNoAllPrompt: print a prompt until user answer in yes/no/all. Return a +# yesNoAllPrompt: print a prompt until user answer in yes/no/all. Return a # boolean for answer, and also may affect the 'accept_all' option. # Note: i gave up with getch-like functions, to much bugs in case of escape # sequences. Back to raw_input. @@ -259,8 +259,8 @@ def parseSize(size): ############################################################################### -# parseTime: convert a duration "Xu" ("X" is an int, and "u" a time unit in -# [Y,M,W,D,H]) into an integer which is a past EPOCH date. +# parseTime: convert a duration "Xu" ("X" is an int, and "u" a time unit in +# [Y,M,W,D,H]) into an integer which is a past EPOCH date. # Raises ParseArgsException('time') in case of failure. # (yep, big approximations inside... who cares?) def parseTime(timespec): @@ -287,7 +287,7 @@ def parseTime(timespec): # dict. def parseArgs(myoptions={}): - # local function for interpreting command line options + # local function for interpreting command line options # and setting myoptions accordingly def optionSwitch(myoption,opts,action=None): return_code = True @@ -323,7 +323,7 @@ def parseArgs(myoptions={}): # sanity check of --destructive only options: for myopt in ('fetch-restricted', 'package-names'): if (not myoptions['destructive']) and myoptions[myopt]: - if not myoptions['quiet']: + if not myoptions['quiet']: eerror("--%s only makes sense in --destructive mode." \ % myopt, myoptions['nocolor']) myoptions[myopt] = False @@ -429,14 +429,14 @@ def parseExcludeFile(filepath): filecontents = file.readlines() file.close() cat_re = re.compile('^(?P[a-zA-Z0-9]+-[a-zA-Z0-9]+)(/\*)?$') - cp_re = re.compile('^(?P[-a-zA-Z0-9_]+/[-a-zA-Z0-9_]+)$') + cp_re = re.compile('^(?P[-a-zA-Z0-9_]+/[-a-zA-Z0-9_]+)$') for line in filecontents: line = line.strip() if not len(line): continue if line[0] == '#': continue try: mycat = cat_re.match(line).group('cat') except: pass - else: + else: if not mycat in portage.settings.categories: raise ParseExcludeFileException("Invalid category: "+mycat) excl_dict['categories'][mycat] = None @@ -604,7 +604,7 @@ def findPackages( \ package_names=False): clean_dict = {} # create a full package dictionary - + if not (os.path.isdir(pkgdir)): eerror("%s does not appear to be a directory." % pkgdir, myoptions['nocolor']) eerror("Please set PKGDIR to a sane value.", myoptions['nocolor']) @@ -687,7 +687,7 @@ def doCleanup(clean_dict,action,myoptions): or yesNoAllPrompt(myoptions, \ "Do you want to delete this " \ + file_type+"?"): - # non-interactive mode or positive answer. + # non-interactive mode or positive answer. # For each file, try to delete the file and clean it out # of Packages metadata file if action == 'packages': @@ -713,7 +713,7 @@ def doCleanup(clean_dict,action,myoptions): clean_size += filesize if action == 'packages': metadata.packages[:] = [p for p in metadata.packages if 'CPV' in p and p['CPV'] != file] - + if action == 'packages': with open(os.path.join(pkgdir, 'Packages'), 'w') as metadata_file: metadata.write(metadata_file) @@ -740,7 +740,7 @@ def doAction(action,myoptions,exclude_dict={}): destructive=myoptions['destructive'], \ package_names=myoptions['package-names'], \ time_limit=myoptions['time-limit']) - else: + else: clean_dict = findDistfiles( \ myoptions, \ exclude_dict=exclude_dict, \ @@ -796,7 +796,7 @@ def main(): elif e.value == 'version': printVersion() sys.exit(0) - else: + else: printUsage(e.value) sys.exit(2) # parse the exclusion file @@ -811,7 +811,7 @@ def main(): eerror("Invalid exclusion file: %s" % myoptions['exclude-file'], \ myoptions['nocolor']) eerror("See format of this file in `man %s`" % __productname__, \ - myoptions['nocolor']) + myoptions['nocolor']) sys.exit(1) else: exclude_dict={} # security check for non-pretend mode diff --git a/bin/epkginfo b/bin/epkginfo index 747527a..a335403 100755 --- a/bin/epkginfo +++ b/bin/epkginfo @@ -19,7 +19,7 @@ from xml.sax.handler import feature_namespaces import portage from portage.output import * -version = open('/usr/share/gentoolkit/VERSION').read().strip() +__version__ = "svn" def earch(workdir): """Prints arch keywords for a given dir""" @@ -177,7 +177,7 @@ def check_metadata(full_package): def usage(code): """Prints the uage information for this script""" - print green("epkginfo"), "(%s)" % version + print green("epkginfo"), "(%s)" % __version__ print print "Usage: epkginfo [package-cat/]package" sys.exit(code) diff --git a/bin/equery b/bin/equery index bac8a3a..e7bb6ce 100755 --- a/bin/equery +++ b/bin/equery @@ -2,9 +2,11 @@ # # Copyright 2002-2009 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License v2 or later +# +# $Header$ -"""equery is a flexible utility for Gentoo linux which can display various -information about packages, such as the files they own, their USE flags, +"""equery is a flexible utility for Gentoo linux which can display various +information about packages, such as the files they own, their USE flags, the MD5 sum of each file owned by a given package, and many other things. """ @@ -27,6 +29,16 @@ except KeyboardInterrupt: print sys.exit(1) -from gentoolkit import equery +from gentoolkit import equery, errors -equery.main() +try: + equery.main() +except errors.GentoolkitException, err: + if '--debug' in sys.argv: + raise + else: + from gentoolkit import pprinter as pp + sys.stderr.write(pp.error(str(err))) + print + print "Add '--debug' to global options for traceback." + sys.exit(1) diff --git a/bin/euse b/bin/euse index ca9835e..5950888 100755 --- a/bin/euse +++ b/bin/euse @@ -7,7 +7,7 @@ # Licensed under the GPL v2 PROGRAM_NAME=euse -PROGRAM_VERSION=$(cat /usr/share/gentoolkit/VERSION) +VERSION="svn" MAKE_CONF_PATH=/etc/make.conf MAKE_GLOBALS_PATH=/etc/make.globals @@ -67,9 +67,9 @@ check_sanity() { # file permission tests local descdir local make_defaults - + descdir="$(get_portdir)/profiles" - + [ ! -r "${MAKE_CONF_PATH}" ] && error "${MAKE_CONF_PATH} is not readable" [ ! -r "${MAKE_GLOBALS_PATH}" ] && error "${MAKE_GLOBALS_PATH} is not readable" [ ! -h "${MAKE_PROFILE_PATH}" ] && error "${MAKE_PROFILE_PATH} is not a symlink" @@ -86,7 +86,7 @@ check_sanity() { showhelp() { cat << HELP -${PROGRAM_NAME} (${PROGRAM_VERSION}) +${PROGRAM_NAME} (${VERSION}) Syntax: ${PROGRAM_NAME}