Projects
New Ticket     Wiki     Browse Source     Timeline     Roadmap     Bug Reports     Search

root/trunk/base/portmgr/jobs/portfile_lint.pl

Revision 36285, 2.3 KB (checked in by eridius@…, 9 months ago)

Make the auto-lint script catch errors too, not just warnings

  • Property svn:executable set to *
Line 
1#!/opt/local/bin/perl -w
2
3####
4# Run "port lint" for all Portfiles changed in a given revision
5# Created by William Siegrist,
6# e-mail: wsiegrist@apple.com
7# $Id$
8####
9
10use strict;
11use Mail::Sendmail;
12
13my $REPOPATH = "/svn/repositories/macports/";
14my $REPOHOST = "http://svn.macosforge.org/repository/macports";
15my $SVNLOOK = "/opt/local/bin/svnlook";
16my $PORTCMD = "/opt/local/bin/port";
17my $SVN = "/opt/local/bin/svn -Nq --non-interactive";
18my $MKDIR = "/bin/mkdir -p";
19
20
21my $rev = $ARGV[0] or usage();
22my $TMPROOT = "/tmp/mp_lint/$rev";
23
24my @changes = `$SVNLOOK changed $REPOPATH -r $rev`;
25
26my $author = `$SVNLOOK author $REPOPATH -r $rev`;
27chomp($author);
28
29_log("Rev: $rev");
30
31foreach my $change (@changes) {
32    if ($change =~ /Portfile/) { 
33        # remove svn status and whitespace
34        chop($change);
35        $change =~ s/\w\s+([\/\w]+)/$1/g; 
36        # extract the portname from parent dir of Portfile
37        my $port = $change;
38        $port =~ s/^.*\/([^\/]+)\/Portfile$/$1/g;
39
40        # get the group directory
41        my $group = $change;
42        $group =~ s/^.*\/([^\/]+)\/[^\/]+\/Portfile$/$1/g;     
43
44        _log("Port: $group / $port ");
45
46        # make a temporary work area
47        `$MKDIR $TMPROOT/$group/$port`;
48        chdir("$TMPROOT/$group/$port") or die("Failed to change dir for port: $port"); 
49        `$SVN co $REPOHOST/trunk/dports/$group/$port/ .`;
50        # test the port
51        _lint($port);
52    }
53}
54
55
56#
57# Subroutines
58#
59
60sub _lint {
61    my ($port) = @_; 
62    my $errors = `$PORTCMD -qc lint 2>&1`;
63
64    if ($errors) {
65        _log("Error: $errors ");
66        my $maintainers = `$PORTCMD -q info --maintainer $port`;
67        # strip everything but the email addresses
68        $maintainers =~ s/maintainer: //;
69        $maintainers =~ s/openmaintainer\@macports.org//;
70        $maintainers =~ s/nomaintainer\@macports.org//;
71        chop($maintainers);
72
73        _log("Maintainers: $maintainers ");
74
75        _mail($port, $maintainers, $errors);
76    }
77}
78
79sub _mail {
80    my ($port, $maintainers, $errors) = @_;
81
82    my %mail = (
83             To => "$author, $maintainers",
84             From => 'noreply@macports.org',
85             Subject => "[$rev] $port Lint Report",
86             Message => "Portfile: $port\n\n\n$errors \n\n",
87             smtp => 'relay.apple.com',
88             );
89
90    _log("Mailto: $maintainers ");
91
92    sendmail(%mail) or die $Mail::Sendmail::error;
93}
94
95sub _log {
96        my ($errors) = @_;
97        open(LOG, ">>$TMPROOT/errors") or return;
98        print LOG "$errors\n";
99        close(LOG);
100}
101
102sub usage {
103        print "usage: portfile_lint.pl <rev>\n";
104        exit();
105}
Note: See TracBrowser for help on using the browser.