From: fuzzyray Date: Tue, 5 May 2009 21:04:27 +0000 (-0000) Subject: Update to most recent versions and add changes from djanderson X-Git-Tag: gentoolkit-0.3.0_rc5~3 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=7dd5d6b8f250db3657040e3bcb9e44b674d74bb4;p=gentoolkit.git Update to most recent versions and add changes from djanderson svn path=/trunk/gentoolkit/; revision=599 --- diff --git a/bin/eclean b/bin/eclean index 8b473f9..5497cf3 100644 --- a/bin/eclean +++ b/bin/eclean @@ -1,8 +1,9 @@ -#!/usr/bin/env python +#!/usr/bin/python # Copyright 2003-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ +from __future__ import with_statement ############################################################################### # Meta: @@ -15,6 +16,7 @@ __description__ = "A cleaning tool for Gentoo distfiles and binaries." ############################################################################### # Python imports: + import sys import os, stat import re @@ -502,12 +504,13 @@ def exclDictMatch(excl_dict,pkg): # findDistfiles: find all obsolete distfiles. # XXX: what about cvs ebuilds? i should install some to see where it goes... def findDistfiles( \ + myoptions, \ exclude_dict={}, \ destructive=False,\ fetch_restricted=False, \ package_names=False, \ time_limit=0, \ - size_limit=0): + size_limit=0,): # this regexp extracts files names from SRC_URI. It is not very precise, # but we don't care (may return empty strings, etc.), since it is fast. file_regexp = re.compile('([a-zA-Z0-9_,\.\-\+\~]*)[\s\)]') @@ -548,7 +551,12 @@ def findDistfiles( \ except KeyError: continue del pkg_list - # create a dictionary of files which should be deleted + # create a dictionary of files which should be deleted + if not (os.path.isdir(distdir)): + eerror("%s does not appear to be a directory." % distdir, myoptions['nocolor']) + eerror("Please set DISTDIR to a sane value.", myoptions['nocolor']) + eerror("(Check your /etc/make.conf and environment).", myoptions['nocolor']) + exit(1) for file in os.listdir(distdir): filepath = os.path.join(distdir, file) try: file_stat = os.stat(filepath) @@ -589,12 +597,19 @@ def findDistfiles( \ # XXX: packages are found only by symlinks. Maybe i should also return .tbz2 # files from All/ that have no corresponding symlinks. def findPackages( \ + myoptions, \ exclude_dict={}, \ destructive=False, \ time_limit=0, \ package_names=False): clean_dict = {} - # create a full package dictionnary + # 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']) + eerror("(Check your /etc/make.conf and environment).", myoptions['nocolor']) + exit(1) for root, dirs, files in os.walk(pkgdir): if root[-3:] == 'All': continue for file in files: @@ -631,7 +646,7 @@ def findPackages( \ del clean_dict[mycpv] continue if portage.cpv_getkey(mycpv) in cp_all: - # exlusion because of --package-names + # exlusion because of --package-names del clean_dict[mycpv] return clean_dict @@ -673,7 +688,12 @@ def doCleanup(clean_dict,action,myoptions): "Do you want to delete this " \ + file_type+"?"): # non-interactive mode or positive answer. - # For each file,... + # For each file, try to delete the file and clean it out + # of Packages metadata file + if action == 'packages': + metadata = portage.getbinpkg.PackageIndex() + with open(os.path.join(pkgdir, 'Packages')) as metadata_file: + metadata.read(metadata_file) for file in clean_dict[mykey]: # ...get its size... filesize = 0 @@ -683,11 +703,21 @@ def doCleanup(clean_dict,action,myoptions): except: eerror("Could not read size of "\ +file, myoptions['nocolor']) # ...and try to delete it. - try: os.unlink(file) - except: eerror("Could not delete "+file, \ - myoptions['nocolor']) + try: + os.unlink(file) + except: + eerror("Could not delete "+file, \ + myoptions['nocolor']) # only count size if successfully deleted - else: clean_size += filesize + else: + 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) + # return total size of deleted or to delete files return clean_size @@ -704,13 +734,15 @@ def doAction(action,myoptions,exclude_dict={}): einfo("Building file list for "+action+" cleaning...", \ myoptions['nocolor']) if action == 'packages': - clean_dict = findPackages( \ + clean_dict = findPackages( + myoptions, \ exclude_dict=exclude_dict, \ destructive=myoptions['destructive'], \ package_names=myoptions['package-names'], \ time_limit=myoptions['time-limit']) else: clean_dict = findDistfiles( \ + myoptions, \ exclude_dict=exclude_dict, \ destructive=myoptions['destructive'], \ fetch_restricted=myoptions['fetch-restricted'], \ diff --git a/bin/euse b/bin/euse index b49b120..df61e32 100755 --- a/bin/euse +++ b/bin/euse @@ -346,7 +346,7 @@ showinstdesc() { local current_desc local args local -i foundone=0 - local IFS + local OIFS="$IFS" args=("${@:-*}") @@ -376,7 +376,7 @@ showinstdesc() { echo "$desc" # get list of installed packages matching this USE flag. IFS=$'\n' - packages=($(equery -q -C hasuse -i "${1}" | awk '{ print $(NF-1) }')) + packages=($(equery -q -C hasuse -i "${1}" | awk '{ print $(NF-1) }' | sort)) foundone+=${#packages[@]} printf "\nInstalled packages matching this USE flag: " if [ ${foundone} -gt 0 ]; then @@ -396,7 +396,9 @@ showinstdesc() { # exit status of equery instead of a subshell and pipe to wc -l if [ $(equery -q -C list -i -e "${pkg}" | wc -l) -gt 0 ]; then foundone=1 + IFS="$OIFS" get_flagstatus "${flag}" + IFS=': ' printf "%s (%s):\n%s\n\n" "${flag}" "${pkg}" "${desc#- }" fi done < <(grep ":${1} *-" "${descdir}/use.local.desc") @@ -408,6 +410,7 @@ showinstdesc() { if [ ${foundone} -lt 1 ]; then echo "no matching entries found" fi + IFS="$OIFS" } # show a list of all currently active flags and where they are activated diff --git a/bin/glsa-check b/bin/glsa-check index 1fb577d..0ce133e 100644 --- a/bin/glsa-check +++ b/bin/glsa-check @@ -16,7 +16,7 @@ try: except ImportError: from output import * -from getopt import getopt,GetoptError +from getopt import getopt, GetoptError __program__ = "glsa-check" __author__ = "Marius Mauch " @@ -81,10 +81,10 @@ try: # sanity checking if len(args) <= 0: sys.stderr.write("no option given: what should I do ?\n") - mode="help" + mode = "HELP" elif len(args) > 1: sys.stderr.write("please use only one command per call\n") - mode = "help" + mode = "HELP" else: # in what mode are we ? args = args[0] @@ -95,32 +95,37 @@ try: except GetoptError, e: sys.stderr.write("unknown option given: ") sys.stderr.write(str(e)+"\n") - mode = "help" + mode = "HELP" # we need a set of glsa for most operation modes if len(params) <= 0 and mode in ["fix", "test", "pretend", "dump", "inject", "mail"]: sys.stderr.write("\nno GLSA given, so we'll do nothing for now. \n") sys.stderr.write("If you want to run on all GLSA please tell me so \n") sys.stderr.write("(specify \"all\" as parameter)\n\n") - mode = "help" + mode = "HELP" elif len(params) <= 0 and mode == "list": params.append("new") # show help message -if mode == "help": - sys.stderr.write("\nSyntax: glsa-check