Added some code to peer into a data structure in Maemian/Schedule.pm. Also added the
[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 VERSION
12
13 This document describes minimae version 0.1
14
15 =head1 PURPOSE
16
17 Maemian is the maemo version of lintian - a policy checker designed to
18 assure the quality of a package uploaded into the maemo.org repositories.
19 The goal of maemian is to improve quality by checking that the maemo
20 packaging policy is followed. In order to do that it reads files in the
21 uploaded deb. Currently maemian only looks at the .dsc file and tries to
22 ascertain who uploaded it, and if they used the correct email address.
23
24 =head1 SYNOPSIS
25
26     # Check a debian description file
27     minimae -i file.dsc
28
29 =cut
30
31 use strict;
32 use warnings;
33 use Getopt::Long;
34 use Pod::Usage;
35 use Carp;
36 use lib qw(/home/jeremiah/maemian/lib/);
37 use Maemian::Output;
38 use Maemian::Schedule;
39
40 my $LINTIAN_LAB = "/home/jeremiah/maemian/lab";
41
42 # --- Command line options
43 my $inputfile;                     # --- A file passed on the command line
44 my ($help, $verbose);
45
46 GetOptions
47   (
48    'help' => \$help,
49    'verbose' => \$verbose,
50    'inputfile|i=s' => \$inputfile,
51   );
52
53 # --- Process Command line options
54 pod2usage() if $help;
55 pod2usage() if not $inputfile;
56
57 # --- Output settings
58 my $out = new Maemian::Output;
59 if ($verbose) {
60   $out->verbose(1);
61   $out->v_msg("Verbose on");
62
63 else {
64   $out->quiet(0);
65 }
66 $out->color("auto");
67
68 sub file_tests {
69   use File::Basename;
70   use Perl6::Slurp;
71   my ($filename, $path);
72   my $file = shift;
73   if (-r $file) {
74     ($filename, $path) = fileparse($file);
75   }
76   else {
77     die "Cannot read $file\n";
78   }
79   # --- maemo is a trademarked term
80   if ($filename =~ /maemo/) {
81     $out->v_msg("Any use of the word \"maemo\" in the package name (not package version) is subject to trademark.");
82   }
83   $out->v_msg("File name is $filename");
84   $out->v_msg("Path is $path");
85
86   # We push the entire file into an array
87   # If the file is signed, the sig is separated by a blank line
88   my @control = slurp $file, { irs => qr/\n\n/xms };
89   my @lines = split /\n/, $control[1];
90   print map { $_ } grep /Maintainer/, @lines;
91 }
92
93 if ($inputfile) {
94   file_tests($inputfile);
95 } else {
96   croak "No input file found: $!\n";
97 }
98
99 my $schedule = new Maemian::Schedule(verbose => $verbose);
100 # .deb file?
101 if ($inputfile =~ /\.deb$/) {
102   $out->v_msg("Lab is $LINTIAN_LAB");
103
104   # schedule is a hash containing two hashes followed by an array
105   $schedule->add_deb('b', $inputfile)
106     or warning("$inputfile is a zero-byte file, skipping");
107 }
108
109
110
111
112 1;