3 # Copyright (C) Jeremiah C. Foster 2009, based on:
4 # Lintian -- Debian package checker
5 # Copyright (C) 1998 Christian Schwarz and Richard Braakman
9 minimae - Executes some tests on a gzipped tarball, looking for
10 debian packaging files and conventions. minimae gets a json string
11 as input and parses that string to do its checks and find resources.
17 This document describes minimae version 2.0
21 Maemian is the maemo version of lintian - a policy checker designed to
22 assure the quality of a package uploaded into the maemo.org repositories.
23 The goal of maemian is to improve quality by checking that the maemo
24 packaging policy is followed. In order to do that it reads files in the
25 tarball that has been uploaded to the maemo repositories.
36 use Test::More tests => 8;
37 use IPC::System::Simple qw/ capture /;
45 my $tarball = $ARGV[0]; # Orignal tarball
46 my $repo = RepoUtils->new();
47 $repo->copy_file($tarball, "lab/"); # copy the tarball to the lab
48 my $package_name = basename $tarball;
50 my $tar = Archive::Tar->new;
51 $tar->read("lab/$package_name",1);
52 if ($package_name =~ /orig.tar.gz/) {
53 $package_name =~ s/.orig.tar.gz$//; # Remove suffixes
56 $package_name =~ s/.tar.gz$//; # Remove suffixes
58 $package_name =~ tr/_/-/; # translate underscore into dash
59 $package_name =~ s/-[\d]$//; # trim package version
60 $package_name =~ s/-.?maemo.$//; # trim package version
61 chdir("lab/"); # We're in /lab now!
62 $tar->extract(); # extracted tarball now in lab/
64 my $changelog_file = "$package_name/debian/changelog";
65 my $copyright_file = "$package_name/debian/copyright";
66 my $control_file = "$package_name/debian/control";
69 my $file_type = capture("file -i $control_file");
70 ok(($file_type), "File type defined.");
71 my ($name, $content, $charset) = split / /, $file_type;
74 when ("charset=us-ascii") {
75 ok($charset, 'charset is ASCII.');
77 when ("charset=utf-8") {
78 ok($charset, 'charset is UTF-8');
81 not_ok($charset, "$charset");
82 die qq(Unknown charset for $charset.);
86 # Each chunk is a discreet package
87 my @chunks = slurp $control_file, {irs => qr/\n\n/xms};
88 print map { $_ . "\n" } @chunks;
91 my @fields = slurp $control_file, {irs => qr/\n\n/xms};
92 diag((grep /XB-Maemo-Icon/, split /\n/, $fields[-1]), ' Found icon in control file.');
93 my @arches = grep /Architecture/, split /\n/, $fields[-1];
95 ok((grep /Architecture/, split /\n/, $fields[-1]), "Arches: $arches[-1]");
96 ok((grep /XSBC/, @fields), 'Maemo specific maintainer field');
97 my $package = grep /Package:/, split /\n/, $fields[-1];
98 ok($package !~ /[M|m]aemo/, 'No potential copyright clash with maemo name');
100 # Check copyright file
101 ok(-s $copyright_file, 'Copyright file exists and is non-empty');
102 @fields = slurp $copyright_file, {irs => qr/\n\n/xms};
103 my ($file_name, $type) = split / /, capture("file -i $copyright_file");
104 ok($file_type !~ /application\/x-gzip/, 'Copyright not compressed.');
105 my @copylines = map { $_ } grep /copyright|\(C\)/, @fields;
106 ok((scalar @copylines > 1), 'Found copyright assignment.');
112 1; # Nothing to see here, move along.