[debhelper-devel] [debhelper] 02/06: Dh_Lib: Let X-DH-Buildlabel influence default_sourcedir

Niels Thykier nthykier at moszumanska.debian.org
Sun Jul 16 18:14:12 UTC 2017


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

nthykier pushed a commit to branch easier-multi-builds
in repository debhelper.

commit 78968f906b286172665572e2de0d5fb074d70fcf
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Jul 16 15:26:53 2017 +0000

    Dh_Lib: Let X-DH-Buildlabel influence default_sourcedir
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Dh_Lib.pm | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 34c55c3..bf94d45 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -63,7 +63,7 @@ our (@EXPORT, %dh);
 	    XARGS_INSERT_PARAMS_HERE &glob_expand_error_handler_reject
 	    &glob_expand_error_handler_warn_and_discard &glob_expand
 	    &glob_expand_error_handler_silently_ignore DH_BUILTIN_VERSION
-	    &default_sourcedir
+	    &default_sourcedir &package_dh_option
 );
 
 # The Makefile changes this if debhelper is installed in a PREFIX.
@@ -643,6 +643,10 @@ sub tmpdir {
 # use, for that package.  (Usually debian/tmp)
 sub default_sourcedir {
 	my ($package) = @_;
+	my $label = package_dh_option($package, 'buildlabel');
+	if (defined($label)) {
+		return "debian/tmp-${label}";
+	}
 
 	return 'debian/tmp';
 }
@@ -1210,7 +1214,7 @@ 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, %package_multiarches, %packages_by_type,
-    %package_sections);
+    %package_sections, %packages_dh_opts);
 sub getpackages {
 	my ($type) = @_;
 	error("getpackages: First argument must be one of \"arch\", \"indep\", or \"both\"")
@@ -1228,6 +1232,7 @@ sub getpackages {
 	my $package="";
 	my $arch="";
 	my $section="";
+	my $dh_opts = {};
 	my ($package_type, $multiarch, %seen, @profiles, $source_section,
 		$included_in_build_profile);
 	if (exists $ENV{'DEB_BUILD_PROFILES'}) {
@@ -1256,7 +1261,8 @@ sub getpackages {
 			$package_type=$1;
 		} elsif (/^Multi-Arch:\s*(.*)/i) {
 			$multiarch = $1;
-
+		} elsif (/^X-DH-([^:\s]+):\s*(.*)/i) {
+			$dh_opts->{lc($1)} = $2;
 		} elsif (/^Build-Profiles:\s*(.*)/i) {
 			# rely on libdpkg-perl providing the parsing functions
 			# because if we work on a package with a Build-Profiles
@@ -1281,6 +1287,7 @@ sub getpackages {
 				$package_arches{$package}=$arch;
 				$package_multiarches{$package} = $multiarch;
 				$package_sections{$package} = $section || $source_section;
+				$packages_dh_opts{$package} = $dh_opts;
 				if ($included_in_build_profile) {
 					push(@{$packages_by_type{'all-listed-in-control-file'}}, $package);
 					if ($arch eq 'all') {
@@ -1299,6 +1306,7 @@ sub getpackages {
 			$package_type=undef;
 			$arch='';
 			$section='';
+			$dh_opts = {};
 		}
 	}
 	close($fd);
@@ -1376,6 +1384,19 @@ sub package_section {
 	return $package_sections{$package} // 'unknown';
 }
 
+# Returns the value of a "X-DH-${field}" field from d/control when given $package + $field.
+# - undef is returned if the field is not set
+# - Dh_Lib normalizes field names to all lowercase, so $field should always be in all lowercase.
+sub package_dh_option {
+	my ($package, $field) = @_;
+
+	if (! exists $packages_dh_opts{$package}) {
+		warning "package $package is not in control info";
+		return;
+	}
+	return $packages_dh_opts{$package}{$field};
+}
+
 # Return true if a given package is really a udeb.
 sub is_udeb {
 	my $package=shift;

-- 
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