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 <gentoo-commits+bounces-402706-garchives=archives.gentoo.org@lists.gentoo.org>)
	id 1RT8fi-0006Ik-0p
	for garchives@archives.gentoo.org; Wed, 23 Nov 2011 08:59:14 +0000
Received: from pigeon.gentoo.org (localhost [127.0.0.1])
	by pigeon.gentoo.org (Postfix) with SMTP id 0356F21C02B;
	Wed, 23 Nov 2011 08:59:05 +0000 (UTC)
Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183])
	by pigeon.gentoo.org (Postfix) with ESMTP id BB07F21C02B
	for <gentoo-commits@lists.gentoo.org>; Wed, 23 Nov 2011 08:59:05 +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 3008B1B401C
	for <gentoo-commits@lists.gentoo.org>; Wed, 23 Nov 2011 08:59:05 +0000 (UTC)
Received: from localhost.localdomain (localhost [127.0.0.1])
	by pelican.gentoo.org (Postfix) with ESMTP id 4CD6C80042
	for <gentoo-commits@lists.gentoo.org>; Wed, 23 Nov 2011 08:59:04 +0000 (UTC)
From: "Paweł Hajdan" <phajdan.jr@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Content-type: text/plain; charset=UTF-8
Reply-To: gentoo-dev@lists.gentoo.org, "Paweł Hajdan" <phajdan.jr@gentoo.org>
Message-ID: <5a195bce432416b7486ec481d7dbb241c80fc412.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: 5a195bce432416b7486ec481d7dbb241c80fc412
Date: Wed, 23 Nov 2011 08:59:04 +0000 (UTC)
Precedence: bulk
List-Post: <mailto:gentoo-commits@lists.gentoo.org>
List-Help: <mailto:gentoo-commits+help@lists.gentoo.org>
List-Unsubscribe: <mailto:gentoo-commits+unsubscribe@lists.gentoo.org>
List-Subscribe: <mailto:gentoo-commits+subscribe@lists.gentoo.org>
List-Id: Gentoo Linux mail <gentoo-commits.gentoo.org>
X-BeenThere: gentoo-commits@lists.gentoo.org
Content-Transfer-Encoding: quoted-printable
X-Archives-Salt: e5aeccd0-f0cb-42ea-816c-f098255ddef3
X-Archives-Hash: 7675624901727e2974b9366ab29b7cc7

commit:     5a195bce432416b7486ec481d7dbb241c80fc412
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 23 08:57:03 2011 +0000
Commit:     Pawe=C5=82 Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Wed Nov 23 08:57:03 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=3Dproj/arch-tools.gi=
t;a=3Dcommit;h=3D5a195bce

Automatically file stabilization bugs.

---
 stabilization-candidates.py |   43 +++++++++++++++++++++++++++++++++++++=
+-----
 1 files changed, 38 insertions(+), 5 deletions(-)

diff --git a/stabilization-candidates.py b/stabilization-candidates.py
index 5d0c3f8..696ad9c 100755
--- a/stabilization-candidates.py
+++ b/stabilization-candidates.py
@@ -5,8 +5,10 @@
 import datetime
 import optparse
 import os.path
+import random
 import re
 import subprocess
+import urllib
=20
 import bugz.bugzilla
 from portage.package.ebuild.getmaskingstatus import getmaskingstatus
@@ -21,6 +23,7 @@ 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("-l", "--limit", dest=3D"limit", type=3D"int", defaul=
t=3D-1, help=3D"Limit of filed bugs. Default is no limit.")
 	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)")
=20
@@ -37,6 +40,7 @@ if __name__ =3D=3D "__main__":
 	bugzilla =3D MyBugz(url)
 	bugzilla.auth()
 =09
+	final_candidates =3D []
 	now =3D datetime.datetime.now()
 	for cp in portage.portdb.cp_all():
 		if options.category and not cp.startswith(options.category + "/"):
@@ -44,6 +48,7 @@ if __name__ =3D=3D "__main__":
 		best_stable =3D portage.versions.best(portage.portdb.match(cp))
 		if not best_stable:
 			continue
+		print 'Working on %s...' % cp
 		candidates =3D []
 		for cpv in portage.portdb.cp_list(cp):
 			# Only consider higher versions than best stable.
@@ -58,6 +63,12 @@ if __name__ =3D=3D "__main__":
 					break
 			if is_unstable:
 				continue
+		=09
+			# Eliminate 'live' packages. Obviously have some false positives,
+			# but it'd be much worse to miss something. There are variations
+			# like -r9999 or .9999 in the tree.
+			if '99' in cpv:
+				continue
=20
 			# Eliminate hard masked packages among others.
 			if getmaskingstatus(cpv) not in [[u'~%s keyword' % arch] for arch in =
options.arch]:
@@ -77,7 +88,6 @@ if __name__ =3D=3D "__main__":
 		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)
@@ -115,8 +125,31 @@ if __name__ =3D=3D "__main__":
 				continue
=20
 			metadata =3D MetaDataXML(os.path.join(cvs_path, 'metadata.xml'), '/us=
r/portage/metadata/herds.xml')
+			maintainer_split =3D metadata.format_maintainer_string().split(' ', 1=
)
+			maintainer =3D maintainer_split[0]
+			if len(maintainer_split) > 1:
+				other_maintainers =3D maintainer_split[1].split(',')
+			else:
+				other_maintainers =3D []
+			url =3D 'http://packages.gentoo.org/package/%s?arches=3Dlinux' % urll=
ib.quote(cp)
+			final_candidates.append((best_candidate, url, maintainer, other_maint=
ainers))
=20
-			# 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)
+	if options.limit !=3D -1:
+		final_candidates =3D random.sample(final_candidates, min(options.limit=
, len(final_candidates)))
+	for x in final_candidates:
+		best_candidate, url, maintainer, other_maintainers =3D x
+		description =3D ('Is it OK to stabilize =3D%s ?\n\n' % best_candidate =
+
+		               'If so, please CC arches and add STABLEREQ keyword.\n\n=
' +
+			       'Stabilization of this package has been repoman-checked on the=
 following arches: %s' % ', '.join(options.arch))
+		bug_id =3D bugzilla.post('Gentoo Linux',
+		                       'Keywording and Stabilization',
+				       'Please stabilize =3D%s' % best_candidate,
+				       description,
+				       url=3Durl,
+				       assigned_to=3Dmaintainer,
+				       cc=3Dother_maintainers,
+				       severity=3D'enhancement')
+		if bug_id =3D=3D 0:
+			print 'Submitting bug for %s failed. :-(' % best_candidate
+		else:
+			print 'Submitted bug #%d for %s. ;-)' % (bug_id, best_candidate)