public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Paweł Hajdan" <phajdan.jr@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/arch-tools:master commit in: /
Date: Sun,  7 Aug 2011 03:26:39 +0000 (UTC)	[thread overview]
Message-ID: <e8ad6147da9fec953419799d136dff1f05d378ea.phajdan.jr@gentoo> (raw)

commit:     e8ad6147da9fec953419799d136dff1f05d378ea
Author:     Pawel Hajdan, Jr <phajdan.jr <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  7 03:26:10 2011 +0000
Commit:     Paweł Hajdan <phajdan.jr <AT> gentoo <DOT> org>
CommitDate: Sun Aug  7 03:26:10 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/arch-tools.git;a=commit;h=e8ad6147

Add batch stabilization tool.

---
 batch-stabilize.py |  117 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 117 insertions(+), 0 deletions(-)

diff --git a/batch-stabilize.py b/batch-stabilize.py
new file mode 100755
index 0000000..8414f44
--- /dev/null
+++ b/batch-stabilize.py
@@ -0,0 +1,117 @@
+#!/usr/bin/env python
+# Copyright 2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import itertools
+import optparse
+import os
+import re
+import subprocess
+import sys
+
+import portage.versions
+
+BUG_REGEX = re.compile("[Bb]ug #?(\d+)")
+
+def print_and_log(message, log):
+	try:
+		print message
+		log.write(message)
+	finally:
+		log.flush()
+
+def run_command(args, cwd, log):
+	try:
+		log.write("Running %r in %s...\n" % (args, cwd))
+		cmd  = subprocess.Popen(args, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+		output = cmd.communicate()[0]
+		log.write("Finished with exit code %d\n" % cmd.returncode)
+		log.write(output)
+		return (cmd.returncode, output)
+	finally:
+		log.flush()
+
+if __name__ == "__main__":
+	parser = optparse.OptionParser()
+	parser.add_option("--arch", dest="arch", help="Gentoo arch to use, e.g. x86, amd64, ...")
+	parser.add_option("-i", "--input", dest="input_filename", default="package.keywords", help="Input filename for generated package.keywords file [default=%default]")
+	parser.add_option("--repo", dest="repo", help="Path to portage CVS repository")
+	parser.add_option("-v", "--verbose", dest="verbose", action="store_true", default=False)
+
+	(options, args) = parser.parse_args()
+	if not options.arch:
+		parser.error("--arch option is required")
+	if not options.input_filename:
+		parser.error("--input option is required")
+	if not options.repo:
+		parser.error("--repo option is required")
+	if args:
+		parser.error("unrecognized command-line args")
+	
+	with open(options.input_filename, "r") as input_file:
+		stabilization_list = []
+		bug_id = -1
+		for line in input_file:
+			if line == "\n":
+				continue
+
+			if line.startswith("#"):
+				match = BUG_REGEX.search(line, re.IGNORECASE)
+				if not match:
+					print 'Ignoring comment line [%s]...' % line
+					continue
+				else:
+					bug_id = int(match.group(1))
+				continue
+
+			if bug_id == -1:
+				print 'Could not recognize bug id'
+				sys.exit(1)
+
+			if not line.endswith("\n"):
+				line += "\n"
+			cpv = line[1:-1]
+			p = portage.versions.catsplit(cpv)[1]
+			pn = portage.versions.pkgsplit(cpv)[0]
+			ebuild_name = p + ".ebuild"
+			stabilization_list.append((pn, ebuild_name, bug_id))
+
+		# Sanity check.
+		success = True
+		for pn, ebuild_name, bug_id in stabilization_list:
+			ebuild_path = os.path.join(options.repo, pn, ebuild_name)
+			if not os.path.exists(ebuild_path):
+				print '%s: file does not exist' % ebuild_path
+				success = False
+		if not success:
+			print 'Sanity check failed. Please make sure your CVS repo is up to date (cvs up).'
+			sys.exit(1)
+
+		with open('batch-stabilize.log', 'w') as log_file:
+			for pn, ebuild_name, bug_id in stabilization_list:
+				commit_message = "%s stable wrt bug #%d" % (options.arch, bug_id)
+				cvs_path = os.path.join(options.repo, pn)
+				print_and_log('Working in %s...' % cvs_path, log_file)
+				if run_command(["cvs", "up"], cvs_path, log_file)[0] != 0:
+					print '!!! cvs up failed'
+					sys.exit(1)
+				if run_command(["ekeyword", options.arch, ebuild_name], cvs_path, log_file)[0] != 0:
+					print '!!! ekeyword failed'
+					sys.exit(1)
+				return_code, output = run_command(["cvs", "diff"], cvs_path, log_file)
+				# It seems that cvs diff returns 1 if there are differences.
+				if return_code == 0 and not output:
+					print_and_log('Seems already keyworded, skipping.', log_file)
+					continue
+				if run_command(["echangelog", commit_message], cvs_path, log_file)[0] != 0:
+					print '!!! ekeyword failed'
+					sys.exit(1)
+				if run_command(["repoman", "manifest"], cvs_path, log_file)[0] != 0:
+					print '!!! repoman manifest failed'
+					sys.exit(1)
+				if run_command(["repoman", "full"], cvs_path, log_file)[0] != 0:
+					print '!!! repoman full failed'
+					sys.exit(1)
+				if run_command(["repoman", "commit", "-m", commit_message], cvs_path, log_file)[0] != 0:
+					print '!!! repoman full failed'
+					sys.exit(1)



             reply	other threads:[~2011-08-07  3:26 UTC|newest]

Thread overview: 59+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-07  3:26 Paweł Hajdan [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-07-10 20:29 [gentoo-commits] proj/arch-tools:master commit in: / Paweł Hajdan
2017-07-09 14:42 Paweł Hajdan
2015-01-05 14:41 Paweł Hajdan
2015-01-05 14:41 Paweł Hajdan
2015-01-05 14:41 Paweł Hajdan
2014-06-14  9:47 Paweł Hajdan
2014-04-07 12:40 Samuli Suominen
2014-02-12  7:06 Paweł Hajdan
2013-06-22 15:05 Paweł Hajdan
2013-06-22 14:57 Paweł Hajdan
2013-05-19 23:35 Paweł Hajdan
2013-03-11 21:56 Paweł Hajdan
2013-02-28  4:50 Paweł Hajdan
2013-02-28  4:50 Paweł Hajdan
2012-10-16 16:54 Paweł Hajdan
2012-10-16 16:54 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:03 Paweł Hajdan
2012-10-08 16:02 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-08-01 11:08 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-08-01  7:28 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-06-04  9:18 [gentoo-commits] proj/arch-tools:new-pybugz " Paweł Hajdan
2012-10-08 16:03 ` [gentoo-commits] proj/arch-tools:master " Paweł Hajdan
2012-03-27 15:26 Paweł Hajdan
2012-03-09 11:49 Paweł Hajdan
2012-03-09 11:49 Paweł Hajdan
2012-02-02 16:48 Paweł Hajdan
2012-01-27 14:55 Paweł Hajdan
2012-01-21 17:05 Paweł Hajdan
2011-12-14  7:23 Paweł Hajdan
2011-12-06 11:14 Paweł Hajdan
2011-12-01 18:56 Paweł Hajdan
2011-12-01 18:47 Paweł Hajdan
2011-12-01 18:47 Paweł Hajdan
2011-11-30 17:38 Paweł Hajdan
2011-11-23  8:59 Paweł Hajdan
2011-11-23  8:59 Paweł Hajdan
2011-11-21  8:34 Paweł Hajdan
2011-11-03 11:00 Paweł Hajdan
2011-10-22  8:18 Paweł Hajdan
2011-10-21 15:15 Paweł Hajdan
2011-10-18 14:05 Paweł Hajdan
2011-10-16  3:51 Paweł Hajdan
2011-10-13 21:59 Paweł Hajdan
2011-10-04 21:46 Paweł Hajdan
2011-09-19  3:09 Paweł Hajdan
2011-06-05 16:16 Paweł Hajdan
2011-06-02 15:41 Paweł Hajdan
2011-06-02 15:38 Paweł Hajdan
2011-05-25 19:51 Paweł Hajdan
2011-05-25 10:32 Paweł Hajdan
2011-05-22 15:31 Paweł Hajdan
2011-05-22 15:16 Paweł Hajdan
2011-05-22 13:36 Paweł Hajdan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e8ad6147da9fec953419799d136dff1f05d378ea.phajdan.jr@gentoo \
    --to=phajdan.jr@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox