A working minimae, tested here on the testing machine.
[maemian] / minimae
1 #!/usr/bin/perl
2
3 # Copyright (C) Jeremiah C. Foster 2009, based on:
4 #   Lintian -- Debian package checker
5 # Copyright (C) 1998 Christian Schwarz and Richard Braakman
6
7 =head1 NAME
8
9 minimae - A small, cuddly version of maemian
10
11 =head1 PURPOSE
12
13 Maemian is the maemo version of lintian - a policy checker designed to
14 assure the quality of a package uploaded into the maemo.org repositories.
15 The goal of maemian is to improve quality by checking that the maemo
16 packaging policy is followed. In order to do that it reads files in the
17 uploaded deb. Currently maemian only looks at the .dsc file and tries to
18 ascertain who uploaded it, and if they used the correct email address.
19
20 =head1 SYNOPSIS
21
22     # Check a debian description file
23     minimae -i file.dsc
24
25 =cut
26
27 use strict;
28 use warnings;
29 use Getopt::Long;
30 use Pod::Usage;
31 use Carp;
32 use lib qw(/home/jeremiah/maemian/lib/);
33 use Maemian::Output;
34
35 # --- Command line options
36 my $inputfile;                     # --- A file passed on the command line
37 my ($help, $verbose);
38
39 GetOptions
40   (
41    'help' => \$help,
42    'verbose' => \$verbose,
43    'inputfile|i=s' => \$inputfile,
44   );
45
46 # --- Process Command line options
47 pod2usage() if $help;
48 pod2usage() if not $inputfile;
49
50 # --- Output settings.
51 my $out = new Maemian::Output;
52 if ($verbose) {
53   $out->verbose(1);
54   $out->v_msg("Verbose on");
55
56 else {
57   $out->quiet(0);
58 }
59 $out->color("auto");
60
61 sub file_tests {
62   use File::Basename;
63   use Perl6::Slurp;
64   my ($filename, $path);
65   my $file = shift;
66   if (-r $file) {
67     ($filename, $path) = fileparse($file);
68   }
69   else {
70     die "Cannot read $file\n";
71   }
72   # --- maemo is a trademarked term
73   if ($filename =~ /maemo/) {
74     $out->v_msg("Any use of the word \"maemo\" in the package name (not package version) is subject to trademark.");
75   }
76   $out->v_msg("File name is $filename");
77   $out->v_msg("Path is $path");
78
79   # We push the entire file into an array
80   # If the file is signed, the sig is separated by a blank line
81   my @control = slurp $file, { irs => qr/\n\n/xms };
82   my @lines = split /\n/, $control[1];
83   print map { $_ } grep /Maintainer/, @lines;
84 }
85
86 if ($inputfile) {
87   file_tests($inputfile);
88 } else {
89   croak "No input file found: $!\n";
90 }
91
92
93 1;