Преглед изворни кода

dpkg-source: new option --abort-on-upstream-changes

This option can be used with source formats 1.0, 2.0 and 3.0 (quilt). It
aborts every time that you try to build a source package which
contains (unmanaged) changes to the upstream source code.
Raphaël Hertzog пре 16 година
родитељ
комит
f86ff41434

+ 4 - 0
debian/changelog

@@ -35,6 +35,10 @@ dpkg (1.15.8) UNRELEASED; urgency=low
     2.0 and 3.0 (quilt) that unapplies the patches after a successful build.
     This option can be put in debian/source/local-options in the package VCS
     repository for instance.
+  * Implement new --abort-on-upstream-changes option for dpkg-source with
+    source formats 1.0, 2.0 and 3.0 (quilt). It aborts every time that you try
+    to build a source package which contains (unmanaged) changes to the
+    upstream source code. Closes: #579012
 
   [ Guillem Jover ]
   * Require gettext 0.18:

+ 14 - 0
man/dpkg-source.1

@@ -339,6 +339,13 @@ or raise an error if
 was specified.
 .B \-sA
 is the default.
+.TP
+.B \-\-abort\-on\-upstream\-changes
+The process fails if the generated diff contains changes to files
+outside of the debian sub-directory. This option is not allowed in
+\fBdebian/source/options\fP but can be used in
+\fBdebian/source/local\-options\fP.
+
 .TP
 .B Extract options (with \-x):
 .PP
@@ -515,6 +522,13 @@ even after a package build. This option is usually put in
 \fBdebian/source/local\-options\fP (it's not allowed in
 \fBdebian/source/options\fP so that all generated source packages have the
 same behaviour by default).
+.TP
+.B \-\-abort\-on\-upstream\-changes
+The process fails if an automatic patch has been generated. This option
+can be used to ensure that all changes were properly recorded in separate
+quilt patches prior to the source package build. This option is not
+allowed in \fBdebian/source/options\fP but can be used in
+\fBdebian/source/local\-options\fP.
 
 .PP
 .B Extract options

+ 6 - 0
scripts/Dpkg/Source/Package/V1.pm

@@ -50,6 +50,7 @@ sub init_options {
     }
     $self->{'options'}{'sourcestyle'} ||= 'X';
     $self->{'options'}{'skip_debianization'} ||= 0;
+    $self->{'options'}{'abort_on_upstream_changes'} ||= 0;
 }
 
 sub parse_cmdline_option {
@@ -64,6 +65,9 @@ sub parse_cmdline_option {
     } elsif ($opt =~ m/^--skip-debianization$/) {
         $o->{'skip_debianization'} = 1;
         return 1;
+    } elsif ($opt =~ m/^--abort-on-upstream-changes$/) {
+        $o->{'abort_on_upstream_changes'} = 1;
+        return 1;
     }
     return 0;
 }
@@ -362,6 +366,8 @@ sub do_build {
 	            "\n " . join("\n ", @files));
 	    info(_g("use the '3.0 (quilt)' format to have separate and " .
 	            "documented changes to upstream files, see dpkg-source(1)"));
+	    error(_g("aborting due to --abort-on-upstream-changes"))
+		if $self->{'options'}{'abort_on_upstream_changes'};
 	}
 
 	rename($newdiffgz, $diffname) ||

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

@@ -59,6 +59,8 @@ sub init_options {
         unless exists $self->{'options'}{'skip_debianization'};
     $self->{'options'}{'create_empty_orig'} = 0
         unless exists $self->{'options'}{'create_empty_orig'};
+    $self->{'options'}{'abort_on_upstream_changes'} = 0
+        unless exists $self->{'options'}{'abort_on_upstream_changes'};
 }
 
 sub parse_cmdline_option {
@@ -87,6 +89,9 @@ sub parse_cmdline_option {
     } elsif ($opt =~ /^--create-empty-orig$/) {
         $self->{'options'}{'create_empty_orig'} = 1;
         return 1;
+    } elsif ($opt =~ /^--abort-on-upstream-changes$/) {
+        $self->{'options'}{'abort_on_upstream_changes'} = 1;
+        return 1;
     }
     return 0;
 }
@@ -446,6 +451,9 @@ sub do_build {
                 syserr(_g("unable to change permission of `%s'"), $autopatch);
     }
     $self->register_autopatch($dir);
+    if (-e $autopatch and $self->{'options'}{'abort_on_upstream_changes'}) {
+        error(_g("aborting due to --abort-on-upstream-changes"));
+    }
     rmdir(File::Spec->catdir($dir, "debian", "patches")); # No check on purpose
     pop @Dpkg::Exit::handlers;
 

+ 1 - 1
scripts/dpkg-source.pl

@@ -110,7 +110,7 @@ if (defined($options{'opmode'}) &&
     # --unapply-patches is only allowed in local-options as it's a matter
     # of personal taste and the default should be to keep patches applied
     my $forbidden_opts_re = {
-	"options" => qr/^--(?:format=|unapply-patches$)/,
+	"options" => qr/^--(?:format=|unapply-patches$|abort-on-upstream-changes$)/,
 	"local-options" => qr/^--format=/,
     };
     foreach my $filename ("local-options", "options") {