Removed upstream dir
[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 binary .deb
30     minimae -b package_name.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    'binary|b' => \&record_pkgmode,
57   );
58
59 # Record what type of data is specified
60 # Options: -b|--binary, -s|--source, --udeb
61 sub record_pkgmode {
62   print "in record_pkgmode\n";
63   $pkg_mode = 'b' if $_[0] eq 'binary';
64   $pkg_mode = 's' if $_[0] eq 'source';
65   $pkg_mode = 'u' if $_[0] eq 'udeb';
66 }
67
68
69 # --- Process Command line options
70 pod2usage(1) if $help;
71
72 # --- Output settings
73 my $out = new Maemian::Output;
74 if ($verbose) {
75   $out->verbose(1);
76   $out->v_msg("Verbose on");
77
78 else {
79   $out->quiet(0);
80 }
81 $out->color("auto");
82
83 sub file_tests {
84   use File::Basename;
85   use Perl6::Slurp;
86   my ($filename, $path);
87   my $file = shift;
88   if (-r $file) {
89     ($filename, $path) = fileparse($file);
90   }
91   else {
92     die "Cannot read $file\n";
93   }
94   # --- maemo is a trademarked term
95   if ($filename =~ /maemo/) {
96     $out->v_msg("Any use of the word \"maemo\" in the package name (not package version) is subject to trademark.");
97   }
98   $out->v_msg("File name is $filename");
99   $out->v_msg("Path is $path");
100
101   # We push the entire file into an array
102   # If the file is signed, the sig is separated by a blank line
103   my @control = slurp $file, { irs => qr/\n\n/xms };
104   my @lines = split /\n/, $control[1];
105   print map { $_ } grep /Maintainer/, @lines;
106 }
107
108 if ($inputfile) {
109   file_tests($inputfile);
110 } else {
111   croak "No input file found: $!\n";
112 }
113
114 my $schedule = new Maemian::Schedule(verbose => $verbose);
115 # .deb file?
116 if ($inputfile =~ /\.deb$/) {
117   $out->v_msg("Lab is $LINTIAN_LAB");
118
119   # schedule is a hash containing two hashes followed by an array
120   $schedule->add_deb('b', $inputfile)
121     or warning("$inputfile is a zero-byte file, skipping");
122 }
123
124
125
126
127 1;