Removing frog.
[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     # Check a deb
30     minimae -i file.deb
31
32 =cut
33
34 use strict;
35 use warnings;
36 use Getopt::Long;
37 use Pod::Usage;
38 use Carp;
39 use lib qw(/home/jeremiah/maemian/lib/);
40 use Maemian::Output;
41 use Maemian::Schedule;
42
43 my $LINTIAN_LAB = "/home/jeremiah/maemian/lab";
44
45 # --- Command line options
46 my $pkg_mode = 'a';             # auto -- automatically search for
47                                 # binary and source pkgs
48 my $inputfile;                  # --- A file passed on the command line
49 my ($help, $verbose, );
50
51 GetOptions
52   (
53    'help' => \$help,
54    'verbose' => \$verbose,
55    'inputfile|i=s' => \$inputfile,
56   );
57
58 # --- Process Command line options
59 pod2usage(1) if $help;
60
61 # --- Output settings
62 my $out = new Maemian::Output;
63 if ($verbose) {
64   $out->verbose(1);
65   $out->v_msg("Verbose on");
66
67 else {
68   $out->quiet(0);
69 }
70 $out->color("auto");
71
72 sub file_tests {
73   use File::Basename;
74   use Perl6::Slurp;
75   my ($filename, $path);
76   my $file = shift;
77   if (-r $file) {
78     ($filename, $path) = fileparse($file);
79   }
80   else {
81     die "Cannot read $file\n";
82   }
83   # --- maemo is a trademarked term
84   if ($filename =~ /maemo/) {
85     $out->v_msg("Any use of the word \"maemo\" in the package name (not package version) is subject to trademark.");
86   }
87   $out->v_msg("File name is $filename");
88   $out->v_msg("Path is $path");
89
90   # We push the entire file into an array
91   # If the file is signed, the sig is separated by a blank line
92   my @control = slurp $file, { irs => qr/\n\n/xms };
93   my @lines;
94   if ($#control > 1) {
95     @lines = split /\n/, $control[1];
96   }
97   else {
98     @lines = split /\n/, $control[0];
99   }
100   print map { $_ } grep /Maintainer/, @lines;
101 }
102
103 if ($inputfile) {
104   file_tests($inputfile);
105 } else {
106   croak "No input file found: $!\n";
107 }
108
109 my $schedule = new Maemian::Schedule(verbose => $verbose);
110 # .deb file?
111 if ($inputfile =~ /\.deb$/) {
112   $out->v_msg("Lab is $LINTIAN_LAB");
113
114   # schedule is a hash containing two hashes followed by an array
115   $schedule->add_deb('b', $inputfile)
116     or warning("$inputfile is a zero-byte file, skipping");
117 }
118
119
120
121
122 1;