This file is indexed.

/usr/bin/dpkg-scanpackages is in dpkg-dev 1.17.5ubuntu5.6.

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

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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
#!/usr/bin/perl
#
# dpkg-scanpackages
#
# Copyright © 2006-2012 Guillem Jover <guillem@debian.org>
#
# 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, see <https://www.gnu.org/licenses/>.

use warnings;
use strict;

use IO::Handle;
use IO::File;
use Getopt::Long qw(:config posix_default bundling no_ignorecase);

use Dpkg ();
use Dpkg::Gettext;
use Dpkg::ErrorHandling;
use Dpkg::Util qw(:list);
use Dpkg::Control;
use Dpkg::Version;
use Dpkg::Checksums;
use Dpkg::Compression::FileHandle;
use Dpkg::IPC;

textdomain('dpkg-dev');

# Do not pollute STDOUT with info messages
report_options(info_fh => \*STDERR);

my (@samemaint, @changedmaint);
my @spuriousover;
my %packages;
my %overridden;

my %options = (help            => sub { usage(); exit 0; },
	       version         => \&version,
	       type            => undef,
	       arch            => undef,
	       multiversion    => 0,
	       'extra-override'=> undef,
               medium          => undef,
	      );

my @options_spec = (
    'help|?',
    'version',
    'type|t=s',
    'arch|a=s',
    'multiversion|m!',
    'extra-override|e=s',
    'medium|M=s',
);

sub version {
    printf _g("Debian %s version %s.\n"), $Dpkg::PROGNAME, $Dpkg::PROGVERSION;
    exit;
}

sub usage {
    printf _g(
"Usage: %s [<option>...] <binary-path> [<override-file> [<path-prefix>]] > Packages

Options:
  -t, --type <type>        scan for <type> packages (default is 'deb').
  -a, --arch <arch>        architecture to scan for.
  -m, --multiversion       allow multiple versions of a single package.
  -e, --extra-override <file>
                           use extra override file.
  -M, --medium <medium>    add X-Medium field for dselect multicd access method
  -?, --help               show this help message.
      --version            show the version.
"), $Dpkg::PROGNAME;
}

sub load_override
{
    my $override = shift;
    my $comp_file = Dpkg::Compression::FileHandle->new(filename => $override);

    while (<$comp_file>) {
	s/\#.*//;
	s/\s+$//;
	next unless $_;

	my ($p, $priority, $section, $maintainer) = split(/\s+/, $_, 4);

	if (not defined($packages{$p})) {
	    push(@spuriousover, $p);
	    next;
	}

	for my $package (@{$packages{$p}}) {
	    if ($maintainer) {
		if ($maintainer =~ m/(.+?)\s*=\>\s*(.+)/) {
		    my $oldmaint = $1;
		    my $newmaint = $2;
		    my $debmaint = $$package{Maintainer};
		    if (none { $debmaint eq $_ } split m{\s*//\s*}, $oldmaint) {
			push(@changedmaint,
			     sprintf(_g('  %s (package says %s, not %s)'),
			             $p, $$package{Maintainer}, $oldmaint));
		    } else {
			$$package{Maintainer} = $newmaint;
		    }
		} elsif ($$package{Maintainer} eq $maintainer) {
		    push(@samemaint, "  $p ($maintainer)");
		} else {
		    warning(_g('unconditional maintainer override for %s'), $p);
		    $$package{Maintainer} = $maintainer;
		}
	    }
	    $$package{Priority} = $priority;
	    $$package{Section} = $section;
	}
	$overridden{$p} = 1;
    }

    close($comp_file);
}

sub load_override_extra
{
    my $extra_override = shift;
    my $comp_file = Dpkg::Compression::FileHandle->new(filename => $extra_override);

    while (<$comp_file>) {
	s/\#.*//;
	s/\s+$//;
	next unless $_;

	my ($p, $field, $value) = split(/\s+/, $_, 3);

	next unless defined($packages{$p});

	for my $package (@{$packages{$p}}) {
	    $$package{$field} = $value;
	}
    }

    close($comp_file);
}

{
    local $SIG{__WARN__} = sub { usageerr($_[0]) };
    GetOptions(\%options, @options_spec);
}

if (not (@ARGV >= 1 and @ARGV <= 3)) {
    usageerr(_g('one to three arguments expected'));
}

my $type = defined($options{type}) ? $options{type} : 'deb';
my $arch = $options{arch};

my @find_args;
if ($options{arch}) {
     @find_args = ('(', '-name', "*_all.$type", '-o',
			'-name', "*_${arch}.$type", ')');
}
else {
     @find_args = ('-name', "*.$type");
}

my ($binarydir, $override, $pathprefix) = @ARGV;

if (not -d $binarydir) {
    error(_g('binary dir %s not found'), $binarydir);
}
if (defined $override and not -e $override) {
    error(_g('override file %s not found'), $override);
}

$pathprefix //= '';

my $find_h = IO::Handle->new();
open($find_h, '-|', 'find', '-L', "$binarydir/", @find_args, '-print')
     or syserr(_g("couldn't open %s for reading"), $binarydir);
FILE:
    while (<$find_h>) {
	chomp;
	my $fn = $_;
	my $output;
	my $pid = spawn(exec => [ 'dpkg-deb', '-I', $fn, 'control' ],
	                to_pipe => \$output);
	my $fields = Dpkg::Control->new(type => CTRL_INDEX_PKG);
	$fields->parse($output, $fn)
	    or error(_g("couldn't parse control information from %s"), $fn);
	wait_child($pid, no_check => 1);
	if ($?) {
	    warning(_g("\`dpkg-deb -I %s control' exited with %d, skipping package"),
	            $fn, $?);
	    next;
	}

	defined($fields->{'Package'})
	    or error(_g('no Package field in control file of %s'), $fn);
	my $p = $fields->{'Package'};

	if (defined($packages{$p}) and not $options{multiversion}) {
	    foreach (@{$packages{$p}}) {
		if (version_compare_relation($fields->{'Version'}, REL_GT,
					     $_->{'Version'}))
                {
		    warning(_g('package %s (filename %s) is repeat but newer version;'),
		            $p, $fn);
		    warning(_g('used that one and ignored data from %s!'),
		            $_->{Filename});
		    $packages{$p} = [];
		} else {
		    warning(_g('package %s (filename %s) is repeat;'), $p, $fn);
		    warning(_g('ignored that one and using data from %s!'),
		            $_->{Filename});
		    next FILE;
		}
	    }
	}
	warning(_g('package %s (filename %s) has Filename field!'), $p, $fn)
	    if defined($fields->{'Filename'});

	$fields->{'Filename'} = "$pathprefix$fn";

        my $sums = Dpkg::Checksums->new();
	$sums->add_from_file($fn);
        foreach my $alg (checksums_get_list()) {
            if ($alg eq 'md5') {
	        $fields->{'MD5sum'} = $sums->get_checksum($fn, $alg);
            } else {
                $fields->{$alg} = $sums->get_checksum($fn, $alg);
            }
        }
	$fields->{'Size'} = $sums->get_size($fn);
        $fields->{'X-Medium'} = $options{medium} if defined $options{medium};

	push @{$packages{$p}}, $fields;
    }
close($find_h);

load_override($override) if defined $override;
load_override_extra($options{'extra-override'}) if defined $options{'extra-override'};

my @missingover=();

my $records_written = 0;
for my $p (sort keys %packages) {
    if (defined($override) and not defined($overridden{$p})) {
        push(@missingover,$p);
    }
    for my $package (@{$packages{$p}}) {
         print("$package\n") or syserr(_g('failed when writing stdout'));
         $records_written++;
    }
}
close(STDOUT) or syserr(_g("couldn't close stdout"));

if (@changedmaint) {
    warning(_g('Packages in override file with incorrect old maintainer value:'));
    warning($_) foreach (@changedmaint);
}
if (@samemaint) {
    warning(_g('Packages specifying same maintainer as override file:'));
    warning($_) foreach (@samemaint);
}
if (@missingover) {
    warning(_g('Packages in archive but missing from override file:'));
    warning('  %s', join(' ', @missingover));
}
if (@spuriousover) {
    warning(_g('Packages in override file but not in archive:'));
    warning('  %s', join(' ', @spuriousover));
}

info(_g('Wrote %s entries to output Packages file.'), $records_written);