diff options
author | Gilles Dartiguelongue <eva@gentoo.org> | 2010-04-13 10:05:28 +0200 |
---|---|---|
committer | Gilles Dartiguelongue <eva@gentoo.org> | 2010-04-13 10:07:56 +0200 |
commit | cea66781eaf920151908daf5f4fe26a688c369d2 (patch) | |
tree | 82c95948fa3d10a8dd4852e100040f63420b0f1e /scripts | |
parent | gen-archlist.py: Various fixes (diff) | |
download | gnome-cea66781eaf920151908daf5f4fe26a688c369d2.tar.gz gnome-cea66781eaf920151908daf5f4fe26a688c369d2.tar.bz2 gnome-cea66781eaf920151908daf5f4fe26a688c369d2.zip |
scripts: add find-keywordreq script
These are experimental scripts to generate a keyword request list for
arches and ease new gnome release work.
Use like this: sh find-keywordreq.sh <list-of-atoms>
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/find-keywordreq.py | 107 | ||||
-rwxr-xr-x | scripts/find-keywordreq.sh | 33 |
2 files changed, 140 insertions, 0 deletions
diff --git a/scripts/find-keywordreq.py b/scripts/find-keywordreq.py new file mode 100644 index 00000000..7f319f61 --- /dev/null +++ b/scripts/find-keywordreq.py @@ -0,0 +1,107 @@ +#!/usr/bin/python + +""" Helper module to print a list of needed keywords provided a list of cpv. + +Can be tweaked to either compute keyword request from a list of defined arches or from older revisions available stable keywords. +""" + +import os +import sys + +import portage + +from pprint import pprint + +ARCH_GNOME=['alpha', 'amd64', 'arm', 'hppa', 'ia64', 'ppc', 'ppc64', 'sh', 'sparc', 'x86'] +ARCH_DEV=["mips", "amd64-fbsd", "sparc-fbsd", "x86-fbsd"] +ARCH_EXP=["ppc-aix", "x86-freebsd", "x64-freebsd", "hppa-hpux", "ia64-hpux", "x86-interix", "mips-irix", "amd64-linux", "arm-linux", "ia64-linux", "x86-linux", "ppc-macos", "x86-macos", "x64-macos", "m68k-mint", "x86-netbsd", "ppc-openbsd", "x86-openbsd", "x64-openbsd", "sparc-solaris", "sparc64-solaris", "x64-solaris", "x86-solaris", "x86-winnt"] + +def package_sort(item1, item2): + """ Sort revisions """ + + return portage.dep.pkgcmp(portage.dep.pkgsplit(item1), portage.dep.pkgsplit(item2)) + +def main(): + """ Main function """ + + api = portage.portdbapi() + api._aux_cache_keys.clear() + api._aux_cache_keys.update(["EAPI", "KEYWORDS", "SLOT"]) + + root = '/' + trees = { + root : {'porttree' : portage.portagetree(root)} + } + portdb = trees[root]['porttree'].dbapi + #portdb._aux_cache_keys.clear() + #portdb._aux_cache_keys.update(["EAPI", "KEYWORDS", "SLOT"]) + + #pprint(api.porttrees) + + for atom in sys.argv: + + arches = {} + keywords = {} + best_revision = {} + need_keyword = {} + revisions = api.cp_list(atom, mytree=api.porttrees[0]) + rev_keywords = {} + max_arch_list = [] + + # Select best revision + revisions.sort(package_sort) + + # Build maximum possible arches list + for revision in revisions: + # print revision + + aux_kw, slot = api.aux_get(revision, ['KEYWORDS', 'SLOT']) + aux_kw = [kw for kw in aux_kw.replace('~', '').split() if kw and not kw.startswith('-') and kw not in ARCH_DEV and kw not in ARCH_EXP] + + # Build best set of keywords per SLOT + for kw in aux_kw: + if slot in keywords: + if kw not in keywords[slot]: + keywords[slot].append(kw) + else: + keywords[slot] = [kw] + + if not keywords or not slot in keywords: + revisions.remove(revision) + else: + if revision.endswith("9999"): + revisions.remove(revision) + continue + best_revision[slot] = revision + keywords[slot] = ARCH_GNOME + need_keyword[slot] = [kw for kw in keywords[slot] if kw not in aux_kw] + + # Show missing arches + for slot in keywords: + if need_keyword[slot]: +# keycheck_incrementals = tuple(x for x in portage.const.INCREMENTALS if x != 'ACCEPT_KEYWORDS') + # for package.use.mask support inside dep_check +# dep_settings = portage.config( +# config_incrementals = keycheck_incrementals, +# local_config = False) +# dep_settings.setcpv(revision) +# dep_settings["ACCEPT_KEYWORDS"] = " ".join(keywords[slot] + need_keyword[slot]) +# +# for dep_type in ('DEPEND', 'RDEPEND', 'PDEPEND'): +# aux_dep = api.aux_get(revision, [dep_type])[0] +# print portage.dep_check(aux_dep, portdb, dep_settings, use='all', trees=trees, mode='minimum-visible') +# + + kw_print = "" + for kw in ARCH_GNOME: + kw_print += " " + if kw in need_keyword[slot]: + kw_print += kw + else: + kw_print += " " * len(kw) + + print "%-60s:" % best_revision[slot], kw_print + + +if __name__ == "__main__": + main() diff --git a/scripts/find-keywordreq.sh b/scripts/find-keywordreq.sh new file mode 100755 index 00000000..f11aedc4 --- /dev/null +++ b/scripts/find-keywordreq.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +# Wrapper script for find-keywordreq.py. +# Builds a temporary overlay and check for dependencies with repoman + +cd $(dirname $0) + +#PORTDIR=$(portageq portdir) +PORTDIR=/home/eva/devel/gentoo-x86 + +rm -rf /tmp/tmptree +rm -rf /tmp/step1.list + +python find-keywordreq.py $@ > /tmp/step1.list + +while read line +do + ATOM=$(echo $line | cut -f1 -d: | sed -nr 's/(.*)-[0-9.]+.*/\1/p'| xargs echo) + PN=$(echo $ATOM | cut -f2 -d/ | xargs echo) + VERSION=$(echo $line | cut -f1 -d: | sed -nr 's/.*-([0-9.]+.*)/\1/p' |xargs echo) + KEYWORDS=$(echo $line | cut -f2 -d:) + mkdir -p /tmp/tmptree/$ATOM + cp $PORTDIR/$ATOM/$PN-$VERSION.ebuild \ + /tmp/tmptree/$ATOM + for keyword in $(echo $KEYWORDS) + do + ekeyword ~$keyword /tmp/tmptree/$ATOM/$PN-$VERSION.ebuild > /dev/null + done +done < /tmp/step1.list + +cd /tmp/tmptree +PORTDIR="${PORTDIR}" PORTDIR_OVERLAY="/tmp/tmptree" repoman manifest +PORTDIR="${PORTDIR}" PORTDIR_OVERLAY="/tmp/tmptree" repoman full |