From 232d69fa230abb490e0b0f8eef550f28745be6a3 Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Mon, 22 Jun 2009 20:45:49 +0000 Subject: Fix traceback with glsa-check -f (Bug 275105) svn path=/trunk/gentoolkit/; revision=665 --- ChangeLog | 3 +++ bin/glsa-check | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index d20fca5..6ccaa47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2009-06-22: Paul Varner + * glsa-check: Fix traceback with glsa-check -f (Bug 275105) + 2009-06-05: Paul Varner * epkginfo: Add patch from Sebastian Mingramm to Make epkginfo slot aware and only print keywords for the highest visible versions in each diff --git a/bin/glsa-check b/bin/glsa-check index c24ef23..a66371c 100755 --- a/bin/glsa-check +++ b/bin/glsa-check @@ -287,8 +287,8 @@ if mode in ["dump", "fix", "inject", "pretend"]: exitcode >>= 8 if exitcode: sys.exit(exitcode) - if len(mergelist): - sys.stdout.write("\n") + if len(mergelist): + sys.stdout.write("\n") elif mode == "pretend": sys.stdout.write("Checking GLSA "+myid+"\n") if not myglsa.isVulnerable(): -- cgit v1.2.3 From 72ba7b1274faf37451b1641ee51140f53f4b7098 Mon Sep 17 00:00:00 2001 From: rbu Date: Tue, 18 Aug 2009 17:47:20 +0000 Subject: Make --pretend output in glsa-check nicer. Add colors and fix linebreaks. svn path=/trunk/gentoolkit/; revision=670 --- bin/glsa-check | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/bin/glsa-check b/bin/glsa-check index a66371c..9f2e344 100755 --- a/bin/glsa-check +++ b/bin/glsa-check @@ -298,13 +298,22 @@ if mode in ["dump", "fix", "inject", "pretend"]: for (vuln, update) in myglsa.getAffectionTable(least_change=least_change): mergedict.setdefault(update, []).append(vuln) - sys.stdout.write(">>> The following updates will be performed for this GLSA:\n") - for pkg in mergedict: - if pkg != "": - sys.stdout.write(" " + pkg + " (vulnerable: " + ", ".join(mergedict[pkg]) + ")\n") + # first, extract the atoms that cannot be upgraded (where key == "") + no_upgrades = [] if "" in mergedict: - sys.stdout.write("\n>>> For the following packages, no upgrade path exists:\n") - sys.stdout.write(" " + ", ".join(mergedict[""])) + no_upgrades = mergedict[""] + del mergedict[""] + + # see if anything is left that can be upgraded + if mergedict: + sys.stdout.write(">>> Updates that will be performed:\n") + for (upd, vuln) in mergedict.iteritems(): + sys.stdout.write(" " + green(upd) + " (vulnerable: " + red(", ".join(vuln)) + ")\n") + + if no_upgrades: + sys.stdout.write(">>> No upgrade path exists for these packages:\n") + sys.stdout.write(" " + red(", ".join(no_upgrades)) + "\n") + sys.stdout.write("\n") elif mode == "inject": sys.stdout.write("injecting " + myid + "\n") myglsa.inject() -- cgit v1.2.3 From 2419943820ac8fb90bdf9bb5d2064a6ccdfec804 Mon Sep 17 00:00:00 2001 From: rbu Date: Tue, 18 Aug 2009 17:47:32 +0000 Subject: getminupgrade: fix documentation and backtrace Bug 281101: Fix a backtrace introduced in r647. in getminupgrade the rValue variable was still leftover and was used in a check when glsa-check was run in --emergelike mode and more than one upgrade atoms existed. Also, update the API documentation to reflect changes back then. svn path=/trunk/gentoolkit/; revision=671 --- pym/gentoolkit/glsa/__init__.py | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) diff --git a/pym/gentoolkit/glsa/__init__.py b/pym/gentoolkit/glsa/__init__.py index d283835..2efb008 100644 --- a/pym/gentoolkit/glsa/__init__.py +++ b/pym/gentoolkit/glsa/__init__.py @@ -374,14 +374,17 @@ def revisionMatch(revisionAtom, portdb, match_type="default"): def getMinUpgrade(vulnerableList, unaffectedList, minimize=True): """ - Checks if the systemstate is matching an atom in - I{vulnerableList} and returns string describing - the lowest version for the package that matches an atom in - I{unaffectedList} and is greater than the currently installed - version. It will return an empty list if the system is affected, - and no upgrade is possible or None if the system is not affected. - Both I{vulnerableList} and I{unaffectedList} should have the - same base package. + Checks if the state of installed packages matches an atom in + I{vulnerableList} and returns an update path. + + Return value is: + * None if the system is not affected + * a list of tuples (a,b) where + a is a cpv describing an installed vulnerable atom + b is a cpv describing an uninstalled unaffected atom + in the same slot as a + OR the empty string ("") which means no upgrade + is possible @type vulnerableList: List of Strings @param vulnerableList: atoms matching vulnerable package versions @@ -390,11 +393,9 @@ def getMinUpgrade(vulnerableList, unaffectedList, minimize=True): @type minimize: Boolean @param minimize: True for a least-change upgrade, False for emerge-like algorithm - @rtype: String | None - @return: the lowest unaffected version that is greater than - the installed version. + @rtype: List | None + @return: None if unaffected or a list of (vuln, upgrade) atoms. """ - rValue = "" v_installed = reduce(operator.add, [match(v, "vartree") for v in vulnerableList], []) u_installed = reduce(operator.add, [match(u, "vartree") for u in unaffectedList], []) @@ -416,13 +417,18 @@ def getMinUpgrade(vulnerableList, unaffectedList, minimize=True): for vuln in v_installed: update = "" + # find the best update path for the vuln atom for c in avail_updates: c_pv = portage.catpkgsplit(c) i_pv = portage.catpkgsplit(vuln) - if portage.pkgcmp(c_pv[1:], i_pv[1:]) > 0 \ - and (update == "" \ - or (minimize ^ (portage.pkgcmp(c_pv[1:], portage.catpkgsplit(rValue)[1:]) > 0))) \ - and portage.db["/"]["porttree"].dbapi.aux_get(c, ["SLOT"]) == portage.db["/"]["vartree"].dbapi.aux_get(vuln, ["SLOT"]): + if portage.pkgcmp(c_pv[1:], i_pv[1:]) <= 0: + # c is less or equal than vuln + continue + if portage.db["/"]["porttree"].dbapi.aux_get(c, ["SLOT"]) != \ + portage.db["/"]["vartree"].dbapi.aux_get(vuln, ["SLOT"]): + # upgrade to a different slot + continue + if update == "" or (minimize ^ (portage.pkgcmp(c_pv[1:], portage.catpkgsplit(update)[1:]) > 0)): update = c_pv[0]+"/"+c_pv[1]+"-"+c_pv[2] if c_pv[3] != "r0": # we don't like -r0 for display update += "-"+c_pv[3] -- cgit v1.2.3 From 8190a7299a618e0ce120fe1c894b944075576342 Mon Sep 17 00:00:00 2001 From: rbu Date: Tue, 18 Aug 2009 18:25:59 +0000 Subject: Remove 'new' target from glsa-list Everyone should use 'affected' or 'all' Update man page and changelog svn path=/trunk/gentoolkit/; revision=672 --- ChangeLog | 7 +++++++ bin/glsa-check | 21 +++++++++++---------- man/glsa-check.1 | 14 +++++++------- 3 files changed, 25 insertions(+), 17 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6ccaa47..9ee1092 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-08-18: Robert Buchholz + * glsa-check: Remove 'new' target from glsa-list, everyone + should use 'affected' or 'all' + * glsa-check: fix getminupgrade API doc and TypeError (Bug 281101) + * glsa-check: Make --pretend output in glsa-check nicer. + Add colors and fix linebreaks. + 2009-06-22: Paul Varner * glsa-check: Fix traceback with glsa-check -f (Bug 275105) diff --git a/bin/glsa-check b/bin/glsa-check index 9f2e344..fcd4cb0 100755 --- a/bin/glsa-check +++ b/bin/glsa-check @@ -24,14 +24,14 @@ __author__ = "Marius Mauch " __version__ = open("/usr/share/gentoolkit/VERSION").read().strip() optionmap = [ -["-l", "--list", "list all unapplied GLSA"], -["-d", "--dump", "--print", "show all information about the given GLSA"], -["-t", "--test", "test if this system is affected by the given GLSA"], -["-p", "--pretend", "show the necessary commands to apply this GLSA"], -["-f", "--fix", "try to auto-apply this GLSA (experimental)"], +["-l", "--list", "list the GLSAs"], +["-d", "--dump", "--print", "show all information about the GLSAs"], +["-t", "--test", "test if this system is affected by the GLSAs"], +["-p", "--pretend", "show the necessary steps to apply the GLSAs"], +["-f", "--fix", "try to auto-apply the GLSAs (experimental)"], ["-i", "--inject", "inject the given GLSA into the glsa_injected file"], ["-n", "--nocolor", "disable colors (option)"], -["-e", "--emergelike", "do not use a least-change algorithm (option)"], +["-e", "--emergelike", "upgrade to latest version (not least-change, option)"], ["-h", "--help", "show this help message"], ["-V", "--version", "some information about this tool"], ["-v", "--verbose", "print more information (option)"], @@ -112,7 +112,7 @@ if len(params) <= 0 and mode in ["fix", "test", "pretend", "dump", "inject", "ma sys.stderr.write("(specify \"all\" as parameter)\n\n") mode = "HELP" elif len(params) <= 0 and mode == "list": - params.append("new") + params.append("affected") # show help message if mode == "help" or mode == "HELP": @@ -123,7 +123,7 @@ if mode == "help" or mode == "HELP": msg += "\t" + o + "\n" msg += "\nglsa-list can contain an arbitrary number of GLSA ids, \n" msg += "filenames containing GLSAs or the special identifiers \n" - msg += "'all', 'new' and 'affected'\n" + msg += "'all' and 'affected'\n" if mode == "help": sys.stdout.write(msg) sys.exit(0) @@ -173,14 +173,15 @@ todolist = [e for e in completelist if e not in checklist] glsalist = [] if "new" in params: - glsalist = todolist params.remove("new") + sys.stderr.write("Warning: The 'new' glsa-list target has been removed, using 'affected'.\n") + params.append("affected") if "all" in params: glsalist = completelist params.remove("all") + if "affected" in params: - # replaced completelist with todolist on request of wschlich for x in todolist: try: myglsa = Glsa(x, glsaconfig) diff --git a/man/glsa-check.1 b/man/glsa-check.1 index eee5151..be15992 100644 --- a/man/glsa-check.1 +++ b/man/glsa-check.1 @@ -1,4 +1,4 @@ -.TH "glsa-check" "1" "0.6" "Marius Mauch" "gentoolkit" +.TH "glsa-check" "1" "0.3" "Marius Mauch" "gentoolkit" .SH "NAME" .LP glsa\-check \- Gentoo: Tool to locally monitor and manage GLSAs @@ -6,7 +6,7 @@ glsa\-check \- Gentoo: Tool to locally monitor and manage GLSAs .LP glsa\-check <\fIoption\fP> [\fIglsa\-list\fP] -[\fIglsa\-list\fR] can contain an arbitrary number of GLSA ids, filenames containing GLSAs or the special identifiers 'all', 'new' and 'affected' +[\fIglsa\-list\fR] can contain an arbitrary number of GLSA ids, filenames containing GLSAs or the special identifiers 'all' and 'affected' .SH "DESCRIPTION" .LP This tool is used to locally monitor and manage Gentoo Linux Security Advisories. @@ -21,19 +21,19 @@ Note: In order for this tool to be effective, you must regularly sync your local .LP .TP .B \-l, \-\-list -list all unapplied GLSA +list the a summary for all GLSAs in glsa-list and whether they affect the system .TP .B \-d, \-\-dump, \-\-print -show all information about the given GLSA +show all information about the GLSAs in glsa-list .TP .B \-t, \-\-test -test if this system is affected by the given GLSA +test if this system is affected by the GLSAs in glsa-list and output the GLSA IDs .TP .B \-p, \-\-pretend -show the necessary commands to apply this GLSA +show the necessary steps to apply the GLSAs in glsa-list .TP .B \-f, \-\-fix -try to auto\-apply this GLSA (experimental) +try to auto\-apply the GLSAs in in glsa-list using emerge. This will only upgrade packages to later version, but not remove packages when no upgrade path exists (experimental) .TP .B \-i, \-\-inject inject the given GLSA into the glsa_injected file -- cgit v1.2.3 From fa66f11aa5254b3242577d34f08f73d0997ad011 Mon Sep 17 00:00:00 2001 From: idl0r Date: Mon, 26 Oct 2009 08:47:45 +0000 Subject: Don't add an additional new line at the end of file. svn path=/trunk/gentoolkit/; revision=691 --- bin/euse | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/euse b/bin/euse index 10f75b0..ca9835e 100755 --- a/bin/euse +++ b/bin/euse @@ -520,6 +520,7 @@ modify() { (while [ "$x" -eq "0" ]; do read -r line x="$?" + [[ "${x}" -ne "0" ]] && break [ "${line:0:4}" == "USE=" ] && inuse=1 [ "${inuse}" == "0" ] && echo -E "${line}" if [ "${inuse}" == "1" ] && echo "${line}" | egrep '" *(#.*)?$' > /dev/null; then -- cgit v1.2.3 From f23a98b65fccb47be09ea4c0d330b8a5538bdd51 Mon Sep 17 00:00:00 2001 From: idl0r Date: Mon, 26 Oct 2009 08:52:01 +0000 Subject: Update ChangeLog :) svn path=/trunk/gentoolkit/; revision=692 --- ChangeLog | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ChangeLog b/ChangeLog index 9ee1092..40ff7b0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +2009-10-26: Christian Ruppert + * euse: Don't add an additional new line at the end of file. + 2009-08-18: Robert Buchholz * glsa-check: Remove 'new' target from glsa-list, everyone should use 'affected' or 'all' -- cgit v1.2.3 From 7cca9fdfcb4f0405f2f9ff87d8129fe5ebe70896 Mon Sep 17 00:00:00 2001 From: idl0r Date: Mon, 26 Oct 2009 21:49:22 +0000 Subject: Fix bug 248844, thanks to J M W . svn path=/trunk/gentoolkit/; revision=694 --- ChangeLog | 1 + man/equery.1 | 9 ++++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 40ff7b0..7a5e660 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,6 @@ 2009-10-26: Christian Ruppert * euse: Don't add an additional new line at the end of file. + * equery.1: Fix bug 248844, thanks to J M W . 2009-08-18: Robert Buchholz * glsa-check: Remove 'new' target from glsa-list, everyone diff --git a/man/equery.1 b/man/equery.1 index 27b8078..d4ca773 100644 --- a/man/equery.1 +++ b/man/equery.1 @@ -45,15 +45,18 @@ same file, it usually consitutes a problem, and should be reported (http://bugs. .br .IP is either or both of: -.br -.B \-c, \-\-category cat -only search in category cat +.\" .br +.\" .B \-c, \-\-category cat +.\" only search in category cat .br .B \-f, \-\-full\-regex supplied query is a regex .br .B \-e, \-\-earlyout stop when first match found +.br +.B \-n, \-\-name-only +don't print the version .PP .B check pkgspec -- cgit v1.2.3 From e4245be8b053765bdda7018d3c4d749821f1e20f Mon Sep 17 00:00:00 2001 From: idl0r Date: Tue, 27 Oct 2009 18:44:33 +0000 Subject: * revdep-rebuild.1: Fix bug 281050, thanks to Jesús Guerrero . MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit svn path=/trunk/gentoolkit/; revision=695 --- ChangeLog | 4 ++++ man/revdep-rebuild.1 | 9 ++++----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 7a5e660..e5afdd6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-10-27: Christian Ruppert + * revdep-rebuild.1: Fix bug 281050, thanks to Jesús Guerrero + . + 2009-10-26: Christian Ruppert * euse: Don't add an additional new line at the end of file. * equery.1: Fix bug 248844, thanks to J M W . diff --git a/man/revdep-rebuild.1 b/man/revdep-rebuild.1 index a482f66..a03ed58 100644 --- a/man/revdep-rebuild.1 +++ b/man/revdep-rebuild.1 @@ -10,6 +10,9 @@ revdep\-rebuild scans libraries and binaries for missing shared library dependen .TP .B \-C | \-\-nocolor Turn off colored output. (This option is also passed to portage.) +.TP +.B \-d | \-\-debug +Print way too much information (uses bash's set -xv) .TP .B \-e | \-\-exact Emerge the most recent version of found packages, without regard to SLOT. @@ -40,15 +43,11 @@ Turn off the progress meter .TP .B \-q | \-\-quiet Print less output and disable the progress meter. (This option is also passed to portage.) -.TP -.B \-u UTIL | \-\-no-util UTIL -Do not use features provided by UTIL. -UTIL can be one of portage-utils or pkgcore, or it can be a \fBquoted\fR space-delimited list. .TP .B \-v | \-\-verbose More output. (Prints the revdep\-rebuild search environment.) .TP -.B All other options (including unrecognized ones) are passed to the emerge command. Single\-letter options may not be combined, so for example, \-pv is not valid. Please use \-p \-v. +.B Options after -- are ignored by revdep-rebuild and passed directly to emerge. .SH "CONFIGURATION" revdep\-rebuild no longer uses hardcoded paths. To change the default behavior the following variables can be changed by the user. -- cgit v1.2.3 From afd74c21a75ef7350a66235910032ed5ce570bc9 Mon Sep 17 00:00:00 2001 From: idl0r Date: Wed, 28 Oct 2009 20:48:11 +0000 Subject: Use realpath in get_file_owner to be able to get the package containing e.g. /lib/libreadline.so.6 on amd64, fixes bug 280341. svn path=/trunk/gentoolkit/; revision=696 --- ChangeLog | 6 +++++- bin/revdep-rebuild | 11 +++++++++-- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index e5afdd6..955a1ce 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,10 @@ +2009-10-27: Christian Ruppert + * revdep-rebuild: Use realpath in get_file_owner to be able to get the + package containing e.g. /lib/libreadline.so.6 on amd64, fixes bug 280341. + 2009-10-27: Christian Ruppert * revdep-rebuild.1: Fix bug 281050, thanks to Jesús Guerrero - . + . 2009-10-26: Christian Ruppert * euse: Don't add an additional new line at the end of file. diff --git a/bin/revdep-rebuild b/bin/revdep-rebuild index b44dadc..b6d4eed 100755 --- a/bin/revdep-rebuild +++ b/bin/revdep-rebuild @@ -252,12 +252,19 @@ clean_exit() { } ## # Get the name of the package that owns a file or list of files given as args. +# NOTE: depends on app-misc/realpath! get_file_owner() { local IFS=$'\n' - # ${*/%/ } adds a space to the end of each object name to prevent false + # Add a space to the end of each object name to prevent false # matches, for example /usr/bin/dia matching /usr/bin/dialog (bug #196460). + # The same for "${rpath} ". + + rpath=$(realpath "${*}" 2>/dev/null) + # To ensure we always have something in rpath... + [[ -z $rpath ]] && rpath=${*} + find -L /var/db/pkg -name CONTENTS -print0 | - xargs -0 grep -Fl "${*/%/ }" | + xargs -0 grep -Fl -e "${*} " -e "${rpath} " | sed 's:/var/db/pkg/\(.*\)/CONTENTS:\1:' } ## -- cgit v1.2.3 From 8a7c93709f74e29b81b5e7ad5310530d86cfe87c Mon Sep 17 00:00:00 2001 From: idl0r Date: Fri, 30 Oct 2009 14:02:08 +0000 Subject: Speedup portageq queries. Include FuzzyRay's patch to respect EMERGE_DEFAULT_OPTS. svn path=/trunk/gentoolkit/; revision=697 --- ChangeLog | 4 ++++ bin/revdep-rebuild | 44 +++++++++++++++++++++++++++++++++++--------- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 955a1ce..b5b0442 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2009-10-30: Christian Ruppert + * revdep-rebuild: Speedup portageq queries. Include FuzzyRay's patch to + respect EMERGE_DEFAULT_OPTS. + 2009-10-27: Christian Ruppert * revdep-rebuild: Use realpath in get_file_owner to be able to get the package containing e.g. /lib/libreadline.so.6 on amd64, fixes bug 280341. diff --git a/bin/revdep-rebuild b/bin/revdep-rebuild index b6d4eed..55a4d6b 100755 --- a/bin/revdep-rebuild +++ b/bin/revdep-rebuild @@ -89,6 +89,7 @@ declare WORKING_DIR # Working directory where cache files are kept main() { # preliminary setup + portage_settings get_opts "$@" setup_portage setup_search_paths_and_masks @@ -280,7 +281,6 @@ normalize_emerge_opts() { setup_color() { # This should still work if NOCOLOR is set by the -C flag or in the user's # environment. - export NOCOLOR=$(portageq envvar NOCOLOR) [[ $NOCOLOR = yes || $NOCOLOR = true ]] && export RC_NOCOLOR=yes # HACK! (grr) . /etc/init.d/functions.sh } @@ -971,12 +971,38 @@ show_unowned_files() { done < "$OWNERS_FILE" | gawk '!s[$0]++' # (omit dupes) fi } + +# Get multiple portage variables at once to speedup revdep-rebuild. +portage_settings() { + local results=() + + local query_vars=( + ROOT + PORTAGE_NICENESS + EMERGE_DEFAULT_OPTS + NOCOLOR + SEARCH_DIRS + SEARCH_DIRS_MASK + LD_LIBRARY_MASK + ) + + # one value per line + IFS=$'\n' + results=( $(unset SEARCH_DIRS; unset SEARCH_DIRS_MASK; unset LD_LIBRARY_MASK; portageq envvar ${query_vars[*]}) ) + IFS=$OIFS + + PORTAGE_ROOT=${results[0]} + PORTAGE_NICENESS=${results[1]} + EMERGE_DEFAULT_OPTS=${results[2]} + export NOCOLOR=${results[3]} + SEARCH_DIRS+=" "${results[4]} + SEARCH_DIRS_MASK+=" "${results[5]} + LD_LIBRARY_MASK+=" "${results[6]} +} + ## # Setup portage and the search paths setup_portage() { - local PORTAGE_NICENESS=$(portageq envvar PORTAGE_NICENESS) - PORTAGE_ROOT=$(portageq envvar ROOT) - # Obey PORTAGE_NICENESS if [[ $PORTAGE_NICENESS ]]; then renice $PORTAGE_NICENESS $$ > /dev/null @@ -1001,9 +1027,9 @@ setup_search_paths_and_masks() { # Read the incremental variables from environment and portage # Until such time as portage supports these variables as incrementals # The value will be what is in /etc/make.conf - SEARCH_DIRS+=" "$(unset SEARCH_DIRS; portageq envvar SEARCH_DIRS) - SEARCH_DIRS_MASK+=" "$(unset SEARCH_DIRS_MASK; portageq envvar SEARCH_DIRS_MASK) - LD_LIBRARY_MASK+=" "$(unset LD_LIBRARY_MASK; portageq envvar LD_LIBRARY_MASK) +# SEARCH_DIRS+=" "$(unset SEARCH_DIRS; portageq envvar SEARCH_DIRS) +# SEARCH_DIRS_MASK+=" "$(unset SEARCH_DIRS_MASK; portageq envvar SEARCH_DIRS_MASK) +# LD_LIBRARY_MASK+=" "$(unset LD_LIBRARY_MASK; portageq envvar LD_LIBRARY_MASK) # Add the defaults if [[ -d /etc/revdep-rebuild ]]; then @@ -1056,7 +1082,7 @@ rebuild() { trap - SIGHUP SIGINT SIGQUIT SIGABRT SIGTERM einfo 'All prepared. Starting rebuild' - echo "emerge --oneshot ${EMERGE_OPTIONS[@]} $REBUILD_LIST" + echo "emerge --oneshot ${EMERGE_OPTIONS[@]} ${EMERGE_DEFAULT_OPTS} $REBUILD_LIST" is_real_merge && countdown 10 @@ -1065,7 +1091,7 @@ rebuild() { # Run in background to correctly handle Ctrl-C { - EMERGE_DEFAULT_OPTS="--oneshot ${EMERGE_OPTIONS[@]}" emerge $REBUILD_LIST <&6 + emerge --oneshot ${EMERGE_OPTIONS[@]} ${EMERGE_DEFAULT_OPTS} $REBUILD_LIST <&6 echo $? > "$STATUS_FILE" } & wait -- cgit v1.2.3 From acdf616efa73b77936963eaa8b5c715db97646d2 Mon Sep 17 00:00:00 2001 From: fuzzyray Date: Tue, 8 Dec 2009 21:53:45 +0000 Subject: 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}