~ubuntu-branches/ubuntu/wily/devscripts/wily

« back to all changes in this revision

Viewing changes to scripts/dget.pl

  • Committer: Package Import Robot
  • Author(s): James McCoy, Paul Wise, James McCoy, Dominique Dumont, Mattia Rizzolo
  • Date: 2015-07-27 23:12:23 UTC
  • mfrom: (10.10.23 sid)
  • Revision ID: package-import@ubuntu.com-20150727231223-iyqh301acuxy9lh5
Tags: 2.15.6
[ Paul Wise ]
* Adjust wording of common suffixes passed to repacksuffix

[ James McCoy ]
* debcheckout:
  + Handle Launchpad Git URLs.  Thanks to Colin Watson for the patch.
    (Closes: #788777)
  + Handle authenticated checkout when Vcs-Darcs is missing the root /darcs
    directory.
* checkbashisms:
  + Fix unescaped, literal curly brace in regex, causing FTBFS with Perl
    5.22.  Thanks to Roderich Schupp for the patch.  (Closes: #788707)
  + Improve detection of %q/%b to include when it is at the start of the
    string.  Thanks to Eero Vuojolahti.  (Closes: #793396)
* wnpp-check:
  + Use getopt to handle argument parsing.
  + Add --exact switch to match the exact package name instead of a
    substring.  Thanks to Balasankar C.  (Closes: #791918)
* Replace manual parsing of dpkg-buildpackage's output with the use of its
  -S switch or the Dpkg::Changelog::Parse Perl module.
  + Bump minimum required version of dpkg-dev to 1.17.0
* dget: Support arch-qualified package names.  “dget foo:i386” will download
  the foo binary package for Arch: i386.  “dget --all srcfoo:i386” will
  download all binary packages from the srcfoo source package that are
  either Arch: all or Arch: any/i386.  (Closes: #792917)
* uscan: Only check for presence of signing key when downloading a new
  upstream archive.  (Closes: #790047)

[ Dominique Dumont ]
* licensecheck:
  * extract © owner when © and owners are specified on 2 or more lines.
  * fix digia © and license extraction (Closes: #789074)
  * fix BSD-2-clause detection
  * parse assembly files with suffix .S
  * warn if scanned file is not a text file (Closes: #791756)

[ Mattia Rizzolo ]
* uscan: Suggest the correct syntax in the manpage for the dversionmangle
  option, escaping a '+'. Thanks to Martin Erik Werner for reporting.
  (Closes: #789389)

Show diffs side-by-side

added added

removed removed

Lines of Context:
33
33
use IO::File;
34
34
use Digest::MD5;
35
35
use Devscripts::Compression;
 
36
use Dpkg::Control;
36
37
use Getopt::Long qw(:config gnu_getopt);
37
38
use File::Basename;
38
39
 
266
267
sub apt_get {
267
268
    my ($package, $version) = @_;
268
269
 
 
270
    my ($archpackage, $arch) = $package;
 
271
    ($package, $arch) = split(/:/, $package, 2);
 
272
 
269
273
    my $qpackage = quotemeta($package);
270
274
    my $qversion = quote_version($version) if $version;
271
275
    my @hosts;
272
276
 
273
 
    my $apt = new IO::File("LC_ALL=C apt-cache policy $package |") or die "$!";
 
277
    my $apt = IO::File->new("LC_ALL=C apt-cache policy $archpackage |") or die "$!";
274
278
    OUTER: while (<$apt>) {
275
279
        if (not $version and /^  Candidate: (.+)/) {
276
280
            $version = $1;
287
291
    }
288
292
    close $apt;
289
293
    unless ($version) {
290
 
        die "$progname: $package has no installation candidate\n";
 
294
        die "$progname: $archpackage has no installation candidate\n";
291
295
    }
292
296
    unless (@hosts) {
293
 
        die "$progname: no hostnames in apt-cache policy $package for version $version found\n";
 
297
        die "$progname: no hostnames in apt-cache policy $archpackage for version $version found\n";
294
298
    }
295
299
 
296
 
    $apt = new IO::File("LC_ALL=C apt-cache show $package=$version |")
 
300
    $apt = IO::File->new("LC_ALL=C apt-cache show $archpackage=$version |")
297
301
        or die "$!";
298
302
    my ($v, $p, $filename, $md5sum);
299
303
    while (<$apt>) {
322
326
    close $apt;
323
327
 
324
328
    unless ($filename) {
325
 
        die "$progname: no filename for $package ($version) found\n";
 
329
        die "$progname: no filename for $archpackage ($version) found\n";
326
330
    }
327
331
 
328
332
    # find deb lines matching the hosts in the policy output
481
485
        }
482
486
 
483
487
    # case 2a: --all srcpackage[=version]
484
 
    } elsif ($opt->{'all'} and $arg =~ /^([a-z0-9.+-]{2,})(?:=([a-zA-Z0-9.:~+-]+))?$/) {
485
 
        my ($source, $version) = ($1, $2);
 
488
    } elsif ($opt->{'all'} and $arg =~ /^([a-z0-9.+-:]{2,})(?:=([a-zA-Z0-9.:~+-]+))?$/) {
 
489
        my ($source, $version, $arch) = ($1, $2);
 
490
        ($source, $arch) = split(/:/, $source, 2);
486
491
        my $cmd = "apt-cache showsrc $source";
487
 
        #$cmd .= "=$version" if ($version); # unfortunately =version doesn't work here
488
 
        open A, '-|', $cmd;
489
 
        while (<A>) {
490
 
            next unless /^Binary: (.*)/;
491
 
            my @packages = split (/, /, $1);
492
 
            foreach my $package (@packages) {
493
 
                eval { apt_get ($package, $version) } or print "$@";
 
492
        # unfortunately =version doesn't work here, and even if it did, was the
 
493
        # user referring to the source version or the binary version?  The code
 
494
        # assumes binary version.
 
495
        #$cmd .= "=$version" if ($version);
 
496
        open my $showsrc, '-|', $cmd;
 
497
        my $c = Dpkg::Control->new(type => CTRL_INDEX_SRC);
 
498
        while ($c->parse($showsrc, $cmd)) {
 
499
            if ($arch) {
 
500
                my @packages = grep { $_ } split /\n/, $c->{'Package-List'};
 
501
                # Find all packages whose architecture is either 'all', 'any',
 
502
                # or the given architecture.  The Package-List lines are
 
503
                # $pkg $debtype $section $priority arch=$archlist
 
504
                foreach my $package (@packages) {
 
505
                    $package =~ s/^\s*//;
 
506
                    my ($binary,
 
507
                        $debtype,
 
508
                        $section,
 
509
                        $priority,
 
510
                        $archs) = split(/\s+/, $package, 5);
 
511
                    if ($archs =~ m/all/) {
 
512
                        eval { apt_get($binary, $version) } or print "$@";
 
513
                    }
 
514
                    elsif ($archs =~ m/any|[=,]$arch/) {
 
515
                        eval { apt_get("$binary:$arch", $version) } or print "$@";
 
516
                    }
 
517
                }
 
518
            }
 
519
            else {
 
520
                my @packages = split /, /, $c->{Binary};
 
521
                foreach my $package (@packages) {
 
522
                    eval { apt_get ($package, $version) } or print "$@";
 
523
                }
494
524
            }
495
525
            last;
496
526
        }
497
 
        close A;
 
527
        close $showsrc;
498
528
 
499
529
    # case 2b: package[=version]
500
 
    } elsif ($arg =~ /^([a-z0-9.+-]{2,})(?:=([a-zA-Z0-9.:~+-]+))?$/) {
 
530
    } elsif ($arg =~ /^([a-z0-9.+-:]{2,})(?:=([a-zA-Z0-9.:~+-]+))?$/) {
501
531
        apt_get($1, $2);
502
532
 
503
533
    } else {
567
597
=item B<-a>, B<--all>
568
598
 
569
599
Interpret I<package> as a source package name, and download all binaries as
570
 
found in the output of "apt-cache showsrc I<package>".
 
600
found in the output of "apt-cache showsrc I<package>".  If I<package> is
 
601
arch-qualified, then only binary packages which are "Arch: all", "Arch: any",
 
602
or "Arch: $arch" will be downloaded.
571
603
 
572
604
=item B<-b>, B<--backup>
573
605