Typo
[maemian] / maemian
1 #!/usr/bin/perl
2
3 # Copyright (C) Jeremiah C. Foster 2009, based on:
4
5 #   Lintian -- Debian package checker
6 # Copyright (C) 1998 Christian Schwarz and Richard Braakman
7
8 # This program is free software.  It is distributed under the terms of
9 # the GNU General Public License as published by the Free Software
10 # Foundation; either version 2 of the License, or (at your option) any
11 # later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program.  If not, you can find it on the World Wide
20 # Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
21 # Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
22 # MA 02110-1301, USA.
23
24 =head1 NAME
25
26 maemian - Maemo package checker
27
28 =head1
29
30 Maemian is the maemo version of lintian - a policy checker designed to
31 assure the quality of a package uploaded into the maemo.org repositories.
32 The goal of maemian is to improve quality by checking that the maemo
33 packaging policy is followed. In order to do that it reads files in the
34 uploaded deb. Currently maemian only looks at the .dsc file and tries to
35 ascertain who uploaded it, and if they used the correct email address.
36
37 =head1 EXAMPLE
38
39 maemian -i file.dsc
40
41 =cut
42
43 use strict;
44 use warnings;
45 use Getopt::Long;
46 use Carp;
47
48 unshift @INC, "/home/jeremiah/maemian/lib";
49 require Maemian::Output;
50 my $lintout = new Maemian::Output;
51
52 # --- Command line options
53 my $inputfile;             # --- A file passed to maemian
54 GetOptions ("inputfile|i=s" => \$inputfile);
55
56 sub file_tests {
57   use File::Basename;
58   my $path = shift;
59   if (-r $path) {
60     my ($filename, $dirs) = fileparse($path);
61     # --- maemo is a trademarked term
62     if ($filename =~ /maemo/) {
63       print "W: Any use of the word \"maemo\" is subject to trademark.\n";
64     }
65     # --- Open file into an array
66     open my $file, '<', $path or die "Cannot open file: $!\n";
67     my @lines = <$file>;
68     close $file;
69
70     my ($field, $maintainer) = map { split /: / } grep /Maintainer/, @lines;
71     chomp($maintainer);
72     if ($maintainer =~ /(ubuntu|debian)/i) {
73       print "W: Maintainer email address ($maintainer) might be the same as upstream.\n";
74     }
75     else {
76       print "N: $maintainer\n";
77     }
78     if (grep /BEGIN PGP SIGNED MESSAGE/, @lines) {
79       print "N: $filename is signed\n";
80     }
81     # print "\n$dirs\n$filename\n";
82   }
83   else {
84     croak "File not readable: $!\n";
85   }
86 }
87
88 if ($inputfile) {
89   file_tests($inputfile);
90 } else {
91   croak "No input file found: $!\n";
92 }