Просмотр исходного кода

dpkg-buildpackage: Add support for host and target long flags

These are passed through to dpkg-architecture if specified.

This restores the ability to specify the target architecture when
building cross-compilers.

Regression introduced in commit f29ed62d0c340869752c61d55a2df74159c31625.

Reported-by: Helmut Grohne <helmut@subdivi.de>
Guillem Jover лет назад: 11
Родитель
Сommit
e16a76d241
3 измененных файлов с 51 добавлено и 14 удалено
  1. 5 0
      debian/changelog
  2. 13 4
      man/dpkg-buildpackage.1
  3. 33 10
      scripts/dpkg-buildpackage.pl

+ 5 - 0
debian/changelog

@@ -28,6 +28,11 @@ dpkg (1.17.17) UNRELEASED; urgency=low
   * Normalize dpkg-architecture command-line parsing, so that «--option=value»
   * Normalize dpkg-architecture command-line parsing, so that «--option=value»
     «--option value», «-ovalue» and «-o value» will all be accepted.
     «--option value», «-ovalue» and «-o value» will all be accepted.
   * Add long option names for all dpkg-architecture short options.
   * Add long option names for all dpkg-architecture short options.
+  * Add support for --host-arch, --host-type, --target-arch and --target-type
+    long options in dpkg-buildpackage. These will get passed through to
+    dpkg-architecture. This restores the ability to specify the target
+    architecture when building cross-compilers. Regression introduced in
+    dpkg 1.17.14. Reported by Helmut Grohne <helmut@subdivi.de>.
 
 
   [ Updated programs translations ]
   [ Updated programs translations ]
   * German (Sven Joachim).
   * German (Sven Joachim).

+ 13 - 4
man/dpkg-buildpackage.1

@@ -139,15 +139,24 @@ run with root rights.
 .BI \-e maintainer-address
 .BI \-e maintainer-address
 Passed unchanged to \fBdpkg\-genchanges\fP. See its manual page.
 Passed unchanged to \fBdpkg\-genchanges\fP. See its manual page.
 .TP
 .TP
-.BI \-a architecture
+.BR \-a ", " \-\-host\-arch " \fIarchitecture\fP"
 Specify the Debian architecture we build for. The architecture of the
 Specify the Debian architecture we build for. The architecture of the
 machine we build on is determined automatically, and is also the default
 machine we build on is determined automatically, and is also the default
 for the host machine.
 for the host machine.
 .TP
 .TP
-.BI \-t gnu-system-type
+.BR \-t ", " \-\-host\-type " \fIgnu-system-type\fP"
 Specify the GNU system type we build for. It can be used in place
 Specify the GNU system type we build for. It can be used in place
-of \-a or as a complement to override the default GNU system type
-of the target Debian architecture.
+of \-\-host\-arch or as a complement to override the default GNU system type
+of the host Debian architecture.
+.TP
+.BR \-\-target\-arch " \fIarchitecture\fP"
+Specify the Debian architecture the binaries built will build for.
+The default value is the host machine.
+.TP
+.BR \-\-target\-type " \fIgnu-system-type\fP"
+Specify the GNU system type the binaries built will build for. It can be
+used in place of \-\-target\-arch or as a complement to override the
+default GNU system type of the target Debian architecture.
 .TP
 .TP
 .BR \-P \fIprofile\fP[ , ...]
 .BR \-P \fIprofile\fP[ , ...]
 Specify the profile(s) we build, as a comma-separated list. The default
 Specify the profile(s) we build, as a comma-separated list. The default

+ 33 - 10
scripts/dpkg-buildpackage.pl

@@ -100,8 +100,10 @@ sub usage {
       --version  show the version.')
       --version  show the version.')
     . "\n\n" . _g(
     . "\n\n" . _g(
 'Options passed to dpkg-architecture:
 'Options passed to dpkg-architecture:
-  -a<arch>       Debian architecture we build for.
-  -t<system>     set GNU system type.')
+  -a, --host-arch <arch>    set the host Debian architecture.
+  -t, --host-type <type>    set the host GNU system type.
+      --target-arch <arch>  set the target Debian architecture.
+      --target-type <type>  set the target GNU system type.')
     . "\n\n" . _g(
     . "\n\n" . _g(
 'Options passed to dpkg-genchanges:
 'Options passed to dpkg-genchanges:
   -si (default)  source includes orig, if new upstream.
   -si (default)  source includes orig, if new upstream.
@@ -145,8 +147,10 @@ my $signsource = 1;
 my $signchanges = 1;
 my $signchanges = 1;
 my $buildtarget = 'build';
 my $buildtarget = 'build';
 my $binarytarget = 'binary';
 my $binarytarget = 'binary';
-my $targetarch = '';
-my $targetgnusystem = '';
+my $host_arch = '';
+my $host_type = '';
+my $target_arch = '';
+my $target_type = '';
 my @build_profiles = ();
 my @build_profiles = ();
 my $call_target = '';
 my $call_target = '';
 my $call_target_as_root = 0;
 my $call_target_as_root = 0;
@@ -260,8 +264,10 @@ while (@ARGV) {
 	$signchanges = 0;
 	$signchanges = 0;
     } elsif (/^-ap$/) {
     } elsif (/^-ap$/) {
 	$signpause = 1;
 	$signpause = 1;
-    } elsif (/^-a(.*)$/) {
-	$targetarch = $1;
+    } elsif (/^-a$/ or /^--host-arch$/) {
+	$host_arch = shift;
+    } elsif (/^-a(.*)$/ or /^--host-arch=(.*)$/) {
+	$host_arch = $1;
     } elsif (/^-P(.*)$/) {
     } elsif (/^-P(.*)$/) {
 	my $arg = $1;
 	my $arg = $1;
 	@build_profiles = split /,/, $arg;
 	@build_profiles = split /,/, $arg;
@@ -271,8 +277,18 @@ while (@ARGV) {
 	push @source_opts, $_; # passed to dpkg-source
 	push @source_opts, $_; # passed to dpkg-source
     } elsif (/^-tc$/) {
     } elsif (/^-tc$/) {
 	$cleansource = 1;
 	$cleansource = 1;
-    } elsif (/^-t(.*)$/) {
-	$targetgnusystem = $1; # Order DOES matter!
+    } elsif (/^-t$/ or /^--host-type$/) {
+	$host_type = shift; # Order DOES matter!
+    } elsif (/^-t(.*)$/ or /^--host-type=(.*)$/) {
+	$host_type = $1; # Order DOES matter!
+    } elsif (/^--target-arch$/) {
+	$target_arch = shift;
+    } elsif (/^--target-arch=(.*)$/) {
+	$target_arch = $1;
+    } elsif (/^--target-type$/) {
+	$target_type = shift;
+    } elsif (/^--target-type=(.*)$/) {
+	$target_type = $1;
     } elsif (/^(?:--target|-T)$/) {
     } elsif (/^(?:--target|-T)$/) {
         $call_target = shift @ARGV;
         $call_target = shift @ARGV;
     } elsif (/^(?:--target=|-T)(.+)$/) {
     } elsif (/^(?:--target=|-T)(.+)$/) {
@@ -411,8 +427,15 @@ if ($changedby) {
     $maintainer = mustsetvar($changelog->{maintainer}, _g('source changed by'));
     $maintainer = mustsetvar($changelog->{maintainer}, _g('source changed by'));
 }
 }
 
 
-open my $arch_env, '-|', 'dpkg-architecture', "-a$targetarch",
-    "-t$targetgnusystem", '-f' or subprocerr('dpkg-architecture');
+
+my @arch_opts;
+push @arch_opts, ('--host-arch', $host_arch) if $host_arch;
+push @arch_opts, ('--host-type', $host_type) if $host_type;
+push @arch_opts, ('--target-arch', $target_arch) if $target_arch;
+push @arch_opts, ('--target-type', $target_type) if $target_type;
+
+open my $arch_env, '-|', 'dpkg-architecture', '-f', @arch_opts
+    or subprocerr('dpkg-architecture');
 while (<$arch_env>) {
 while (<$arch_env>) {
     chomp;
     chomp;
     my ($key, $value) = split /=/, $_, 2;
     my ($key, $value) = split /=/, $_, 2;