Author: myon
Date: 2008-02-17 14:35:01 +0000 (Sun, 17 Feb 2008)
New Revision: 1024

Modified:
   trunk/debian/changelog
   trunk/debian/postinst
   trunk/scripts/dget.pl
Log:
* dget:
  + Make unpacking downloaded source packages the default, use -d for the
    old behaviour.
  + Check signature of source packages using dscverify, use -u to disable.
    (Closes: #434521)

Modified: trunk/debian/changelog
===================================================================
--- trunk/debian/changelog      2008-02-17 14:28:51 UTC (rev 1023)
+++ trunk/debian/changelog      2008-02-17 14:35:01 UTC (rev 1024)
@@ -1,5 +1,6 @@
 devscripts (2.10.17) UNRELEASED; urgency=low
 
+  [ Adam D. Barratt ]
   * checkbashisms: Fix a false positive in the $(( test (Closes: #465364)
   * Debbugs.pm: Add status()
   * tagpending: Rewrite in perl using Debbugs.pm
@@ -19,8 +20,15 @@
   * dget: Correctly handle the processing of a file that we've already
     retrieved (Closes: #445546)
 
- -- Adam D. Barratt <[EMAIL PROTECTED]>  Tue, 12 Feb 2008 08:50:01 +0000
+  [ Christoph Berg ]
+  * dget:
+    + Make unpacking downloaded source packages the default, use -d for the
+      old behaviour.
+    + Check signature of source packages using dscverify, use -u to disable.
+      (Closes: #434521)
 
+ -- Christoph Berg <[EMAIL PROTECTED]>  Sun, 17 Feb 2008 15:31:44 +0100
+
 devscripts (2.10.16) unstable; urgency=low
 
   The "storm before the calm" release

Modified: trunk/debian/postinst
===================================================================
--- trunk/debian/postinst       2008-02-17 14:28:51 UTC (rev 1023)
+++ trunk/debian/postinst       2008-02-17 14:35:01 UTC (rev 1024)
@@ -399,6 +399,20 @@
 # BTS_SUPPRESS_ACKS=no
 EOF
        fi
+
+       if dpkg --compare-versions "$2" lt 2.10.17
+       then
+           # Added in devscripts 2.10.17
+           cat >> /etc/devscripts.conf <<EOF
+
+##### dget options added in version 2.10.17
+#
+# Unpack downloaded source packages
+# DGET_UNPACK=yes
+# Verify source package signatures using dscverify
+# DGET_VERIFY=yes
+EOF
+       fi
     fi
 fi
 

Modified: trunk/scripts/dget.pl
===================================================================
--- trunk/scripts/dget.pl       2008-02-17 14:28:51 UTC (rev 1023)
+++ trunk/scripts/dget.pl       2008-02-17 14:35:01 UTC (rev 1024)
@@ -2,7 +2,7 @@
 # vim:sw=4:sta:
 
 #   dget - Download Debian source and binary packages
-#   Copyright (C) 2005-07 Christoph Berg <[EMAIL PROTECTED]>
+#   Copyright (C) 2005-08 Christoph Berg <[EMAIL PROTECTED]>
 #   Modifications Copyright (C) 2005-06 Julian Gilbey <[EMAIL PROTECTED]>
 #
 #   This program is free software; you can redistribute it and/or modify
@@ -58,12 +58,16 @@
 Usage: $progname [options] URL
        $progname [options] package[=version]
 
-Downloads Debian packages, either from the specified URL (first form),
+Downloads Debian packages (source and binary) from the specified URL (first 
form),
 or using the mirror configured in /etc/apt/sources.list (second form).
 
    -b, --backup    Move files that would be overwritten to ./backup
    -q, --quiet     Suppress wget/curl output
-   -x, --extract   Run dpkg-source -x on downloaded source (first form only)
+   -d, --download-only
+                   Do not extract downloaded source
+   -x, --extract   Unpack downloaded source (default)
+   -u, --allow-unauthenticated
+                   Do no attempt to verify source package signature
    --build         Build package with dpkg-buildpackage after download
    --path DIR      Check these directories in addition to the apt archive;
                    if DIR='' then clear current list (may be used multiple
@@ -83,7 +87,7 @@
 sub version {
     print <<"EOF";
 This is $progname, from the Debian devscripts package, version ###VERSION###
-This code is copyright 2005-07 by Christoph Berg <[EMAIL PROTECTED]>.
+This code is copyright 2005-08 by Christoph Berg <[EMAIL PROTECTED]>.
 Modifications copyright 2005-06 by Julian Gilbey <[EMAIL PROTECTED]>.
 All rights reserved.
 This program comes with ABSOLUTELY NO WARRANTY.
@@ -330,7 +334,7 @@
 # Now start by reading configuration files and then command line
 # The next stuff is boilerplate
 
-my $dget_path;
+my ($dget_path, $dget_unpack, $dget_verify);
 
 if (@ARGV and $ARGV[0] =~ /^--no-?conf$/) {
     $modified_conf_msg = "  (no configuration files read)";
@@ -339,6 +343,8 @@
     my @config_files = ('/etc/devscripts.conf', '~/.devscripts');
     my %config_vars = (
                       'DGET_PATH' => '',
+                      'DGET_UNPACK' => 'yes',
+                      'DGET_VERIFY' => 'yes',
                       );
     my %config_default = %config_vars;
 
@@ -363,6 +369,8 @@
     chomp $modified_conf_msg;
 
     $dget_path = $config_vars{'DGET_PATH'};
+    $dget_unpack = $config_vars{'DGET_UNPACK'} =~ /^y/i;
+    $dget_verify = $config_vars{'DGET_VERIFY'} =~ /^y/i;
 }
 
 # handle options
@@ -371,7 +379,11 @@
     "b|backup"   =>  \$opt->{'backup'},
     "q|quiet"    =>  \$opt->{'quiet'},
     "build"      =>  \$opt->{'build'},
-    "x|extract"  =>  \$opt->{'unpack_source'},
+    "d|download-only"
+                 =>  sub { $dget_unpack = 0 },
+    "x|extract"  =>  sub { $dget_unpack = 1 },
+    "u|allow-unauthenticated"
+                 =>  sub { $dget_verify = 0 },
     "insecure"   =>  \$opt->{'insecure'},
     "no-cache"   =>  \$opt->{'no-cache'},
     "noconf|no-conf"   =>  \$opt->{'no-conf'},
@@ -402,25 +414,36 @@
 for my $arg (@ARGV) {
     $found_dsc = "";
 
+    # case 1: URL
     if ($arg =~ 
/^((?:copy|file|ftp|http|rsh|rsync|ssh|www).*)\/([^\/]+\.\w+)$/) {
        get_file($1, $2, "unlink") or exit 1;
-       if ($found_dsc and $opt->{'build'}) {
-               my @output = `dpkg-source -x $found_dsc`;
+       if ($found_dsc) {
+           if ($dget_verify) { # We are duplicating work here a bit as
+               # dpkg-source -x will also verify signatures. Still, we
+               # also want to barf with -d, and on unsigned packages.
+               system 'dscverify', $found_dsc;
+               exit $? >> 8 if $? >> 8 != 0;
+           }
+           if ($opt->{'build'}) {
+               my @output = `dpkg-source -x $found_dsc`; # FIXME: this will 
break when dpkg-source output is localized
+               print @output;
                foreach (@output) {
-                       if ( /^dpkg-source: extracting .* in .*/ ) {
-                               /^dpkg-source: extracting .* in (.*)$/;
-                               chdir $1;
-                               system 'dpkg-buildpackage', '-b', '-uc';
-                       }
+                   if ( /^dpkg-source: extracting .* in (.*)/ ) {
+                       chdir $1;
+                       system 'dpkg-buildpackage', '-b', '-uc';
+                       last;
+                   }
                }
+           } elsif ($dget_unpack) {
+               system 'dpkg-source', '-x', $found_dsc;
+           }
        }
-       elsif ($found_dsc and $opt->{'unpack_source'}) {
-           system 'dpkg-source', '-x', $found_dsc;
-       }
 
+    # case 2a: package
     } elsif ($arg =~ /^[a-z0-9.+-]{2,}$/) {
        apt_get($arg);
 
+    # case 2b: package=version
     } elsif ($arg =~ /^([a-z0-9.+-]{2,})=([a-zA-Z0-9.:~+-]+)$/) {
        apt_get($1, $2);
 
@@ -450,8 +473,8 @@
 B<dget> downloads Debian packages.  In the first form, B<dget> fetches
 the requested URL.  If this is a .dsc or .changes file, then B<dget>
 acts as a source-package aware form of B<wget>: it also fetches any
-files referenced in the .dsc/.changes file.  When the B<-x> option is
-given, the downloaded source is also unpacked by B<dpkg-source>.
+files referenced in the .dsc/.changes file.  The downloaded source is
+then unpacked by B<dpkg-source>.
 
 In the second form, B<dget> downloads a I<binary> package (i.e., a
 I<.deb> file) from the Debian mirror configured in
@@ -487,11 +510,22 @@
 
 Suppress B<wget>/B<curl> non-error output.
 
+=item B<-d>, B<--download-only>
+
+Do not run B<dpkg-source -x> on the downloaded source package.  This can
+only be used with the first method of calling B<dget>.
+
 =item B<-x>, B<--extract>
 
-Run B<dpkg-source -x> on the downloaded source package.  This can only
-be used with the first method of calling B<dget>.
+Run B<dpkg-source -x> on the downloaded source package to unpack it.
+This option is the default and can only be used with the first method of
+calling B<dget>.
 
+=item B<-u>, B<--allow-unauthenticated>
+
+Do not attempt to verify the integrity of downloaded source packages
+using B<dscverify>.
+
 =item B<--build>
 
 Run B<dpkg-buildpackage -b -uc> on the downloaded source package.
@@ -544,15 +578,28 @@
 I</var/cache/apt/archives>.  It has the same effect as the B<--path>
 command line option.  It is not set by default.
 
+=item DGET_UNPACK
+
+Set to 'no' to disable extracting downloaded source packages.  Default
+is 'yes'.
+
+=item DGET_VERIFY
+
+Set to 'no' to disable checking signatures of downloaded source
+packages.  Default is 'yes'.
+
 =cut
 
-=head1 BUGS
+=head1 BUGS AND COMPATIBILITY
 
 B<dget> I<package> should be implemented in B<apt-get install -d>.
 
+Before devscripts version 2.10.17, the default was not to extract the
+downloaded source. Set DGET_UNPACK=no to revert to the old behaviour.
+
 =head1 AUTHOR
 
-This program is Copyright (C) 2005-07 by Christoph Berg <[EMAIL PROTECTED]>.
+This program is Copyright (C) 2005-08 by Christoph Berg <[EMAIL PROTECTED]>.
 Modifications are Copyright (C) 2005-06 by Julian Gilbey <[EMAIL PROTECTED]>.
 
 This program is licensed under the terms of the GPL, either version 2



-- 
To unsubscribe, send mail to [EMAIL PROTECTED]

Reply via email to