This file is indexed.

/usr/bin/rmadison is in devscripts 2.17.12ubuntu1.

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
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
#!/usr/bin/perl
# vim:sw=4:sta:

# Copyright (C) 2006-2013 Christoph Berg <myon@debian.org>
#           (C) 2010 Uli Martens <uli@youam.net>
#
# 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, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

use strict;
use warnings;
use File::Basename;
use Getopt::Long qw(:config bundling permute no_getopt_compat);

BEGIN {
    pop @INC if $INC[-1] eq '.';
    # Load the URI::Escape module safely
    eval { require URI::Escape; };
    if ($@) {
       my $progname = basename $0;
       if ($@ =~ /^Can\'t locate URI\/Escape\.pm/) {
           die "$progname: you must have the liburi-perl package installed\nto use this script\n";
       }
       die "$progname: problem loading the URI::Escape module:\n  $@\nHave you installed the liburi-perl package?\n";
    }
    import URI::Escape;
}

my $VERSION = '0.4';

sub version($) {
    my ($fd) = @_;
    print $fd <<EOT;
rmadison $VERSION (devscripts 2.17.12ubuntu1)
(C) 2006-2010 Christoph Berg <myon\@debian.org>
(C) 2010 Uli Martens <uli\@youam.net>
EOT
}

my %url_map = (
    'debian' => "https://api.ftp-master.debian.org/madison",
    'new' => "https://api.ftp-master.debian.org/madison?s=new",
    'qa' => "https://qa.debian.org/madison.php",
    'ubuntu' => "http://people.canonical.com/~ubuntu-archive/madison.cgi",
    'udd' => 'https://qa.debian.org/cgi-bin/madison.cgi',
);
my $default_url = 'debian';
if (system('dpkg-vendor', '--is', 'ubuntu') == 0) {
    $default_url = 'ubuntu';
}

sub usage($$) {
    my ($fd, $exit) = @_;
    my @urls = split /,/, $default_url;
    my $url = (@urls > 1) ? join(', and ', join(', ', @urls[0..$#urls-1]), $urls[-1])
                          : $urls[0];

    print $fd <<EOT;
Usage: rmadison [OPTION] PACKAGE[...]
Display information about PACKAGE(s).

  -a, --architecture=ARCH    only show info for ARCH(s)
  -b, --binary-type=TYPE     only show info for binary TYPE
  -c, --component=COMPONENT  only show info for COMPONENT(s)
  -g, --greaterorequal       show buildd 'dep-wait pkg >= {highest version}' info
  -G, --greaterthan          show buildd 'dep-wait pkg >> {highest version}' info
  -h, --help                 show this help and exit
  -r, --regex                treat PACKAGE as a regex [not supported everywhere]
  -s, --suite=SUITE          only show info for this suite
  -S, --source-and-binary    show info for the binary children of source pkgs
  -t, --time                 show projectb snapshot date
  -u, --url=URL              use URL instead of $url

  --noconf, --no-conf        don\'t read devscripts configuration files

ARCH, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
    --architecture=m68k,i386

Aliases for URLs:
EOT
    foreach my $alias (sort keys %url_map) {
	print $fd "\t$alias\t$url_map{$alias}\n";
    }
    exit $exit;
}

my $params;
my $default_arch;
my $ssl_ca_file;
my $ssl_ca_path;

if (@ARGV and $ARGV[0] =~ /^--no-?conf$/) {
    shift;
} else {
    # We don't have any predefined variables, but allow any of the form
    # RMADISON_URL_MAP_SHORTCODE=URL
    my @config_files = ('/etc/devscripts.conf', '~/.devscripts');
    my @config_vars = ();

    my $shell_cmd;
    # Set defaults
    $shell_cmd .= qq[unset `set | grep "^RMADISON_" | cut -d= -f1`;\n];
    $shell_cmd .= 'for file in ' . join(" ", @config_files) . "; do\n";
    $shell_cmd .= '[ -f $file ] && . $file; done;' . "\n";
    $shell_cmd .= 'for var in `set | grep "^RMADISON_" | cut -d= -f1`; do ';
    $shell_cmd .= 'eval echo $var=\$$var; done;' . "\n";
    # Read back values
    my $shell_out = `/bin/bash -c '$shell_cmd'`;
    @config_vars = split /\n/, $shell_out, -1;

    foreach my $confvar (@config_vars) {
	if ($confvar =~ /^RMADISON_URL_MAP_([^=]*)=(.*)$/) {
	    $url_map{lc($1)}=$2;
	} elsif ($confvar =~ /^RMADISON_DEFAULT_URL=(.*)$/) {
	    $default_url=$1;
	} elsif ($confvar =~ /^RMADISON_ARCHITECTURE=(.*)$/) {
	    $default_arch=$1;
	} elsif ($confvar =~ /^RMADISON_SSL_CA_FILE=(.*)$/) {
	    $ssl_ca_file=$1;
	} elsif ($confvar =~ /^RMADISON_SSL_CA_PATH=(.*)$/) {
	    $ssl_ca_path=$1;
	}
    }
}

unless (GetOptions(
    '-a=s'                =>  \$params->{'architecture'},
    '--architecture=s'    =>  \$params->{'architecture'},
    '-b=s'                =>  \$params->{'binary-type'},
    '--binary-type=s'     =>  \$params->{'binary-type'},
    '-c=s'                =>  \$params->{'component'},
    '--component=s'       =>  \$params->{'component'},
    '-g'                  =>  \$params->{'greaterorequal'},
    '--greaterorequal'    =>  \$params->{'greaterorequal'},
    '-G'                  =>  \$params->{'greaterthan'},
    '--greaterthan'       =>  \$params->{'greaterthan'},
    '-h'                  =>  \$params->{'help'},
    '--help'              =>  \$params->{'help'},
    '-r'                  =>  \$params->{'regex'},
    '--regex'             =>  \$params->{'regex'},
    '-s=s'                =>  \$params->{'suite'},
    '--suite=s'           =>  \$params->{'suite'},
    '-S'                  =>  \$params->{'source-and-binary'},
    '--source-and-binary' =>  \$params->{'source-and-binary'},
    '-t'                  =>  \$params->{'time'},
    '--time'              =>  \$params->{'time'},
    '-u=s'                =>  \$params->{'url'},
    '--url=s'             =>  \$params->{'url'},
    '--version'           =>  \$params->{'version'},
)) {
    usage(\*STDERR, 1);
};

if ($params->{help}) {
    usage(\*STDOUT, 0);
}
if ($params->{version}) {
    version(\*STDOUT);
    exit 0;
}

unless (@ARGV) {
    print STDERR "E: need at least one package name as an argument.\n";
    exit 1;
}
if ($params->{greaterorequal} and $params->{greaterthan}) {
    print STDERR "E: -g/--greaterorequal and -G/--greaterthan are mutually exclusive.\n";
    exit 1;
}

my @args;

if ( $params->{'architecture'} ) {
    push @args, "a=$params->{'architecture'}";
} elsif ( $default_arch ) {
    push @args, "a=$default_arch";
}
push @args, "b=$params->{'binary-type'}" if $params->{'binary-type'};
push @args, "c=$params->{'component'}" if $params->{'component'};
push @args, "g" if $params->{'greaterorequal'};
push @args, "G" if $params->{'greaterthan'};
push @args, "r" if $params->{'regex'};
push @args, "s=$params->{'suite'}" if $params->{'suite'};
push @args, "S" if $params->{'source-and-binary'};
push @args, "t" if $params->{'time'};

my $url = $params->{'url'} ? $params->{'url'} : $default_url;
my @url = split /,/, $url;

my $status = 0;

# Strip arch qualifiers from the package name, to help those that are feeding
# in output from other commands
s/:.*// for (@ARGV);

foreach my $url (@url) {
    print "$url:\n" if @url > 1;
    $url = $url_map{$url} if $url_map{$url};
    my @cmd;
    if ( -x "/usr/bin/curl" ) {
        @cmd = qw/curl -f -s -S -L/;
        push @cmd, "--cacert", $ssl_ca_file if $ssl_ca_file;
        push @cmd, "--capath", $ssl_ca_path if $ssl_ca_path;

    } else {
        @cmd = qw/wget -q -O -/;
        push @cmd, "--ca-certificate=$ssl_ca_file" if $ssl_ca_file;
        push @cmd, "--ca-directory=$ssl_ca_path"   if $ssl_ca_path;
    }
    system @cmd, $url . (($url =~ m/\?/)?'&':'?')."package=" . join("+", map { uri_escape($_) } @ARGV) . "&text=on&" . join ("&", @args);
    $status = 1 if ($? >> 8 != 0);
}

exit $status;

__END__

=head1 NAME

rmadison -- Remotely query the Debian archive database about packages

=head1 SYNOPSIS

=over

=item B<rmadison> [I<OPTIONS>] I<PACKAGE> ...

=back

=head1 DESCRIPTION

B<dak ls> queries the Debian archive database ("projectb") and
displays which package version is registered per architecture/component/suite.
The CGI at B<https://qa.debian.org/madison.php> provides that service without
requiring SSH access to ftp-master.debian.org or the mirror on
mirror.ftp-master.debian.org. This script, B<rmadison>, is a command line
frontend to this CGI.

=head1 OPTIONS

=over

=item B<-a>, B<--architecture=>I<ARCH>

only show info for ARCH(s)

=item B<-b>, B<--binary-type=>I<TYPE>

only show info for binary TYPE

=item B<-c>, B<--component=>I<COMPONENT>

only show info for COMPONENT(s)

=item B<-g>, B<--greaterorequal>

show buildd 'dep-wait pkg >= {highest version}' info

=item B<-G>, B<--greaterthan>

show buildd 'dep-wait pkg >> {highest version}' info

=item B<-h>, B<--help>

show this help and exit

=item B<-s>, B<--suite=>I<SUITE>

only show info for this suite

=item B<-r>, B<--regex>

treat PACKAGE as a regex

B<Note:> Since B<-r> can easily DoS the database ("-r ."), this option is not
supported by the CGI on qa.debian.org and most other installations.

=item B<-S>, B<--source-and-binary>

show info for the binary children of source pkgs

=item B<-t>, B<--time>

show projectb snapshot and reload time (not supported by all archives)

=item B<-u>, B<--url=>I<URL>[B<,>I<URL> ...]

use I<URL> for the query. Supported shorthands are
 B<debian> https://api.ftp-master.debian.org/madison
 B<new> https://api.ftp-master.debian.org/madison?s=new
 B<qa> https://qa.debian.org/madison.php
 B<ubuntu> http://people.canonical.com/~ubuntu-archive/madison.cgi
 B<udd> https://qa.debian.org/cgi-bin/madison.cgi

See the B<RMADISON_URL_MAP_> variable below for a method to add
new shorthands.

=item B<--version>

show version and exit

=item B<--no-conf>, B<--noconf>

don't read the devscripts configuration files

=back

ARCH, COMPONENT and SUITE can be comma (or space) separated lists, e.g.
--architecture=m68k,i386

=head1 CONFIGURATION VARIABLES

The two configuration files F</etc/devscripts.conf> and
F<~/.devscripts> are sourced by a shell in that order to set
configuration variables. Command line options can be used to override
configuration file settings. Environment variable settings are
ignored for this purpose. The currently recognised variables are:

=over 4

=item B<RMADISON_URL_MAP_>I<SHORTHAND>=I<URL>

Add an entry to the set of shorthand URLs listed above. I<SHORTHAND> should
be replaced with the shorthand form to be used to refer to I<URL>.

Multiple shorthand entries may be specified by using multiple
B<RMADISON_URL_MAP_*> variables.

=item B<RMADISON_DEFAULT_URL>=I<URL>

Set the default URL to use unless overridden by a command line option.
For Debian this defaults to debian. For Ubuntu this defaults to ubuntu.

=item B<RMADISON_ARCHITECTURE>=I<ARCH>

Set the default architecture to use unless overridden by a command line option.
To run an unrestricted query when B<RMADISON_ARCHITECTURE> is set, use
B<--architecture='*'>.

=item B<RMADISON_SSL_CA_FILE>=I<FILE>

Use the specified CA file instead of the default CA bundle for curl/wget,
passed as --cacert to curl, and as --ca-certificate to wget.

=item B<RMADISON_SSL_CA_PATH>=I<PATH>

Use the specified CA directory instead of the default CA bundle for curl/wget,
passed as --capath to curl, and as --ca-directory to wget.

=back

=head1 NOTES

B<dak ls> was formerly called B<madison>.

The protocol used by rmadison is fairly simple, the CGI accepts query the
parameters a, b, c, g, G, r, s, S, t, and package. The parameter text is passed to
enable plain-text output.

=head1 SEE ALSO

B<dak>(1), B<madison-lite>(1)

=head1 AUTHOR

rmadison and https://qa.debian.org/madison.php were written by Christoph Berg
<myon@debian.org>. dak was written by
James Troup <james@nocrew.org>, Anthony Towns <ajt@debian.org>, and others.

=cut