+ return ($authline, $r1authline, $clogp, $changes);
+}
+
+sub generate_commits_from_dsc () {
+ # See big comment in fetch_from_archive, below.
+ # See also README.dsc-import.
+ prep_ud();
+ changedir $playground;
+
+ my $bpd_abs = bpd_abs();
+ my $upstreamv = upstreamversion $dsc->{version};
+ my @dfi = dsc_files_info();
+
+ dotdot_bpd_transfer_origs $bpd_abs, $upstreamv,
+ sub { grep { $_->{Filename} eq $_[0] } @dfi };
+
+ foreach my $fi (@dfi) {
+ my $f = $fi->{Filename};
+ die "$f ?" if $f =~ m#/|^\.|\.dsc$|\.tmp$#;
+ my $upper_f = "$bpd_abs/$f";
+
+ printdebug "considering reusing $f: ";
+
+ if (link_ltarget "$upper_f,fetch", $f) {
+ printdebug "linked (using ...,fetch).\n";
+ } elsif ((printdebug "($!) "),
+ $! != ENOENT) {
+ fail f_ "accessing %s: %s", "$buildproductsdir/$f,fetch", $!;
+ } elsif (link_ltarget $upper_f, $f) {
+ printdebug "linked.\n";
+ } elsif ((printdebug "($!) "),
+ $! != ENOENT) {
+ fail f_ "accessing %s: %s", "$buildproductsdir/$f", $!;
+ } else {
+ printdebug "absent.\n";
+ }
+
+ my $refetched;
+ complete_file_from_dsc('.', $fi, \$refetched)
+ or next;
+
+ printdebug "considering saving $f: ";
+
+ if (rename_link_xf 1, $f, $upper_f) {
+ printdebug "linked.\n";
+ } elsif ((printdebug "($@) "),
+ $! != EEXIST) {
+ fail f_ "saving %s: %s", "$buildproductsdir/$f", $@;
+ } elsif (!$refetched) {
+ printdebug "no need.\n";
+ } elsif (rename_link_xf 1, $f, "$upper_f,fetch") {
+ printdebug "linked (using ...,fetch).\n";
+ } elsif ((printdebug "($@) "),
+ $! != EEXIST) {
+ fail f_ "saving %s: %s", "$buildproductsdir/$f,fetch", $@;
+ } else {
+ printdebug "cannot.\n";
+ }
+ }
+
+ my @tartrees;
+ @tartrees = import_tarball_tartrees($upstreamv, \@dfi)
+ unless @dfi == 1; # only one file in .dsc
+
+ my $dscfn = "$package.dsc";
+
+ my $treeimporthow = 'package';
+
+ open D, ">", $dscfn or die "$dscfn: $!";
+ print D $dscdata or die "$dscfn: $!";
+ close D or die "$dscfn: $!";
+ my @cmd = qw(dpkg-source);
+ push @cmd, '--no-check' if $dsc_checked;
+ if (madformat $dsc->{format}) {
+ push @cmd, '--skip-patches';
+ $treeimporthow = 'unpatched';
+ }
+ push @cmd, qw(-x --), $dscfn;
+ runcmd @cmd;
+
+ my ($tree,$dir) = mktree_in_ud_from_only_subdir(__ "source package");
+ if (madformat $dsc->{format}) {
+ check_for_vendor_patches();
+ }
+
+ my $dappliedtree;
+ if (madformat $dsc->{format}) {
+ my @pcmd = qw(dpkg-source --before-build .);
+ runcmd shell_cmd 'exec >/dev/null', @pcmd;
+ rmtree '.pc';
+ $dappliedtree = git_add_write_tree();
+ }
+
+ my ($authline, $r1authline, $clogp, $changes) =
+ import_tarball_commits(\@tartrees, $upstreamv);
+
+ my $cversion = getfield $clogp, 'Version';
+