From 2042b9bfe9c2f685a9aef043378a8c0ba985924f Mon Sep 17 00:00:00 2001 From: Fabian Groffen Date: Fri, 14 Aug 2009 20:26:56 +0000 Subject: [PATCH] Merged from trunk -r13978:13988 | 13979 | Add portage ImportError sys.path insertion. | | zmedico | | | 13980 | This is an old emerge profiling script that probably doesn't | | zmedico | work. | | 13981 | This is a commandline interface to pkgsplit() that probably | | zmedico | isn't used by anyone. We can add a function like this to | | | portageq. | | 13982 | This old script does checksums on installed files. People | | zmedico | use equery for this now. | | 13983 | This script is obsolete since manifest 2. | | zmedico | | | 13984 | This is an obsolete shell script for applying package moves | | zmedico | vardb entry. | | 13985 | This definitely obsolete. | | zmedico | | | 13986 | This is an uneeded script for parsing ldd output. | | zmedico | | | 13987 | Add portage ImportError sys.path insertion. | | zmedico | | | 13988 | This is an unused commandline interface to xpak.xpak(). | | zmedico | | svn path=/main/branches/prefix/; revision=14040 --- bin/chkcontents | 69 ------------------------------ bin/egencache | 9 +++- bin/find-requires | 44 -------------------- bin/fixdbentries | 20 --------- bin/md5check.py | 104 ---------------------------------------------- bin/md5check.sh | 31 -------------- bin/pemerge.py | 44 -------------------- bin/pkgname | 22 ---------- bin/quickpkg | 3 +- bin/xpak | 20 --------- 10 files changed, 9 insertions(+), 357 deletions(-) delete mode 100755 bin/chkcontents delete mode 100755 bin/find-requires delete mode 100755 bin/fixdbentries delete mode 100755 bin/md5check.py delete mode 100755 bin/md5check.sh delete mode 100755 bin/pemerge.py delete mode 100755 bin/pkgname delete mode 100755 bin/xpak diff --git a/bin/chkcontents b/bin/chkcontents deleted file mode 100755 index 4bdf34c2e..000000000 --- a/bin/chkcontents +++ /dev/null @@ -1,69 +0,0 @@ -#!@PORTAGE_PYTHON@ -# Copyright 1999-2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -# Very simple program to compare the md5sums of a package as listed -# in VDB_PATH/category/package/CONTENTS with the md5sums of the -# actual programs on the system (and makes sure that symlinks point to -# the right files). - -import os.path, os, sys - -# for an explanation on this logic, see pym/_emerge/__init__.py -import os -import sys -if os.environ.__contains__("PORTAGE_PYTHONPATH"): - sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"]) -else: - sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym")) -import portage - -def CONTENTScheck(path): - try: - contents = open(path, "r") - except IOError, e: - print "Unable to open %s: %s" % (path, e) - sys.exit(1) - lines = contents.readlines() - for line in lines: - items = line.split() - # items is a list w/ size depending on the type of item listed in item[0] - # if items[0] = 'dir' then items[1] is the path of a directory - # if items[0] = 'obj' then items[1] is the path of a file, - # items[2] is the file's md5sum, - # items[3] is the file's size - # if items[0] = 'sym' then items[1] is the path of a symbolic link, - # items[2] is '->' - # items[3] is the file the symlink should point to - # items[4] is the symlink mtime - if (items[0] == 'obj'): - md5stored = items[2].lower() - # fchksum.fmdft(file) returns the file's md5sum and the file's size - md5real = portage.perform_checksum(items[1])[0].lower() - if (md5stored != md5real): - if md5real: - print "%s has md5sum of %s instead of %s" % (items[1], md5real, md5stored) - else: - print "%s is missing!" % items[1] - elif (items[0] == 'sym'): - link = items[1] - target = items[3] - if (not os.path.islink(link)): - print "%s is not a symbolic link" % link - continue - actualtarget = os.readlink(link) - if (os.path.normpath(actualtarget) != os.path.normpath(target)): - print "%s points to %s, not %s" % (link, actualtarget, target) - - -if __name__ == '__main__': - import sys - if (len(sys.argv) != 2 or sys.argv[1] == "--help"): - print "This program compares md5sums in the file VDB_PATH/category/package/CONTENTS" - print "with the md5sums of the actual files on the filesystem" - print "(and makes sure that symlinks point to the right files)." - print "\nUsage: chkcontents path/to/CONTENTS" - sys.exit(1) - CONTENTScheck(sys.argv[1]) - diff --git a/bin/egencache b/bin/egencache index d04dec202..a848279f9 100755 --- a/bin/egencache +++ b/bin/egencache @@ -22,7 +22,14 @@ except KeyboardInterrupt: import logging import optparse import os -import portage + +try: + import portage +except ImportError: + from os import path as osp + sys.path.insert(0, osp.join(osp.dirname(osp.dirname(osp.realpath(__file__))), "pym")) + import portage + from _emerge.MetadataRegen import MetadataRegen from portage.cache.cache_errors import CacheError, StatCollision from portage.util import writemsg_level diff --git a/bin/find-requires b/bin/find-requires deleted file mode 100755 index 91951a8a5..000000000 --- a/bin/find-requires +++ /dev/null @@ -1,44 +0,0 @@ -#!@PORTAGE_BASH@ -# Copyright 1999-2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -# note this works for both a.out and ELF executables -# it also auto-generates requirment lines for shell scripts - -ulimit -c 0 - -filelist=`sed "s/['\"]/\\\&/g"` -exelist=`echo $filelist | $XARGS file | grep ":.*executable" | cut -d: -f1 ` -scriptlist=`echo $filelist | $XARGS file | @EGREP@ ":.* (commands|script) " | cut -d: -f1 ` -liblist=`echo $filelist | $XARGS file | grep ":.*shared object" | cut -d : -f1 ` - -for f in $exelist; do - if [ -x $f ]; then - ldd $f | awk '/=>/ { print $1 }' - fi -done | sort -u | sed "s/['\"]/\\\&/g" | $XARGS -n 1 basename | grep -v 'libNoVersion.so' | sort -u - -for f in $liblist; do - ldd $f | awk '/=>/ { print $1 }' -done | sort -u | sed "s/['\"]/\\\&/g" | $XARGS -n 1 basename | grep -v 'libNoVersion.so' | sort -u - -for f in $scriptlist; do - if [ -x $f ]; then - head -1 $f | sed -e 's/^\#\![ ]*//' | cut -d" " -f1 - fi -done | sort -u - -#for f in $liblist $exelist ; do -# objdump -p $f | awk ' -# BEGIN { START=0; LIBNAME=""; } -# /Version References:/ { START=1; } -# /required from/ && (START==1) { -# sub(/:/, "", $3); -# LIBNAME=$3; -# } -# (START==1) && (LIBNAME!="") && ($4~/^GLIBC_*/) { print LIBNAME "(" $4 ")"; } -# /^$/ { START=0; } -# ' -#done | sort -u - diff --git a/bin/fixdbentries b/bin/fixdbentries deleted file mode 100755 index d4e288821..000000000 --- a/bin/fixdbentries +++ /dev/null @@ -1,20 +0,0 @@ -#!@PORTAGE_BASH@ -# Copyright 1999-2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -# Script to adjust the contents of the DB entries after a package move. -# Fairly straight forward... ./movedbentry 'from/here' 'to/here' /over/here - -VAR=$1 -NEW=$2 -SPATH=$3 - -grep -FrZl "${VAR}" "${SPATH}" | -sed "s#${SPATH}[^\d000]\+/CONTENTS\d000##g" | -$XARGS -0 sed -i -e " -s#${VAR}\$#${NEW}#g; -s#${VAR}\([[:space:]]\)#${NEW}\1#g; -s#${VAR}\(-[^a-zA-Z]\)#${NEW}\1#g; -s#${VAR}\([^a-zA-Z0-9-]\)#${NEW}\1#g -" diff --git a/bin/md5check.py b/bin/md5check.py deleted file mode 100755 index 5976c1434..000000000 --- a/bin/md5check.py +++ /dev/null @@ -1,104 +0,0 @@ -#!@PORTAGE_PYTHON@ -O -# Copyright 1999-2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -import os,sys -os.environ["FEATURES"]="mirror cvs" - -# for an explanation on this logic, see pym/_emerge/__init__.py -import os -import sys -if os.environ.__contains__("PORTAGE_PYTHONPATH"): - sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"]) -else: - sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym")) -import portage - -import portage.util - -def cstrip(mystr,mychars): - newstr = "" - for x in mystr: - if x not in mychars: - newstr += x - return newstr - -md5_list = {} -bn_list = [] -col_list = [] - -hugelist = [] -for mycp in portage.db["/"]["porttree"].dbapi.cp_all(): - hugelist += portage.db["/"]["porttree"].dbapi.cp_list(mycp) -hugelist.sort() - -for mycpv in hugelist: - pv = mycpv.split("/")[-1] - - newuri = portage.db["/"]["porttree"].dbapi.aux_get(mycpv,["SRC_URI"])[0] - newuri = newuri.split() - - digestpath = portage.db["/"]["porttree"].dbapi.findname(mycpv) - digestpath = os.path.dirname(digestpath)+"/files/digest-"+pv - md5sums = portage.digestParseFile(digestpath) - - if md5sums == None: - portage.writemsg("Missing digest: %s\n" % mycpv) - md5sums = {} - - for x in md5sums.keys(): - if x[0] == '/': - del md5sums[x] - - #portage.writemsg("\n\ndigestpath: %s\n" % digestpath) - #portage.writemsg("md5sums: %s\n" % md5sums) - #portage.writemsg("newuri: %s\n" % newuri) - - bn_list = [] - for x in newuri: - if not x: - continue - if (x in [")","(",":","||"]) or (x[-1] == "?"): - # ignore it. :) - continue - x = cstrip(x,"()|?") - if not x: - continue - - mybn = os.path.basename(x) - if mybn not in bn_list: - bn_list += [mybn] - else: - continue - - if mybn not in md5sums: - portage.util.writemsg("Missing md5sum: %s in %s\n" % (mybn, mycpv)) - else: - if mybn in md5_list: - if (md5_list[mybn]["MD5"] != md5sums[mybn]["MD5"]) or \ - (md5_list[mybn]["size"] != md5sums[mybn]["size"]): - - # This associates the md5 with each file. [md5/size] - md5joins = md5_list[mybn][2].split(",") - md5joins = (" ["+md5_list[mybn][0]+"/"+md5_list[mybn][1]+"],").join(md5joins) - md5joins += " ["+md5_list[mybn][0]+"/"+md5_list[mybn][1]+"]" - - portage.writemsg("Colliding md5: %s of %s [%s/%s] and %s\n" % (mybn,mycpv,md5sums[mybn][0],md5sums[mybn][1],md5joins)) - col_list += [mybn] - else: - md5_list[mybn][2] += ","+mycpv - else: - md5_list[mybn] = md5sums[mybn]+[mycpv] - del md5sums[mybn] - - #portage.writemsg(str(bn_list)+"\n") - for x in md5sums: - if x not in bn_list: - portage.writemsg("Extra md5sum: %s in %s\n" % (x, mycpv)) - - -print col_list -print -print str(len(md5_list))+" unique distfile md5s." -print str(len(bn_list))+" unique distfile names." diff --git a/bin/md5check.sh b/bin/md5check.sh deleted file mode 100755 index 05cc59615..000000000 --- a/bin/md5check.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!@PORTAGE_BASH@ -# Copyright 1999-2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -# pipe in the data. - -sort -u - > md5check.tmp -grep '^Extra' md5check.tmp > md5check.tmp.extra -grep '^Missing' md5check.tmp > md5check.tmp.missing -grep '^Coll' md5check.tmp > md5check.tmp.colliding - -sed -i " -s:^Col:\nCol: -s:,:\n :g -s: of :\n :g -s: and :\n :g" md5check.tmp.colliding -sed -i "s/^[^ ]\+ md5sum: \(.*\) in \(.*\)$/ \2: \1/g" md5check.tmp.missing -sed -i "s/^[^ ]\+ md5sum: \(.*\) in \(.*\)$/ \2: \1/g" md5check.tmp.extra - -#echo "Colliding files:" > md5check.colliding -#sort -u md5check.tmp.colliding >> md5check.colliding -cp md5check.tmp.colliding md5check.colliding - -echo "Missing from digest:" > md5check.missing -sort -u md5check.tmp.missing >> md5check.missing - -echo "Extra files in digest:" > md5check.extra -sort -u md5check.tmp.extra >> md5check.extra - -rm md5check.tmp* diff --git a/bin/pemerge.py b/bin/pemerge.py deleted file mode 100755 index 8a578e7b6..000000000 --- a/bin/pemerge.py +++ /dev/null @@ -1,44 +0,0 @@ -#!@PORTAGE_PYTHON@ -O - -import profile,time,sys,os -sys.path = ["@PORTAGE_BASE@/bin","@PORTAGE_BASE@/pym"]+sys.path - -def clock(): - return time.time() -profile.time.clock = clock - -profile.run("import emerge", os.getcwd()+"/prof") - -class StatsProcesser: - def __init__(self, stats): - self.output = [] - self.last = "" - import sys - sys.stdout = self - stats.print_stats() - sys.stdout = sys.__stdout__ - funcs = ["?"] - for line in self.output: - spline = line.split() - if len(spline) == 6 and spline[0][0].isdigit(): - func = spline[5][spline[5].index("(")+1:-1] - print line - if func not in funcs: - funcs.append(func) - func = "\\(" + func + "\\)" - stats.print_callers(func) - - def write(self, text): - new = self.last + text - new = new.split("\n") - if len(new) > 1: - self.output += new[:-1] - self.last = new[-1] - -import pstats -p = pstats.Stats("prof") -dir(p) -p.sort_stats("time") -p.print_stats() - -sp = StatsProcesser(p) diff --git a/bin/pkgname b/bin/pkgname deleted file mode 100755 index 1d3637194..000000000 --- a/bin/pkgname +++ /dev/null @@ -1,22 +0,0 @@ -#!@PORTAGE_PYTHON@ -# Copyright 1999-2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -# for an explanation on this logic, see pym/_emerge/__init__.py -import os -import sys -if os.environ.__contains__("PORTAGE_PYTHONPATH"): - sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"]) -else: - sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym")) -import portage -from portage.versions import pkgsplit - -a=pkgsplit(sys.argv[1]) -if a: - print a[0],a[1],a[2][1:] - sys.exit(0) -else: - print '!!! Error: package name is invalid.' - sys.exit(1) diff --git a/bin/quickpkg b/bin/quickpkg index 9223f2ea0..01df28702 100755 --- a/bin/quickpkg +++ b/bin/quickpkg @@ -7,12 +7,11 @@ import errno, signal, sys, os from itertools import izip # for an explanation on this logic, see pym/_emerge/__init__.py -import os -import sys if os.environ.__contains__("PORTAGE_PYTHONPATH"): sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"]) else: sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym")) +import portage def quickpkg_main(options, args, eout): from portage import catsplit, dep_expand, flatten, isvalidatom, xpak diff --git a/bin/xpak b/bin/xpak deleted file mode 100755 index c41c18449..000000000 --- a/bin/xpak +++ /dev/null @@ -1,20 +0,0 @@ -#!@PORTAGE_PYTHON@ -O -# Copyright 1999-2006 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -import sys, os -if len(sys.argv)!=3: - print "xpak: expecting three arguments." - sys.exit(1) - -# for an explanation on this logic, see pym/_emerge/__init__.py -import os -import sys -if os.environ.__contains__("PORTAGE_PYTHONPATH"): - sys.path.insert(0, os.environ["PORTAGE_PYTHONPATH"]) -else: - sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "pym")) -import portage.xpak - -portage.xpak.xpak(sys.argv[1],sys.argv[2]) -- 2.26.2