summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Ullmann <jokey@gentoo.org>2006-11-01 11:43:28 +0000
committerMarkus Ullmann <jokey@gentoo.org>2006-11-01 11:43:28 +0000
commit983f6d88836e5e5a3459ed6806e5c42b809dfbb0 (patch)
tree616d4adcfe738be8f073496758b55113315ed693 /scripts
parenttagging new sync (diff)
downloadjokey-983f6d88836e5e5a3459ed6806e5c42b809dfbb0.tar.gz
jokey-983f6d88836e5e5a3459ed6806e5c42b809dfbb0.tar.bz2
jokey-983f6d88836e5e5a3459ed6806e5c42b809dfbb0.zip
scripts are always needed
svn path=/trunk/; revision=67
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/eclean173
1 files changed, 173 insertions, 0 deletions
diff --git a/scripts/eclean b/scripts/eclean
new file mode 100755
index 0000000..216e9b7
--- /dev/null
+++ b/scripts/eclean
@@ -0,0 +1,173 @@
+#!/usr/bin/env python
+# vim: set ts=4 sts=4:
+#
+# eclean -- (c) 2004 Michal Januszewski <spock@gentoo.org>
+#
+# A little script to display a list of ebuilds than can be cleaned out
+# - ie. a list of ebuilds that don't provide any new archs or ~archs.
+#
+# Usage: just call it in a directory with a bunch of ebuilds.
+#
+# $Header: /srv/cvs/gentoo/gendevtools/eclean,v 1.2 2004/09/10 14:38:07 spock Exp $
+
+import sys, re, string, commands, math
+
+# The following two functions are taken from portage and hacked a little bit
+# to handle package revisions (-r<x>).
+
+endversion={"pre":-2,"p":0,"alpha":-4,"beta":-3,"rc":-1}
+endversion_keys = ["pre", "p", "alpha", "beta", "rc"]
+
+def relparse(myver):
+ "converts last version part into three components"
+ number=0
+ suffix=0
+ endtype=0
+ endnumber=0
+
+ mynewver=string.split(myver,"_")
+ myver=mynewver[0]
+
+ #normal number or number with letter at end
+ divider=len(myver)-1
+ if myver[divider:] not in "1234567890":
+ #letter at end
+ suffix=ord(myver[divider:])
+ number=string.atof(myver[0:divider])
+ elif re.match("r([0-9]+)", myver):
+ # this will fail if we ever get more than 100 revisions
+ # - hopefully, that will never happen ;>
+ number=string.atof(myver[1:])/100
+ else:
+ number=string.atof(myver)
+
+ if len(mynewver)==2:
+ #an endversion
+ for x in endversion_keys:
+ elen=len(x)
+ if mynewver[1][:elen] == x:
+ match=1
+ endtype=endversion[x]
+ try:
+ endnumber=string.atof(mynewver[1][elen:])
+ except:
+ endnumber=0
+ break
+ return [number,suffix,endtype,endnumber]
+
+vcmpcache={}
+def vercmp(val1,val2):
+ if val1==val2:
+ #quick short-circuit
+ return 0
+
+ valkey=val1+" "+val2
+ try:
+ return vcmpcache[valkey]
+ try:
+ return -vcmpcache[val2+" "+val1]
+ except KeyError:
+ pass
+ except KeyError:
+ pass
+
+ # consider 1_p2 vc 1.1
+ # after expansion will become (1_p2,0) vc (1,1)
+ # then 1_p2 is compared with 1 before 0 is compared with 1
+ # to solve the bug we need to convert it to (1,0_p2)
+ # by splitting _prepart part and adding it back _after_expansion
+ val1_prepart = val2_prepart = ''
+ if val1.count('_'):
+ val1, val1_prepart = val1.split('_', 1)
+ if val2.count('_'):
+ val2, val2_prepart = val2.split('_', 1)
+
+ # replace '-' by '.'
+ # FIXME: Is it needed? can val1/2 contain '-'?
+ val1=string.split(val1,'-')
+ if len(val1)==2:
+ val1[0]=val1[0]+"."+val1[1]
+
+ val2=string.split(val2,'-')
+ if len(val2)==2:
+ val2[0]=val2[0]+"."+val2[1]
+
+ val1=string.split(val1[0],'.')
+ val2=string.split(val2[0],'.')
+
+ #add back decimal point so that .03 does not become "3" !
+ for x in range(1,len(val1)):
+ if val1[x][0] == '0' :
+ val1[x]='.' + val1[x]
+ for x in range(1,len(val2)):
+ if val2[x][0] == '0' :
+ val2[x]='.' + val2[x]
+
+ # extend version numbers
+ if len(val2)<len(val1):
+ val2.extend(["0"]*(len(val1)-len(val2)))
+ elif len(val1)<len(val2):
+ val1.extend(["0"]*(len(val2)-len(val1)))
+
+ # add back _prepart tails
+ if val1_prepart:
+ val1[-1] += '_' + val1_prepart
+ if val2_prepart:
+ val2[-1] += '_' + val2_prepart
+ #The above code will extend version numbers out so they
+ #have the same number of digits.
+ for x in range(0,len(val1)):
+
+ cmp1=relparse(val1[x])
+ cmp2=relparse(val2[x])
+
+ for y in range(0,4):
+ myret=cmp1[y]-cmp2[y]
+
+ if myret != 0:
+ if myret < 0:
+ myret = -1
+ else:
+ myret = 1
+
+ vcmpcache[valkey]=myret
+ return myret
+ vcmpcache[valkey]=0
+ return 0
+
+pkg = commands.getoutput('basename $(pwd)')
+versions = string.split(commands.getoutput('ls -1 *ebuild | sed -e "s/.ebuild//" -e "s/$(basename $(pwd))-//"'),"\n")
+versions.sort(vercmp)
+versions.reverse()
+
+tbl={}
+
+for i in versions:
+
+ data = commands.getoutput('grep KEYWORDS %s-%s.ebuild | sed -e "s/KEYWORDS=//" -e \'s/"//g\'' % (pkg, i))
+ toclean = 1
+
+ for arch in string.split(data,' '):
+
+ if re.match('\*', arch) or len(arch) == 0:
+ continue
+
+ if arch[0] == '~':
+ if not tbl.has_key(arch[1:]):
+ tbl[arch[1:]] = {}
+
+ if not tbl[arch[1:]].has_key("unstable") and not tbl[arch[1:]].has_key("stable"):
+ tbl[arch[1:]]["unstable"] = i
+ toclean = 0
+
+ elif data[0] != '-':
+ if not tbl.has_key(arch):
+ tbl[arch] = {}
+
+ if not tbl[arch].has_key("stable"):
+ tbl[arch]["stable"] = i
+ toclean = 0
+
+ if toclean:
+ print "clean %s (%s)" % (i,data)
+