[debhelper-devel] [debhelper] 04/28: dh_gencontrol: Create ddebs as M-A: same or without a M-A field

Niels Thykier nthykier at moszumanska.debian.org
Sun Jun 28 12:57:15 UTC 2015


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit 4386d1a4e83e20820d61193cec0324cf2b346ede
Author: Niels Thykier <niels at thykier.net>
Date:   Fri May 15 15:56:00 2015 +0200

    dh_gencontrol: Create ddebs as M-A: same or without a M-A field
    
    Unless the original package is "Multi-Arch: same", there is no reason
    for the ddeb to have a "Multi-Arch" field.
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Dh_Lib.pm | 30 +++++++++++++++++++++++-------
 dh_gencontrol              | 10 +++++++++-
 2 files changed, 32 insertions(+), 8 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index c0da230..d144017 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -21,7 +21,7 @@ use vars qw(@ISA @EXPORT %dh);
 	    &dpkg_architecture_value &sourcepackage &make_symlink
 	    &is_make_jobserver_unavailable &clean_jobserver_makeflags
 	    &cross_command &set_buildflags &get_buildoption
-	    &install_dh_config_file &ddeb_filename
+	    &install_dh_config_file &ddeb_filename &package_multiarch
 	    &install_file &install_prog &install_lib &install_dir
 );
 
@@ -838,22 +838,20 @@ sub sourcepackage {
 #
 # As a side effect, populates %package_arches and %package_types
 # with the types of all packages (not only those returned).
-my (%package_types, %package_arches);
+my (%package_types, %package_arches, %package_multiarches);
 sub getpackages {
 	my $type=shift;
 
 	%package_types=();
 	%package_arches=();
+	%package_multiarches=();
 	
 	$type="" if ! defined $type;
 
 	my $package="";
 	my $arch="";
-	my $package_type;
-	my @list=();
-	my %seen;
-	my @profiles=();
-	my $included_in_build_profile;
+	my ($package_type, $multiarch, @list, %seen, @profiles,
+		$included_in_build_profile);
 	if (exists $ENV{'DEB_BUILD_PROFILES'}) {
 		@profiles=split /\s+/, $ENV{'DEB_BUILD_PROFILES'};
 	}
@@ -880,6 +878,9 @@ sub getpackages {
 		if (/^(?:X[BC]*-)?Package-Type:\s*(.*)/i) {
 			$package_type=$1;
 		}
+		if (/^Multi-Arch: \s*(.*)\s*/i) {
+			$multiarch = $1;
+		}
 		# rely on libdpkg-perl providing the parsing functions because
 		# if we work on a package with a Build-Profiles field, then a
 		# high enough version of dpkg-dev is needed anyways
@@ -901,6 +902,7 @@ sub getpackages {
 			if ($package) {
 				$package_types{$package}=$package_type;
 				$package_arches{$package}=$arch;
+				$package_multiarches{$package} = $multiarch;
 			}
 
 			if ($package && $included_in_build_profile &&
@@ -933,6 +935,20 @@ sub package_arch {
 	return $package_arches{$package} eq 'all' ? "all" : buildarch();
 }
 
+# Returns the multiarch value of a package.
+sub package_multiarch {
+	my $package=shift;
+
+	# Test the architecture field instead, as it is common for a
+	# package to not have a multi-arch value.
+	if (! exists $package_arches{$package}) {
+		warning "package $package is not in control info";
+		# The only sane default
+		return 'no';
+	}
+	return $package_multiarches{$package} // 'no';
+}
+
 # Return true if a given package is really a udeb.
 sub is_udeb {
 	my $package=shift;
diff --git a/dh_gencontrol b/dh_gencontrol
index 7107c4b..a987499 100755
--- a/dh_gencontrol
+++ b/dh_gencontrol
@@ -76,12 +76,14 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	if ( -d $ddeb_tmp) {
 		my $arch = package_arch($package);
 		my $ddeb_filename = ddeb_filename($package);
+		my $multiarch = package_multiarch($package);
 		$src_pkg = sourcepackage() if not defined($src_pkg);
+
 		# Remove and override more or less every standard field.
 		my @ddeb_options = (qw(
 			-UPre-Depends -URecommends -USuggests -UEnhances -UProvides -UEssential
 			-UReplaces -UBreaks -UConflicts
-			-DPriority=extra -DSection=debug -DMulti-Arch=same
+			-DPriority=extra -DSection=debug
 			),
 			 "-DPackage=${package}-dbgsym",
 			 "-DDepends=${package}:${arch} (= \${binary:Version})",
@@ -89,6 +91,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			 "-DSource=${src_pkg}",
 			 "-n${ddeb_filename}",
 		);
+		# Disable multi-arch unless the original package is an
+		# multi-arch: same package.  In all other cases, we do not
+		# need a multi-arch value.
+		if ($multiarch ne 'same') {
+			push(@ddeb_options, '-UMulti-Arch');
+		}
 		if ( ! -d "${ddeb_tmp}/DEBIAN" ) {
 			install_dir("${ddeb_tmp}/DEBIAN");
                 }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list