Przeglądaj źródła

dpkg-source: add --skip-debianization extract option

Extracting a source package with --skip-debianization can be interesting
when you want to import a source package in a VCS and want to import
the upstream sources without having precise knowledge of the internals
of all source package formats. This option is only supported for the
source formats "1.0", "2.0" and "3.0 (quilt)" that handle clearly
identified upstream sources.
Raphael Hertzog 17 lat temu
rodzic
commit
8c651a0531

+ 6 - 0
man/dpkg-source.1

@@ -323,6 +323,9 @@ All the
 .BI \-s X
 options are mutually exclusive. If you specify more than one only the
 last one will be used.
+.TP
+.B \-\-skip\-debianization
+Skips application of the debian diff on top of the upstream sources.
 .
 .SS Format: 2.0
 Also known as wig&pen. This format is not recommended for wide-spread
@@ -439,6 +442,9 @@ apparently unapplied.
 .PP
 .B Extract options
 .TP
+.B \-\-skip\-debianization
+Skips extraction of the debian tarball on top of the upstream sources.
+.TP
 .B \-\-skip\-patches
 Do not apply patches at the end of the extraction.
 .TP

+ 8 - 2
scripts/Dpkg/Source/Package.pm

@@ -124,6 +124,9 @@ sub init_options {
     } else {
         $self->{'options'}{'tar_ignore'} = [ @tar_ignore_default_pattern ];
     }
+    # Skip debianization while specific to some formats has an impact
+    # on code common to all formats
+    $self->{'options'}{'skip_debianization'} ||= 0;
 }
 
 sub initialize {
@@ -346,7 +349,9 @@ sub extract {
     }
 
     # Store format if non-standard so that next build keeps the same format
-    if ($self->{'fields'}{'Format'} ne "1.0") {
+    if ($self->{'fields'}{'Format'} ne "1.0" and
+        not $self->{'options'}{'skip_debianization'})
+    {
         my $srcdir = File::Spec->catdir($newdirectory, "debian", "source");
         my $format_file = File::Spec->catfile($srcdir, "format");
         mkdir($srcdir) unless -e $srcdir;
@@ -362,7 +367,8 @@ sub extract {
         unless ($! == ENOENT) {
             syserr(_g("cannot stat %s"), $rules);
         }
-        warning(_g("%s does not exist"), $rules);
+        warning(_g("%s does not exist"), $rules)
+            unless $self->{'options'}{'skip_debianization'};
     } elsif (-f _) {
         chmod($s[2] | 0111, $rules) ||
             syserr(_g("cannot make %s executable"), $rules);

+ 5 - 1
scripts/Dpkg/Source/Package/V1.pm

@@ -44,6 +44,7 @@ sub init_options {
     # Don't call $self->SUPER::init_options() on purpose, V1.0 has no
     # ignore by default
     $self->{'options'}{'sourcestyle'} ||= 'X';
+    $self->{'options'}{'skip_debianization'} ||= 0;
 }
 
 sub parse_cmdline_option {
@@ -55,6 +56,9 @@ sub parse_cmdline_option {
         $o->{'sourcestyle'} = $1;
         $o->{'copy_orig_tarballs'} = 0 if $1 eq 'n'; # Extract option -sn
         return 1;
+    } elsif ($opt =~ m/^--skip-debianization$/) {
+        $o->{'skip_debianization'} = 1;
+        return 1;
     }
     return 0;
 }
@@ -135,7 +139,7 @@ sub do_extract {
         }
     }
 
-    if ($difffile) {
+    if ($difffile and not $self->{'options'}{'skip_debianization'}) {
         my $patch = "$dscdir$difffile";
 	info(_g("applying %s"), $difffile);
 	my $patch_obj = Dpkg::Source::Patch->new(filename => $patch);

+ 8 - 1
scripts/Dpkg/Source/Package/V2.pm

@@ -53,7 +53,8 @@ sub init_options {
         unless exists $self->{'options'}{'preparation'};
     $self->{'options'}{'skip_patches'} = 0
         unless exists $self->{'options'}{'skip_patches'};
-
+    $self->{'options'}{'skip_debianization'} = 0
+        unless exists $self->{'options'}{'skip_debianization'};
 }
 
 sub parse_cmdline_option {
@@ -73,6 +74,9 @@ sub parse_cmdline_option {
     } elsif ($opt =~ /^--skip-patches$/) {
         $self->{'options'}{'skip_patches'} = 1;
         return 1;
+    } elsif ($opt =~ /^--skip-debianization$/) {
+        $self->{'options'}{'skip_debianization'} = 1;
+        return 1;
     }
     return 0;
 }
@@ -129,6 +133,9 @@ sub do_extract {
         $tar->extract("$newdirectory/$subdir", no_fixperms => 1);
     }
 
+    # Stop here if debianization is not wanted
+    return if $self->{'options'}{'skip_debianization'};
+
     # Extract debian tarball after removing the debian directory
     info(_g("unpacking %s"), $debianfile);
     erasedir("$newdirectory/debian");