[33589] trunk/base/portmgr/jobs/portfile_lint.pl

wsiegrist at apple.com wsiegrist at apple.com
Wed Jan 30 16:58:07 PST 2008


Revision: 33589
          http://trac.macosforge.org/projects/macports/changeset/33589
Author:   wsiegrist at apple.com
Date:     2008-01-30 16:58:06 -0800 (Wed, 30 Jan 2008)

Log Message:
-----------
new script to run during repo post-commit for running lint on portfiles and email maintainers with error messages

Added Paths:
-----------
    trunk/base/portmgr/jobs/portfile_lint.pl

Added: trunk/base/portmgr/jobs/portfile_lint.pl
===================================================================
--- trunk/base/portmgr/jobs/portfile_lint.pl	                        (rev 0)
+++ trunk/base/portmgr/jobs/portfile_lint.pl	2008-01-31 00:58:06 UTC (rev 33589)
@@ -0,0 +1,75 @@
+#!/opt/local/bin/perl -w
+
+####
+# Run "port lint" for all Portfiles changed in a given revision
+# Created by William Siegrist,
+# e-mail: wsiegrist at apple.com
+# $Id$
+####
+
+use strict;
+use Mail::Sendmail;
+
+my $REPOPATH = "/svn/repositories/macports/";
+my $SVNLOOK = "/opt/local/bin/svnlook";
+my $PORTCMD = "/opt/local/bin/port";
+
+my $rev = $ARGV[0] or usage();
+my @changes = `$SVNLOOK changed $REPOPATH -r $rev`;
+
+foreach my $change (@changes) {
+    if ($change =~ /Portfile/) { 
+	# remove svn status and whitespace
+	chop($change);
+	$change =~ s/\w\s+([\/\w]+)/$1/g; 
+	# extract the portname from parent dir of Portfile
+	my $port = $change;
+	$port =~ s/^.*\/([^\/]+)\/Portfile$/$1/g;
+
+	# test the port
+	_lint($port);
+    }
+}
+
+
+#
+# Subroutines
+#
+
+sub _lint {
+    my ($port) = @_; 
+    my $errors = `sudo $PORTCMD -q lint $port`;
+    if ($errors) {
+	my $maintainers = `$PORTCMD -q info --maintainer $port`;
+	# strip everything but the email addresses
+	$maintainers =~ s/maintainer: //;
+	$maintainers =~ s/openmaintainer\@macports.org//;
+	$maintainers =~ s/nomaintainer\@macports.org//;
+	chop($maintainers);
+
+	_mail($port, $maintainers, $errors);
+    }
+}
+
+sub _mail {
+    my ($port, $maintainers, $errors) = @_;
+
+    my %mail = (
+	     To => $maintainers,
+	     From => 'noreply at macports.org',
+	     Subject => "[MacPorts Lint] Portfile Lint Errors for: $port",
+	     Message => "Portfile: $port \n\n\n Errors: $errors \n\n",
+	     smtp => 'relay.apple.com',
+	     );
+
+    sendmail(%mail) or die $Mail::Sendmail::error;
+}
+
+sub usage {
+	print "usage: portfile_lint.pl <rev>\n";
+	exit();
+}
+
+
+
+


Property changes on: trunk/base/portmgr/jobs/portfile_lint.pl
___________________________________________________________________
Name: svn:executable
   + *

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.macosforge.org/pipermail/macports-changes/attachments/20080130/56e28b64/attachment.html


More information about the macports-changes mailing list