This file is indexed.

/usr/share/lintian/checks/ocaml is in lintian 2.5.6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
# ocaml -- lintian check script -*- perl -*-
#
# Copyright © 2009 Stéphane Glondu
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, you can find it on the World Wide
# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
# MA 02110-1301, USA.

package Lintian::ocaml;

use strict;
use warnings;

use File::Basename;
use Lintian::Collect::Binary ();
use Lintian::Tags qw(tag);
use Lintian::Relation ();

# The maximum number of *.cmi files to show individually.
our $MAX_CMI = 3;

sub run {

my $pkg = shift;
my $type = shift;
my $info = shift;

# Collect information about .a files from ar-info dump
my %provided_o;
open ARINFO, '<', 'ar-info';
while (<ARINFO>) {
    chomp;
    if (/^\.\/([^:]+): (.*)$/) {
        my $filename = $1;
        my $dirname = dirname($filename);
        foreach (split(m/ /o, $2)) {
            # Note: a .o may be legitimately in several different .a
            $provided_o{"$dirname/$_"} = $filename;
        }
    }
}
close ARINFO;

# is it a library package?
my $is_lib_package = 0;
if ($pkg =~ /^lib/) {
    $is_lib_package = 1;
}

# is it a development package?
my $is_dev_package = 0;
if ($pkg =~ /(-dev|^camlp[45](-extra)?|^ocaml(-nox|-interp|-compiler-libs)?)$/) {
    $is_dev_package = 1;
}

# for libraries outside /usr/lib/ocaml
my $outside_number = 0;
my $outside_prefix;

# dangling .cmi files (we show only $MAX_CMI of them)
my $cmi_number = 0;

# dev files in nondev package
my $dev_number = 0;
my $dev_prefix;

# does the package provide a META file?
my $has_meta = 0;

foreach my $file (@{$info->sorted_file_info}) {
    my $fileinfo = $info->file_info->{$file};

    # For each .cmxa file, there must be a matching .a file (#528367)
    $_ = $file;
    if (s/\.cmxa$/.a/ && !(exists $info->file_info->{$_})) {
        tag 'ocaml-dangling-cmxa', $file;
    }

    # For each .cmxs file, there must be a matching .cma or .cmo file
    # (at least, in library packages)
    if ($is_lib_package) {
        $_ = $file;
        if (s/\.cmxs$/.cm/
            && !(exists $info->file_info->{"${_}a"})
            && !(exists $info->file_info->{"${_}o"})) {
            tag 'ocaml-dangling-cmxs', $file;
        }
    }

    # The .cmx counterpart: for each .cmx file, there must be a
    # matching .o file, which can be there by itself, or embedded in a
    # .a file in the same directory
    $_ = $file;
    if (s/\.cmx$/.o/
        && !(exists $info->file_info->{$_})
        && !(exists $provided_o{$_})) {
        tag 'ocaml-dangling-cmx', $file;
    }

    # $somename.cmi should be shipped with $somename.mli or $somename.ml
    $_ = $file;
    if ($is_dev_package && s/\.cmi$/.ml/
        && !(exists $info->file_info->{"${_}i"})
        && !(exists $info->file_info->{$_})) {
        $cmi_number++;
        if ($cmi_number <= $MAX_CMI) {
            tag 'ocaml-dangling-cmi', $file;
        }
    }

    # non-dev packages should not ship .cmi, .cmx or .cmxa files
    if ($file =~ m/\.cm(i|xa?)$/) {
        $dev_number++;
        if (defined $dev_prefix) {
            chop $dev_prefix while ($file !~ m@^$dev_prefix@);
        } else {
            $dev_prefix = $file;
        }
    }

    # $somename.cmo should usually not be shipped with $somename.cma
    $_ = $file;
    if (s/\.cma$/.cmo/ && exists $info->file_info->{$_}) {
        tag 'ocaml-stray-cmo', $file;
    }

    # development files outside /usr/lib/ocaml (.cmi, .cmx, .cmxa)
    # .cma, .cmo and .cmxs are excluded because they can be plugins
    if ($file =~ m/\.cm(i|xa?)$/ && $file !~ m@^usr/lib/ocaml/@) {
        $outside_number++;
        if (defined $outside_prefix) {
            chop $outside_prefix while ($file !~ m@^$outside_prefix@);
        } else {
            $outside_prefix = $file;
        }
    }

    # If there is a META file, ocaml-findlib should be at least suggested.
    $has_meta = 1 if $file =~ m@^usr/lib/ocaml/(.+/)?META(\..*)?$@;
}

if ($is_dev_package) {
    # summary about .cmi files
    if ($cmi_number > $MAX_CMI) {
        my $plural = ($cmi_number - $MAX_CMI == 1) ? '' : 's';
        tag 'ocaml-dangling-cmi', ($cmi_number - $MAX_CMI),
            "more file$plural not shown";
    }
    # summary about /usr/lib/ocaml
    if ($outside_number) {
        $outside_prefix = dirname($outside_prefix);
        my $plural = ($outside_number == 1) ? '' : 's';
        tag 'ocaml-dev-file-not-in-usr-lib-ocaml',
            "$outside_number file$plural in $outside_prefix";
    }
    if ($has_meta) {
        my $depends = $info->relation('all');
        tag 'ocaml-meta-without-suggesting-findlib'
            unless $depends->implies('ocaml-findlib');
    }
} else {
    # summary about dev files
    if ($dev_number > 0) {
        $dev_prefix = dirname($dev_prefix);
        my $plural = ($dev_number == 1) ? '' : 's';
        tag 'ocaml-dev-file-in-nondev-package',
            "$dev_number file$plural in $dev_prefix";
    }
}

}

1;

# Local Variables:
# indent-tabs-mode: nil
# cperl-indent-level: 4
# End:
# vim: syntax=perl sw=4 sts=4 sr et