chiark / gitweb /
Use curl to download things rather than dget; do our own processing of the files
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 3 Aug 2014 19:28:51 +0000 (20:28 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 3 Aug 2014 19:30:15 +0000 (20:30 +0100)
debian/changelog
dgit
dgit.1

index b63b82911cd17c09d495877b17f2506a6aa7f7b8..963eaa60ccb6f2ba8aa808ec08ee4a38b96d0ca5 100644 (file)
@@ -8,6 +8,8 @@ dgit (0.22~experimental1) experimental; urgency=low
     to pass -dubuntu.  Closes:#751781.
   * Use mirror.ftp-master.debian.org DNS alias rather than coccia.
     Closes:#752602.
     to pass -dubuntu.  Closes:#751781.
   * Use mirror.ftp-master.debian.org DNS alias rather than coccia.
     Closes:#752602.
+  * Check hashes of files ourselves rather than running dget to
+    re-retreive the .dsc.
 
   Minor improvements:
   * Include canonicalised suite name in signed tag message.
 
   Minor improvements:
   * Include canonicalised suite name in signed tag message.
diff --git a/dgit b/dgit
index d587527cb73c32c271b8d576a846bd3e5061515e..461e5e658305f3bfcfe2f507117931f05aabedbc 100755 (executable)
--- a/dgit
+++ b/dgit
@@ -57,6 +57,7 @@ our $suite_re = '[-+.0-9a-z]+';
 
 our (@git) = qw(git);
 our (@dget) = qw(dget);
 
 our (@git) = qw(git);
 our (@dget) = qw(dget);
+our (@curl) = qw(curl -f);
 our (@dput) = qw(dput);
 our (@debsign) = qw(debsign);
 our (@gpg) = qw(gpg);
 our (@dput) = qw(dput);
 our (@debsign) = qw(debsign);
 our (@gpg) = qw(gpg);
@@ -69,7 +70,8 @@ our (@dpkggenchanges) = qw(dpkg-genchanges);
 our (@mergechanges) = qw(mergechanges -f);
 our (@changesopts) = ('');
 
 our (@mergechanges) = qw(mergechanges -f);
 our (@changesopts) = ('');
 
-our %opts_opt_map = ('dget' => \@dget,
+our %opts_opt_map = ('dget' => \@dget, # accept for compatibility
+                    'curl' => \@curl,
                     'dput' => \@dput,
                     'debsign' => \@debsign,
                      'gpg' => \@gpg,
                     'dput' => \@dput,
                     'debsign' => \@debsign,
                      'gpg' => \@gpg,
@@ -972,20 +974,33 @@ sub clogp_authline ($) {
 sub generate_commit_from_dsc () {
     prep_ud();
     changedir $ud;
 sub generate_commit_from_dsc () {
     prep_ud();
     changedir $ud;
-    my @files;
-    foreach my $f (dsc_files()) {
+
+    foreach my $fi (dsc_files_info()) {
+       my $f = $fi->{Filename};
        die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
        die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
-       push @files, $f;
+
        link "../../../$f", $f
            or $!==&ENOENT
            or die "$f $!";
        link "../../../$f", $f
            or $!==&ENOENT
            or die "$f $!";
+
+       complete_file_from_dsc('.', $fi);
+
+       if (is_orig_file($f)) {
+           link $f, "../../../../$f"
+               or $!==&EEXIST
+               or die "$f $!";
+       }
     }
     }
-    runcmd @dget, qw(--), $dscurl;
-    foreach my $f (grep { is_orig_file($_) } @files) {
-       link $f, "../../../../$f"
-           or $!==&EEXIST
-           or die "$f $!";
-    }
+
+    my $dscfn = "$package.dsc";
+
+    open D, ">", $dscfn or die "$dscfn: $!";
+    print D $dscdata or die "$dscfn: $!";
+    close D or die "$dscfn: $!";
+    my @cmd = qw(dpkg-source);
+    push @cmd, qw(-x --), $dscfn;
+    runcmd @cmd;
+
     my ($tree,$dir) = mktree_in_ud_from_only_subdir();
     runcmd qw(sh -ec), 'dpkg-parsechangelog >../changelog.tmp';
     my $clogp = parsecontrol('../changelog.tmp',"commit's changelog");
     my ($tree,$dir) = mktree_in_ud_from_only_subdir();
     runcmd qw(sh -ec), 'dpkg-parsechangelog >../changelog.tmp';
     my $clogp = parsecontrol('../changelog.tmp',"commit's changelog");
@@ -1046,30 +1061,47 @@ END
     return $outputhash;
 }
 
     return $outputhash;
 }
 
+sub complete_file_from_dsc ($$) {
+    our ($dstdir, $fi) = @_;
+    # Ensures that we have, in $dir, the file $fi, with the correct
+    # contents.  (Downloading it from alongside $dscurl if necessary.)
+
+    my $f = $fi->{Filename};
+    my $tf = "$dstdir/$f";
+    my $downloaded = 0;
+
+    if (stat $tf) {
+       progress "using existing $f";
+    } else {
+       die "$tf $!" unless $!==&ENOENT;
+
+       my $furl = $dscurl;
+       $furl =~ s{/[^/]+$}{};
+       $furl .= "/$f";
+       die "$f ?" unless $f =~ m/^${package}_/;
+       die "$f ?" if $f =~ m#/#;
+       runcmd_ordryrun_local @curl,qw(-o),$tf,'--',"$furl";
+       next if !act_local();
+       $downloaded = 1;
+    }
+
+    open F, "<", "$tf" or die "$tf: $!";
+    $fi->{Digester}->reset();
+    $fi->{Digester}->addfile(*F);
+    F->error and die $!;
+    my $got = $fi->{Digester}->hexdigest();
+    $got eq $fi->{Hash} or
+       fail "file $f has hash $got but .dsc".
+           " demands hash $fi->{Hash} ".
+           ($downloaded ? "(got wrong file from archive!)"
+            : "(perhaps you should delete this file?)");
+}
+
 sub ensure_we_have_orig () {
     foreach my $fi (dsc_files_info()) {
        my $f = $fi->{Filename};
        next unless is_orig_file($f);
 sub ensure_we_have_orig () {
     foreach my $fi (dsc_files_info()) {
        my $f = $fi->{Filename};
        next unless is_orig_file($f);
-       if (open F, "<", "../$f") {
-           $fi->{Digester}->reset();
-           $fi->{Digester}->addfile(*F);
-           F->error and die $!;
-           my $got = $fi->{Digester}->hexdigest();
-           $got eq $fi->{Hash} or
-               fail "existing file $f has hash $got but .dsc".
-                   " demands hash $fi->{Hash}".
-                   " (perhaps you should delete this file?)";
-           progress "using existing $f";
-           next;
-       } else {
-           die "$f $!" unless $!==&ENOENT;
-       }
-       my $origurl = $dscurl;
-       $origurl =~ s{/[^/]+$}{};
-       $origurl .= "/$f";
-       die "$f ?" unless $f =~ m/^${package}_/;
-       die "$f ?" if $f =~ m#/#;
-       runcmd_ordryrun_local shell_cmd 'cd ..', @dget,'--',$origurl;
+       complete_file_from_dsc('..', $fi);
     }
 }
 
     }
 }
 
@@ -2164,8 +2196,6 @@ if ($ENV{$fakeeditorenv}) {
     quilt_fixup_editor();
 }
 
     quilt_fixup_editor();
 }
 
-delete $ENV{'DGET_UNPACK'};
-
 parseopts();
 print STDERR "DRY RUN ONLY\n" if $dryrun_level > 1;
 print STDERR "DAMP RUN - WILL MAKE LOCAL (UNSIGNED) CHANGES\n"
 parseopts();
 print STDERR "DRY RUN ONLY\n" if $dryrun_level > 1;
 print STDERR "DAMP RUN - WILL MAKE LOCAL (UNSIGNED) CHANGES\n"
diff --git a/dgit.1 b/dgit.1
index 6449ea34df2b19f983d9fcfa2c1d81d9dabc38b7..de54068d541a78f10ea71c90214f1ff1b95d0a2f 100644 (file)
--- a/dgit.1
+++ b/dgit.1
@@ -274,9 +274,9 @@ Passed to dpkg-genchanges (eventually).
 Specifies a single additional option to pass, eventually, to
 dpkg-genchanges.
 .TP
 Specifies a single additional option to pass, eventually, to
 dpkg-genchanges.
 .TP
-.RI \fB--dget=\fR program |\fB--dput=\fR program |...
+.RI \fB--curl=\fR program |\fB--dput=\fR program |...
 Specifies alternative programs to use instead of
 Specifies alternative programs to use instead of
-.BR dget ,
+.BR curl ,
 .BR dput ,
 .BR debsign ,
 .BR dpkg-source ,
 .BR dput ,
 .BR debsign ,
 .BR dpkg-source ,
@@ -312,9 +312,9 @@ git to access dgit-repos, only git's idea of what ssh to use (eg,
 .BR GIT_SSH )
 is relevant.
 .TP
 .BR GIT_SSH )
 is relevant.
 .TP
-.RI \fB--dget:\fR option |\fB--dput:\fR option |...
+.RI \fB--curl:\fR option |\fB--dput:\fR option |...
 Specifies a single additional option to pass to
 Specifies a single additional option to pass to
-.BR dget ,
+.BR curl ,
 .BR dput ,
 .BR debsign ,
 .BR dpkg-source ,
 .BR dput ,
 .BR debsign ,
 .BR dpkg-source ,
@@ -663,7 +663,7 @@ interprets it the same way as git does.
 See
 also the --ssh= and --ssh: options.
 .TP
 See
 also the --ssh= and --ssh: options.
 .TP
-.BR gpg ", " dpkg- "..., " debsign ", " git ", " dget ", " dput ", " LWP::UserAgent
+.BR gpg ", " dpkg- "..., " debsign ", " git ", " curl ", " dput ", " LWP::UserAgent
 and other subprograms and modules used by dgit are affected by various
 environment variables.  Consult the documentaton for those programs
 for details.
 and other subprograms and modules used by dgit are affected by various
 environment variables.  Consult the documentaton for those programs
 for details.
@@ -728,7 +728,7 @@ well-defined interface, let alone a secure one.)
 fetches may result in subsequent actions being different.  Doing a
 non-dry-run dgit fetch first will help.
 .SH SEE ALSO
 fetches may result in subsequent actions being different.  Doing a
 non-dry-run dgit fetch first will help.
 .SH SEE ALSO
-\fBdget\fP(1),
+\fBcurl\fP(1),
 \fBdput\fP(1),
 \fBdebsign\fP(1),
 \fBgit-config\fP(1),
 \fBdput\fP(1),
 \fBdebsign\fP(1),
 \fBgit-config\fP(1),