MAJOR=4
MINOR=67
DEVNAME=ttyS3
  7   %ˆl–äY>”Ên-ji@¿pB¸ÈÅ£�þYeöVpBqøÆ!<ûÀþÔ„"?ÓÁÑ 3“    %#!/usr/bin/perl
# vim: set ai shiftwidth=4 tabstop=4 expandtab:

# 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.23.4+deb12u2)
(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'  => "https://people.canonical.com/~ubuntu-archive/madison.cgi",
    'udd'     => 'https://qa.debian.org/cgi-bin/madison.cgi',
    'archive' => 'https://qa.debian.org/cgi-bin/madison.cgi?table=archived',
    'ports'   => 'https://qa.debian.org/cgi-bin/madison.cgi?table=ports',
    'janitor' => 'https://janitor.debian.net/api/madison',
);
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=amd64,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', '~/.devscrip