From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1RSPLM-0005zY-3Q for garchives@archives.gentoo.org; Mon, 21 Nov 2011 08:35:12 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id C16EA21C024; Mon, 21 Nov 2011 08:34:56 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 65D6B21C024 for ; Mon, 21 Nov 2011 08:34:56 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id AABBA1B4001 for ; Mon, 21 Nov 2011 08:34:55 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id EAFC280042 for ; Mon, 21 Nov 2011 08:34:54 +0000 (UTC) From: "Paweł Hajdan" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Paweł Hajdan" Message-ID: <6f2f2e0dde5c8a1f593fe523e8e72b6eeff5cbb9.phajdan.jr@gentoo> Subject: [gentoo-commits] proj/arch-tools:master commit in: / X-VCS-Repository: proj/arch-tools X-VCS-Files: stabilization-candidates.py X-VCS-Directories: / X-VCS-Committer: phajdan.jr X-VCS-Committer-Name: Paweł Hajdan X-VCS-Revision: 6f2f2e0dde5c8a1f593fe523e8e72b6eeff5cbb9 Date: Mon, 21 Nov 2011 08:34:54 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: 442bfcc5-9f64-4eca-a114-40d210371579 X-Archives-Hash: d91f3d112f168ed46b0978665f18690c commit: 6f2f2e0dde5c8a1f593fe523e8e72b6eeff5cbb9 Author: Pawel Hajdan, Jr gentoo org> AuthorDate: Mon Nov 21 08:34:19 2011 +0000 Commit: Pawe=C5=82 Hajdan gentoo org> CommitDate: Mon Nov 21 08:34:19 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/arch-tools.gi= t;a=3Dcommit;h=3D6f2f2e0d Automated finding candidates for stabilization. --- stabilization-candidates.py | 122 +++++++++++++++++++++++++++++++++++++= ++++++ 1 files changed, 122 insertions(+), 0 deletions(-) diff --git a/stabilization-candidates.py b/stabilization-candidates.py new file mode 100755 index 0000000..5d0c3f8 --- /dev/null +++ b/stabilization-candidates.py @@ -0,0 +1,122 @@ +#!/usr/bin/env python +# Copyright 2011 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +import datetime +import optparse +import os.path +import re +import subprocess + +import bugz.bugzilla +from portage.package.ebuild.getmaskingstatus import getmaskingstatus +from portage.xml.metadata import MetaDataXML +import portage.versions + +class MyBugz(bugz.bugzilla.Bugz): + def get_input(self, prompt): + return raw_input(prompt) + +if __name__ =3D=3D "__main__": + parser =3D optparse.OptionParser() + parser.add_option("--arch", dest=3D"arch", action=3D"append", help=3D"G= entoo arch to use, e.g. x86, amd64, ... Can be passed multiple times.") + parser.add_option("--days", dest=3D"days", type=3Dint, default=3D30, he= lp=3D"Number of days in the tree after stabilization is possible.") + parser.add_option("--repo", dest=3D"repo", help=3D"Path to portage CVS = repository") + parser.add_option("--category", dest=3D"category", help=3D"Portage cate= gory filter (default is all categories)") + + (options, args) =3D parser.parse_args() + if not options.arch: + parser.error("--arch option is required") + if not options.repo: + parser.error("--repo option is required") + if args: + parser.error("unrecognized command-line args") + + url =3D 'https://bugs.gentoo.org' + print 'You may be prompted for your Gentoo Bugzilla username and passwo= rd (%s).' % url + bugzilla =3D MyBugz(url) + bugzilla.auth() +=09 + now =3D datetime.datetime.now() + for cp in portage.portdb.cp_all(): + if options.category and not cp.startswith(options.category + "/"): + continue + best_stable =3D portage.versions.best(portage.portdb.match(cp)) + if not best_stable: + continue + candidates =3D [] + for cpv in portage.portdb.cp_list(cp): + # Only consider higher versions than best stable. + if portage.versions.pkgcmp(portage.versions.pkgsplit(cpv), portage.ve= rsions.pkgsplit(best_stable)) !=3D 1: + continue + + # Eliminate alpha, beta, pre, rc, and so on packages. + is_unstable =3D False + for suffix in portage.versions.endversion_keys: + if ("_" + suffix) in portage.versions.pkgsplit(cpv)[1]: + is_unstable =3D True + break + if is_unstable: + continue + + # Eliminate hard masked packages among others. + if getmaskingstatus(cpv) not in [[u'~%s keyword' % arch] for arch in = options.arch]: + continue + + pv =3D portage.versions.catsplit(cpv)[1] + with open(os.path.join(options.repo, cp, 'ChangeLog')) as changelog_f= ile: + regex =3D '\*%s \((.*)\)' % re.escape(pv) + match =3D re.search(regex, changelog_file.read()) + if not match: + continue + changelog_date =3D datetime.datetime.strptime(match.group(1), '%d %b= %Y') + if now - changelog_date < datetime.timedelta(days=3Doptions.days): + continue + + candidates.append(cpv) + if not candidates: + continue + candidates.sort(key=3Dportage.versions.cpv_sort_key()) + print '\t\tWorking on %s. Candidates: %s' % (cp, ', '.join(candidates)= ) + candidates.reverse() + best_candidate =3D None + cvs_path =3D os.path.join(options.repo, cp) + for candidate in candidates: + ebuild_name =3D portage.versions.catsplit(candidate)[1] + ".ebuild" + ebuild_path =3D os.path.join(cvs_path, ebuild_name) + manifest_path =3D os.path.join(cvs_path, 'Manifest') + original_contents =3D open(ebuild_path).read() + manifest_contents =3D open(manifest_path).read() + try: + for arch in options.arch: + subprocess.check_output(["ekeyword", arch, ebuild_name], cwd=3Dcvs_= path) + subprocess.check_output(["repoman", "manifest"], cwd=3Dcvs_path) + subprocess.check_output(["repoman", "full"], cwd=3Dcvs_path) + except subprocess.CalledProcessError: + continue + finally: + f =3D open(ebuild_path, "w") + f.write(original_contents) + f.close() + f =3D open(manifest_path, "w") + f.write(manifest_contents) + f.close() + best_candidate =3D candidate + break + if best_candidate: + # Do not risk trying to stabilize a package with known bugs. + bugs =3D bugzilla.search(cp, status=3DNone) + if bugs: + continue + + # Protection against filing a stabilization bug twice. + bugs =3D bugzilla.search(best_candidate) + if bugs: + continue + + metadata =3D MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/us= r/portage/metadata/herds.xml') + + # Spam protection (strip @ and domain name). + maintainer_string =3D re.sub('@[^\s]*', '', metadata.format_maintaine= r_string()) + + print (cp, best_stable, best_candidate, maintainer_string)