From 571d9a9e2683f4f61d5387b7b7ff559f175303bb Mon Sep 17 00:00:00 2001 From: Mark Loeser Date: Sun, 1 Jun 2008 18:15:20 -0400 Subject: Initial commit of this. Very very rough, does the following: !meta !changelog !devaway --- DOCS | 53 ------- gentoo-data.rb | 63 ++++++++ gentoo-scripts/DOCS | 55 +++++++ gentoo-scripts/changelog.py | 61 ++++++++ gentoo-scripts/earch | 347 ++++++++++++++++++++++++++++++++++++++++++ gentoo-scripts/earch.sh | 2 + gentoo-scripts/grabrdeps.sh | 27 ++++ gentoo-scripts/herds.py | 84 ++++++++++ gentoo-scripts/herds.sh | 4 + gentoo-scripts/maintainer.py | 83 ++++++++++ gentoo-scripts/metadata.py | 127 ++++++++++++++++ gentoo-scripts/not-a-herd.txt | 7 + 12 files changed, 860 insertions(+), 53 deletions(-) delete mode 100644 DOCS create mode 100644 gentoo-data.rb create mode 100644 gentoo-scripts/DOCS create mode 100644 gentoo-scripts/changelog.py create mode 100644 gentoo-scripts/earch create mode 100644 gentoo-scripts/earch.sh create mode 100644 gentoo-scripts/grabrdeps.sh create mode 100644 gentoo-scripts/herds.py create mode 100644 gentoo-scripts/herds.sh create mode 100644 gentoo-scripts/maintainer.py create mode 100644 gentoo-scripts/metadata.py create mode 100644 gentoo-scripts/not-a-herd.txt diff --git a/DOCS b/DOCS deleted file mode 100644 index cd03028..0000000 --- a/DOCS +++ /dev/null @@ -1,53 +0,0 @@ -devaway INPUT -------------- -1. Set $who to 'list' -2. If any username, validate and set in $who -2. http://dev.gentoo.org/devaway/index-csv.php?who=$who - -glsa INPUT ----------- -0. Validate input. Valid chars: "-1234567890" -1. Take exact GLSA string (200710-30) -2. Display title and CAN/CVE reference. - -glsa -s INPUT -------------- -1. Validate input. Valid chars: "./>=-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" -2. glsa-check --nocolor -l 2> /dev/null | grep -i -- "$input" | sort -rn - -earch PACKAGE -------------- -1. Validate input. Valid chars: "./>=-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" -2. Use earch.sh tool. - -expn ALIAS ----------- -wget -O - -q http://dev.gentoo.org/~solar/.alias | grep ^${arg} - -ddep PACKAGE ------------- -1. Validate against http://tinderbox.x86.dev.gentoo.org/misc/rindex/.rindex -2. http://tinderbox.dev.gentoo.org/misc/rindex/${CAT}/${PN} -3. See grabrdeps.sh - -rdep PACKAGE ------------- -1. Validate against http://tinderbox.x86.dev.gentoo.org/misc/rindex/.rindex -2. http://tinderbox.dev.gentoo.org/misc/rindex/${CAT}/${PN} -3. See grabrdeps.sh - -maintainer PACKAGE ------------------- -see maintainer.py - -metadata PACKAGE ----------------- -see metadata.py - -herds .... ------ -see herds.py - -changelog .... ---------- -see changelog.py diff --git a/gentoo-data.rb b/gentoo-data.rb new file mode 100644 index 0000000..e076722 --- /dev/null +++ b/gentoo-data.rb @@ -0,0 +1,63 @@ +# Gentoo centric plugin for rbot +# Copyright (c) 2008 Mark Loeser +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +require 'net/http' + +class GentooPlugin < Plugin + def meta(m, params) + f = IO.popen("/usr/bin/python #{@bot.botclass}/gentoo-scripts/metadata.py #{params[:pkg]}") + m.reply "#{m.source.nick}: #{f.readlines}" + end + + def changelog(m, params) + f = IO.popen("/usr/bin/python #{@bot.botclass}/gentoo-scripts/changelog.py #{params[:pkg]}") + m.reply "#{m.source.nick}: #{f.readlines}" + end + + def devaway(m, params) + res = Net::HTTP.start('dev.gentoo.org', 80) { |http| + http.get("/devaway/index-csv.php?who=#{params[:dev]}") + } + m.reply "#{m.source.nick}: #{res.body}" + end +end + +plugin = GentooPlugin.new + +plugin.default_auth( 'modify', false ) +plugin.default_auth( 'view', true ) + +plugin.map 'meta :pkg', + :requirements => { + :pkg => /^[^\. ]+$/ + }, + :action => 'meta', + :auth_path => 'view' + +plugin.map 'changelog :pkg', + :requirements => { + :pkg => /^[^\. ]+$/ + }, + :action => 'changelog', + :auth_path => 'view' + +plugin.map 'devaway :dev', + :requirements => { + :dev => /^[^\. ]+$/ + }, + :action => 'devaway', + :auth_path => 'view' + diff --git a/gentoo-scripts/DOCS b/gentoo-scripts/DOCS new file mode 100644 index 0000000..fd80095 --- /dev/null +++ b/gentoo-scripts/DOCS @@ -0,0 +1,55 @@ +devaway INPUT +------------- +1. Set $who to 'list' +2. If any username, validate and set in $who +2. http://dev.gentoo.org/devaway/index-csv.php?who=$who + +glsa INPUT +---------- +0. Validate input. Valid chars: "-1234567890" +1. Take exact GLSA string (200710-30) +2. Display title and CAN/CVE reference. + +glsa -s INPUT +------------- +1. Validate input. Valid chars: "./>=-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +2. glsa-check --nocolor -l 2> /dev/null | grep -i -- "$input" | sort -rn + +earch PACKAGE +------------- +1. Validate input. Valid chars: "./>=-1234567890ABCDEFGHIJKLMNOPQRSTUVWXYZ" +2. Use earch.sh tool. + +expn ALIAS +---------- +wget -O - -q http://dev.gentoo.org/~solar/.alias | grep ^${arg} + +ddep PACKAGE +------------ +1. Validate against http://tinderbox.x86.dev.gentoo.org/misc/rindex/.rindex +2. http://tinderbox.dev.gentoo.org/misc/rindex/${CAT}/${PN} +3. See grabrdeps.sh + +rdep PACKAGE +------------ +1. Validate against http://tinderbox.x86.dev.gentoo.org/misc/rindex/.rindex +2. http://tinderbox.dev.gentoo.org/misc/rindex/${CAT}/${PN} +3. See grabrdeps.sh + +maintainer PACKAGE +------------------ +see maintainer.py + +metadata PACKAGE +---------------- +see metadata.py + +herds .... +----- +1. On a timer, call herds.sh to update the herds.xml +2. see herds.py +3. See not-a-herd.txt as well + +changelog .... +--------- +see changelog.py diff --git a/gentoo-scripts/changelog.py b/gentoo-scripts/changelog.py new file mode 100644 index 0000000..066f736 --- /dev/null +++ b/gentoo-scripts/changelog.py @@ -0,0 +1,61 @@ +#!/usr/bin/python -O + +# Copyright (C) 2004 Eric Olinger, http://evvl.rustedhalo.net +# Distributed under the terms of the GNU General Public License, v2 or later +# Author : Eric Olinger + +# I changed stuff. solar@gentoo.org + +import os,sys + +sys.stderr=open("/dev/null","w") + +import portage,string,re +from stat import * +from output import * +from xml.sax import saxutils, make_parser, handler +from xml.sax.handler import feature_namespaces + +nocolor() + +version="0.2.5" + +def usage(code): + """Prints the uage information for this script""" + print green("metadata v" + version + "\n") + print "Usage: metadata [package-cat/]package" + sys.exit(code) + +def grab_changelog_stuff(catpkg): + try: + foo="" + os.chdir(portage.settings["PORTDIR"] + "/" + catpkg) + r=re.compile("<[A-Za-z_0-9]+@gentoo.org>", re.I) + + s="\n".join(portage.grabfile("ChangeLog")) + + d={} + for x in r.findall(s): + if x not in d: + d[x] = 0 + d[x] += 1 + + l=[(d[x], x) for x in d.keys()] + l.sort(lambda x,y: cmp(y[0], x[0])) + for x in l: + p = str(x[0]) +" "+ x[1].lstrip("<").rstrip(">") + foo += p[:p.find("@")]+", " + return foo + except: + raise + +def main (): + if len( sys.argv ) < 2: + usage( 1 ) + + for pkg in sys.argv[1:]: + package_list = portage.portdb.xmatch("match-all", pkg) + print darkgreen("Package: ") + portage.pkgsplit(package_list[0])[0] + " " + darkgreen("ChangeLog: ") + grab_changelog_stuff(portage.pkgsplit(package_list[0])[0]) + +if __name__ == '__main__': + main() diff --git a/gentoo-scripts/earch b/gentoo-scripts/earch new file mode 100644 index 0000000..2f44cf0 --- /dev/null +++ b/gentoo-scripts/earch @@ -0,0 +1,347 @@ +#!/usr/bin/python -O +# +# $Header: $ +# Authors: +# Eldad Zack - Original application +# Robin H. Johnson - SLOT and masking support +# +# earch: Gentoo last arch keyword checking tool, with SLOT and masking support +# version 0.9.2 + +import sys +import os +import re +import string +import readline +import getopt +from output import * + +# we import portage later +sys.path.insert(0, "/usr/lib/portage/pym") + +version = '0.9' + +def earch_main(): + + # force to false + opt_masking_reasons = False + opt_hide_masked = False + opt_category = False + opt_help = False + opt_remove_pkgs = False + opt_one_slot = False + opt_ignore_redundant = False + opt_follow_etc_portage = False + opt_version = False + opt_slot = [] + # process commandline + try: + (opts,args) = getopt.gnu_getopt(sys.argv[1:],'cfhHims:orv',['category','masking-reasons','help','hide-masked','version','slot=','remove-pkgs','ignore-redundant','follow-etc-portage']) + for optkey,optvalue in opts: + if optkey == '-c' or optkey == '--category': + opt_category = True + if optkey == '-f' or optkey == '--follow-etc-portage': + opt_follow_etc_portage = True + if optkey == '-m' or optkey == '--masking-reasons': + opt_masking_reasons = True + if optkey == '-h' or optkey == '--help': + opt_help = True + if optkey == '-H' or optkey == '--hide-masked': + opt_hide_masked = True + if optkey == '-i' or optkey == '--ignore-redundant': + opt_ignore_redundant = True + if optkey == '-o' or optkey == '--one-slot': + opt_one_slot = True + if optkey == '-r' or optkey == '--remove-pkgs': + opt_remove_pkgs = True + if optkey == '-s' or optkey == '--slot': + opt_slot = re.split(',',optvalue) + if optkey == '-v' or optkey == '--version': + opt_version = True + except getopt.GetoptError: + opt_help = True + + # don't hide masked packages if we are printing reasons + if opt_masking_reasons: + opt_hide_masked = False + # do help + if opt_help: + earch_help() + return + # version output + if opt_version: + earch_version() + return + + if not opt_follow_etc_portage: + # this is a cheat to get portage to ignore local user profiles + # it must come before the portage module is imported + os.environ["PORTAGE_CALLER"]="repoman" + + # generate + (ebuildlist,ebuilddata,pkgkeywords) = earch_data_generate(args,slots=opt_slot,hide_masked=opt_hide_masked,include_category=opt_category,ignore_redundant=opt_ignore_redundant,one_slot=opt_one_slot) + + if opt_remove_pkgs: + earch_remove_pkgs(ebuildlist,ebuilddata,pkgkeywords) + return + + earch_data_output(ebuildlist,ebuilddata,pkgkeywords,show_masking_reason=opt_masking_reasons) + +def earch_version(): + print 'earch %s' % (version) + +def earch_help(): + earch_version + #'chHmrs:v',['category','masking-reasons','help','hide-masked','version','slot=','remove-pkgs']) + print 'Gentoo last arch keyword checking tool, with SLOT and masking support' + print + print 'Usage:' + print 'earch [opts] [CP]' + print 'If CP is omitted, the current directory is used.' + print + print 'Options:' + print '-c|--category' + print ' Include category in output.' + print + print '-f|--follow-etc-portage' + print ' By default, earch acts like repoman and ignores /etc/portage.' + print ' This option disables that behavior.' + print + print '-h|--help' + print ' This help page.' + print + print '-H|--hide-masked' + print ' Exclude all masked versions from output.' + print + print '-i|--ignore-redundant' + print ' Exclude redudant versions from keyword output.' + print ' Redundant versions are those output by -r.' + print + print '-m|--masking-reason' + print ' For all masked versions, print masking reason. ' + print ' Disables other output.' + print + print '-o|--one-slot' + print ' Consider SLOT values as if they were all equal.' + print ' This effectively disables SLOTs from consideration.' + print + print '-r|--remove-pkgs' + print ' Show all redundant versions to clean from the tree.' + print + print '-s|--slot ' + print ' SLOT values to provide output for, seperated by commas.' + print + print '-v|--version' + print ' earch version output.' + print + print 'Explaination of output:' + print '# earch [$CATEGORY/$PN]' + print '$PF[$SLOT]: $KEYWORDS' + print 'If a specific version is masked, a (M) will preceed the keywords.' + +def earch_manual_getkeywords(pkg): + file = open(pkg + ".ebuild") + for line in file.readlines(): + line = string.rstrip(line) + if re.match("^KEYWORDS=",line): + keywords = re.split("\"",line)[1] + file.close + return re.split(" ",keywords) + +def earch_data_generate(args,slots=[],hide_masked=False,include_category=False,ignore_redundant=False,one_slot=False): + stderr = sys.stderr + sys.stderr = open('/dev/null', 'w') + import portage + # and reset it + sys.stderr = stderr + + # disable color as needed + # this is actually out of place, but still the best place to run it + # to avoid importing portage twice + if (not sys.stdout.isatty()) or (portage.settings["NOCOLOR"] in ["yes","true","1"]): + nocolor() + + portdir = portage.settings["PORTDIR"] + portdb = portage.portdbapi(portdir) + archslotdict = {} + ebuildlist = [] + ebuilddata = {} + pkgkeywords = {} + + if len(args) < 1: + workdir = "." + else: + workdir = portdir + "/" + args[0] + try: + pkg = portage.portdb.xmatch("match-all", args[0]) + catpkg = portage.pkgsplit(pkg[0])[0] + workdir = portdir + "/" + catpkg + except: + pass + + try: + os.chdir(workdir) + except: + print red("!!!" + " Can't find " + workdir) + sys.exit(1) + + cp_path = os.path.abspath(workdir) + cp = re.sub(portdir+'/?','', cp_path, count=1) + #print cp + cat = re.split('/',cp)[0] + #print c + + for file in os.listdir(workdir): + if re.search("\.ebuild$",file): + s = re.split("\.ebuild$",file)[0] + ebuildlist.append(s) + + ebuildlist.sort(lambda x,y: portage.pkgcmp(portage.pkgsplit(x),portage.pkgsplit(y))) + + ebuildlist2 = [] + for pkg in ebuildlist: + cpv = cat+'/'+pkg + aux = portdb.aux_get(cpv,['SLOT','KEYWORDS']) + if one_slot: + slot = '0' + else: + slot = aux[0] + keywords = re.split(' ',aux[1]) + raw_keywords = earch_manual_getkeywords(pkg) + masking = portage.getmaskingstatus(cpv) + is_masked = len(masking) > 0 + if hide_masked and is_masked: + continue + if len(slots) > 0 and not slot in slots: + continue + if include_category: + pkg = cpv + effective_keywords = [] + if len(masking) > 0: + prefix = 'M/' + else: + prefix = '' + for key in keywords: + if len(key) == 0: + #print 'Bad key!',pkg + continue + effective_keywords.append(prefix+key) + if key[0] != '-' and key[0] != '~': + effective_keywords.append(prefix+'~'+key) + ebuildlist2.append(pkg) + # store this for usage later + ebuilddata[pkg] = {'SLOT':slot, 'KEYWORDS':keywords, 'MASKING':masking, 'EFFECTIVE_KEYWORDS':effective_keywords,'RAW_KEYWORDS':raw_keywords} + + ebuildlist = ebuildlist2 + + # build archslotdict + for pkg in ebuildlist: + slot = ebuilddata[pkg]['SLOT'] + keywords = ebuilddata[pkg]['EFFECTIVE_KEYWORDS'] + # ensure the second level tree exists + try: + archslotdict[slot] + except KeyError: + archslotdict[slot] = {} + # now actually populate the second level tree + for arch in keywords: + archslotdict[slot][arch] = pkg + + + # build pkgkeywords from archslotdict + for pkg in ebuildlist: + slot = ebuilddata[pkg]['SLOT'] + ek = ebuilddata[pkg]['EFFECTIVE_KEYWORDS'] + tpk = {} + for value,key in archslotdict[slot].iteritems(): + #value = re.sub('M/','',value) + if (key == pkg): + tpk[re.sub('M/','',value)] = True + # include all -arch and -* flags + for k in ek: + if k[0] == '-' or k[0:3] == 'M/-': + tpk[re.sub('M/','',k)] = True + pkgkeywords[pkg] = tpk.keys() + + # clean out items we are ignoring + if ignore_redundant: + ebuildlist2 = [] + for pkg in ebuildlist: + if len(pkgkeywords[pkg]) > 0: + ebuildlist2.append(pkg) + ebuildlist = ebuildlist2 + + # shorten the pkgkeywords to remove cases where a package is both ~arch + # and arch. + for pkg in ebuildlist: + keywords = pkgkeywords[pkg] + newkeywords = [] + for k in keywords: + if k[0] == '~' and k[1:] in keywords: + continue + else: + newkeywords.append(k) + pkgkeywords[pkg] = newkeywords + + # sort pkgkeywords to reflect the actual flags + for pkg in ebuildlist: + pk = pkgkeywords[pkg] + npk = pk + rk = ebuilddata[pkg]['RAW_KEYWORDS'] + def earch_sort_cmp(x,y,src=rk): + ix = src.index(x) + iy = src.index(y) + if(ix > iy): + return 1 + elif(ix < iy): + return -1 + else: + return 0 + npk.sort(cmp=earch_sort_cmp) + pkgkeywords[pkg] = npk + + return (ebuildlist,ebuilddata,pkgkeywords) + + +def earch_remove_pkgs(ebuildlist,ebuilddata,pkgkeywords): + for pkg in pkgkeywords.keys(): + if len(pkgkeywords[pkg]) == 0: + print pkg + +def earch_data_output(ebuildlist,ebuilddata,pkgkeywords,show_masking_reason=False): + + for pkg in ebuildlist: + slot = ebuilddata[pkg]['SLOT'] + masking = ebuilddata[pkg]['MASKING'] + is_masked = len(masking) > 0 + if is_masked: + m = red(' (M)') + else: + m = '' + print '%s[%s]:%s'%(white(pkg),yellow(slot),m), + # print masking reason only + if show_masking_reason: + print '%s' % (string.join(masking,', ')) + continue + earch_data_output_keywords(pkgkeywords[pkg]) + +def earch_data_output_keywords(keywords): + # force -* to the first item + if '-*' in keywords: + earch_data_output_keyword('-*') + for value in keywords: + if value == '-*': + continue + earch_data_output_keyword(value) + print + +def earch_data_output_keyword(keyword): + if keyword[0] == '-': + print red(keyword), + elif keyword[0] == '~': + print blue(keyword), + else: + print green(keyword), + +if __name__ == "__main__": + earch_main() diff --git a/gentoo-scripts/earch.sh b/gentoo-scripts/earch.sh new file mode 100644 index 0000000..752d628 --- /dev/null +++ b/gentoo-scripts/earch.sh @@ -0,0 +1,2 @@ +~/earch $1 | tr '\n' ' ' +echo diff --git a/gentoo-scripts/grabrdeps.sh b/gentoo-scripts/grabrdeps.sh new file mode 100644 index 0000000..332b6c1 --- /dev/null +++ b/gentoo-scripts/grabrdeps.sh @@ -0,0 +1,27 @@ +#!/bin/sh + +x="$1" + +cd ~ +if [ "${x/\// }" == "${x}" ]; then + wget -q -O ~/rindex.cache http://tinderbox.x86.dev.gentoo.org/misc/rindex/.rindex + x=$(grep /${x}$ ~/rindex.cache) + x=$(echo -n ${x} |tr '\n' ' ') + if [ "${x/ /}" != "${x}" ]; then + echo "ambiguous short name $1. Please specify one of the following fully-qualified ebuild names instead: $(echo $x | tr '\n' ' ')" + exit 1 + fi + [[ $x == "" ]] && exit 1 +fi + +foo=$(wget -q -O - http://tinderbox.x86.dev.gentoo.org/misc/rindex/$x) +if [[ $foo != "" ]]; then + for pkg in ${foo}; do + cpv=${pkg%:*} + use=${pkg/"${cpv}"} + result=${result:+${result}$'\n'}$(qatom -C ${cpv} | cut -f 1-2 -d " " --output-delimiter "/" | tr -d "\n")${use} + done + echo $x '<-' $(sort -u <<< "${result}" | tr "\n" " ") + exit $? +fi +exit 0 diff --git a/gentoo-scripts/herds.py b/gentoo-scripts/herds.py new file mode 100644 index 0000000..8775af7 --- /dev/null +++ b/gentoo-scripts/herds.py @@ -0,0 +1,84 @@ +#!/usr/bin/python + +# must exist because marienz is lazy +cache_dir = './cachedir' +# in seconds +cache_max_age = 100 + +# python, pyxml +import sys, string, os +import cElementTree as elementtree +import urllib2 +import os +import time + +if len(sys.argv) < 2: + print "usage: herds.py herdname" + sys.exit(1) + + +root_node = elementtree.parse('./herds.xml') + +if (sys.argv[1] == "-a"): + herds = root_node.findall('herd/name') + for herd in root_node.findall('herd/name'): + print herd.text.strip() + print + sys.exit(0) + +emails = [] + +for herd in root_node.findall('herd'): + if herd.findtext('name') == sys.argv[1]: + for dev in herd.findall('maintainer'): + role = dev.findtext('role') + email = dev.findtext('email').split('@')[0] + if role and os.getenv("VERBOSE") == "1": + email = '%s(%s)' % (email, role) + emails.append(email) + projects = list(herd.findall('maintainingproject')) + if len(projects) > 1: + print >> sys.stderr, ("I don't like multiple maintainingprojects " + "per herd, Please fix me") + if projects: + project_path = projects[0].text + cache_file = os.path.join(cache_dir, '%s.xml' % sys.argv[1]) + if (not os.path.exists(cache_file) or + (time.time() - os.path.getmtime(cache_file) > cache_max_age)): + # update the cached file + cache_file_obj = open(cache_file, 'w') + try: + f = urllib2.urlopen( + 'http://www.gentoo.org%s?passthru=1' % project_path) + while True: + data = f.read(1024) + if not data: + break + cache_file_obj.write(data) + cache_file_obj.close() + except: + # Do not keep a stale cache file around. + os.unlink(cache_file) + raise + + try: + project_node = elementtree.parse(cache_file) + except: + # Force a reload by killing the cache. + os.unlink(cache_file) + raise + for dev in project_node.findall('dev'): + emails.append(dev.text.strip()) + break + +else: + print >> sys.stderr, 'no such herd!' + + +if len(emails) < 1: + print "herd doesn't exist or has no maintainers or herds.xml is out of date" + # or the mtimedb bug around line 7263 in the portageexit() function is still present" + sys.exit(1) + +emails.sort() +print ", ".join(emails) diff --git a/gentoo-scripts/herds.sh b/gentoo-scripts/herds.sh new file mode 100644 index 0000000..510f233 --- /dev/null +++ b/gentoo-scripts/herds.sh @@ -0,0 +1,4 @@ +wget -O herds.xml -q 'http://www.gentoo.org/proj/en/metastructure/herds/herds.xml?passthru=1' +if [ ! -s herds.xml ]; then + cp /usr/portage/metadata/herds.xml . +fi diff --git a/gentoo-scripts/maintainer.py b/gentoo-scripts/maintainer.py new file mode 100644 index 0000000..5e637dc --- /dev/null +++ b/gentoo-scripts/maintainer.py @@ -0,0 +1,83 @@ +#!/usr/bin/python -O + +# Copyright (C) 2007 +# Distributed under the terms of the GNU General Public License, v2 or later + +# I changed stuff. solar@gentoo.org +# marienz@g.o also changed stuff. + +import sys + +import os +import re + +# temporarily redirect stderr to dev/null to avoid spammage +stderr = sys.stderr +sys.stderr = open('/dev/null', 'w') +import portage +# and reset it +sys.stderr = stderr + +from stat import * +from output import * + +import cElementTree as etree + +nocolor() + +version="0.0.2" + +def usage(code): + """Prints the uage information for this script""" + print green("metadata v" + version + "\n") + print "Usage: metadata [package-cat/]package" + sys.exit(code) + + +def check_metadata(full_package): + """Returns a string of metadata data or None if missing.""" + metadata_file = '%s/%s/metadata.xml' % ( + portage.settings["PORTDIR"], + portage.pkgsplit(full_package)[0]) + if not os.path.exists(metadata_file): + return None + metadata = etree.parse(metadata_file) + ret = [] + + herds = [] + maintainers = [] + + for maint in metadata.findall('maintainer'): + email = maint.findtext('email') + if email: + maintainers.append(email) + + + if not maintainers: + for herd in metadata.findall('herd'): + if herd.text: + herds.append(herd.text) + ret.append(" ".join(herds)) + else: + ret.append(" ".join(maintainers)) + + return ''.join(ret).encode('ascii', 'replace') + + +def main (): + if len( sys.argv ) < 2: + usage( 1 ) + + + for pkg in sys.argv[1:]: + pkg = portage.dep_getkey(pkg) + package_list = portage.portdb.xmatch("match-all", pkg) + if not package_list: + return + metadata = check_metadata(package_list[0]) + if metadata is not None: + print(' '.join(metadata.split())) + + +if __name__ == '__main__': + main() diff --git a/gentoo-scripts/metadata.py b/gentoo-scripts/metadata.py new file mode 100644 index 0000000..4321319 --- /dev/null +++ b/gentoo-scripts/metadata.py @@ -0,0 +1,127 @@ +#!/usr/bin/python -O + +# Copyright (C) 2004 Eric Olinger, http://evvl.rustedhalo.net +# Distributed under the terms of the GNU General Public License, v2 or later +# Author : Eric Olinger + +# I changed stuff. solar@gentoo.org +# marienz@g.o also changed stuff. + +import sys + +import os +import re + +# temporarily redirect stderr to dev/null to avoid spammage +stderr = sys.stderr +sys.stderr = open('/dev/null', 'w') +import portage +# and reset it +sys.stderr = stderr + +from stat import * +from output import * + +import cElementTree as etree + +nocolor() + +version="0.2.5" + +MAX_LONGDESC_LEN = os.getenv("MAX_LONGDESC_LEN") +if MAX_LONGDESC_LEN == None: + MAX_LONGDESC_LEN = 80 +else: + MAX_LONGDESC_LEN = int(MAX_LONGDESC_LEN) + +def usage(code): + """Prints the uage information for this script""" + print green("metadata v" + version + "\n") + print "Usage: metadata [package-cat/]package" + sys.exit(code) + + +def check_metadata(full_package): + """Returns a string of metadata data or None if missing.""" + metadata_file = '%s/%s/metadata.xml' % ( + portage.settings["PORTDIR"], + portage.pkgsplit(full_package)[0]) + if not os.path.exists(metadata_file): + return None + metadata = etree.parse(metadata_file) + ret = [] + + herds = [] + for herd in metadata.findall('herd'): + if herd.text: + herds.append(herd.text) + else: + herds.append(red('bogus empty herd')) + if not herds: + ret.append(darkgreen(" Herd: ") + red("Error (No Herd)")) + else: + ret.append(darkgreen(" Herd: ") + ", ".join(herds)) + + maintainers = [] + for maint in metadata.findall('maintainer'): + email = maint.findtext('email') + desc = maint.findtext('description') + if email: + maintainers.append(email) + else: + maintainers.append(red('bogus (empty?) maintainer')) + if desc: + maintainers.append("(Maint-desc: "+desc+")") + + if not maintainers: + ret.append(darkgreen(" Maintainer: ") + ", ".join(herds)) + else: + ret.append(darkgreen(" Maintainer: ") + ", ".join(maintainers)) + longdesc = metadata.findtext('longdescription') + if longdesc: + longdesc = longdesc.replace('\n', ' ') + if len(longdesc) > MAX_LONGDESC_LEN: + longdesc = longdesc[:MAX_LONGDESC_LEN] + '...' + ret.append(darkgreen(" Description: ") + longdesc) + return ''.join(ret).encode('ascii', 'replace') + + +def grab_changelog_stuff(catpkg): + foo="" + os.chdir(portage.settings["PORTDIR"] + "/" + catpkg) + r=re.compile("<[^@]+@gentoo.org>", re.I) + + s="\n".join(portage.grabfile("ChangeLog")) + + d={} + for x in r.findall(s): + if x not in d: + d[x] = 0 + d[x] += 1 + + l=[(d[x], x) for x in d.keys()] + l.sort(lambda x,y: cmp(y[0], x[0])) + for x in l: + p = str(x[0]) +" "+ x[1].lstrip("<").rstrip(">") + foo += p[:p.find("@")]+", " + return foo + + +def main (): + if len( sys.argv ) < 2: + usage( 1 ) + + + for pkg in sys.argv[1:]: + package_list = portage.portdb.xmatch("match-all", pkg) + if not package_list: + print red('%r does not exist' % pkg) + return + metadata = check_metadata(package_list[0]) + if metadata is not None: + print(darkgreen("Package: ") + portage.pkgsplit(package_list[0])[0] + " " + ' '.join(metadata.split())) + else: + print darkgreen("Package: ") + portage.pkgsplit(package_list[0])[0] + " " + darkgreen("Metadata: missing? candidate for tree removal") +" "+ darkgreen("ChangeLog: ") + grab_changelog_stuff(portage.pkgsplit(package_list[0])[0]) + +if __name__ == '__main__': + main() diff --git a/gentoo-scripts/not-a-herd.txt b/gentoo-scripts/not-a-herd.txt new file mode 100644 index 0000000..571cde8 --- /dev/null +++ b/gentoo-scripts/not-a-herd.txt @@ -0,0 +1,7 @@ +infra (Gentoo Infrastructure) is not a herd. infra is a team. See http://www.gentoo.org/proj/en/infrastructure/ for a list of team members. +security (Gentoo Linux Security Project) is not a herd. For a complete listing of security members see http://security.gentoo.org +pr (Gentoo Public Relations Project) is not a herd. For a complete listing of people on that team visit http://www.gentoo.org/proj/en/pr +qa (Gentoo Quality Assurance) is not a herd. For a semi complete listing of people on that team visit http://www.gentoo.org/proj/en/qa +forums (Gentoo Linux Forums) is not a herd. For a complete listing of people on that team visit http://www.gentoo.org/proj/en/forums +releng (Release Engineering) is not a herd. For a semi complete listing of people on that team visit http://www.gentoo.org/proj/en/releng +treecleaners (TreeCleaners) is not a herd. it is a qa subproject. For a semi complete listing of people on that team visit http://www.gentoo.org/proj/en/qa/treecleaners -- cgit v1.2.3-65-gdbad