[debhelper-devel] [debhelper] 01/09: Dh_Lib: Let X-DH-Buildlabel influence default_sourcedir

Niels Thykier nthykier at moszumanska.debian.org
Sat Jul 29 19:01:18 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 92eaf7d0d8d57f6814ef12837f455625a1403f7a
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 ++++++++++++++++++++++++---
 dh_install                 |  4 ++--
 dh_installexamples         |  4 ++--
 dh_installman              |  4 ++--
 4 files changed, 30 insertions(+), 9 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 6e8c630..63ac68e 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
-	    &print_and_complex_doit &default_sourcedir
+	    &print_and_complex_doit &default_sourcedir &package_dh_option
 );
 
 # The Makefile changes this if debhelper is installed in a PREFIX.
@@ -681,6 +681,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';
 }
@@ -1278,7 +1282,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\"")
@@ -1294,6 +1298,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'}) {
@@ -1328,7 +1333,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
@@ -1354,6 +1360,7 @@ sub getpackages {
 				$package_multiarches{$package} = $multiarch;
 				$package_sections{$package} = $section || $source_section;
 				push(@{$packages_by_type{'all-listed-in-control-file'}}, $package);
+				$packages_dh_opts{$package} = $dh_opts;
 				if ($included_in_build_profile) {
 					if ($arch eq 'all') {
 						push(@{$packages_by_type{'indep'}}, $package);
@@ -1371,6 +1378,7 @@ sub getpackages {
 			$package_type=undef;
 			$arch='';
 			$section='';
+			$dh_opts = {};
 		}
 	}
 	close($fd);
@@ -1448,6 +1456,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;
diff --git a/dh_install b/dh_install
index 269e123..699fe83 100755
--- a/dh_install
+++ b/dh_install
@@ -107,8 +107,8 @@ Look in the specified directory for files to be installed.
 
 Note that this is not the same as the B<--sourcedirectory> option used
 by the B<dh_auto_>I<*> commands. You rarely need to use this option, since
-B<dh_install> automatically looks for files in F<debian/tmp> in debhelper
-compatibility level 7 and above.
+B<dh_install> automatically looks for files in default destination directory
+in debhelper compatibility level 7 and above.
 
 =item B<--autodest>
 
diff --git a/dh_installexamples b/dh_installexamples
index f11d1c5..5ded83d 100755
--- a/dh_installexamples
+++ b/dh_installexamples
@@ -48,8 +48,8 @@ requires compat 11 or later (it is silently ignored in compat 10 or earlier).
 
 Note that this is not the same as the B<--sourcedirectory> option used
 by the B<dh_auto_>I<*> commands. You rarely need to use this option, since
-B<dh_installexamples> automatically looks for files in F<debian/tmp> in debhelper
-compatibility level 11 and above.
+B<dh_installexamples> automatically looks for files in default destination
+directory in debhelper compatibility level 11 and above.
 
 =item B<-X>I<item>, B<--exclude=>I<item>
 
diff --git a/dh_installman b/dh_installman
index cfaa6bc..053fcd7 100755
--- a/dh_installman
+++ b/dh_installman
@@ -97,8 +97,8 @@ requires compat 11 or later (it is silently ignored in compat 10 or earlier).
 
 Note that this is not the same as the B<--sourcedirectory> option used
 by the B<dh_auto_>I<*> commands. You rarely need to use this option, since
-B<dh_installman> automatically looks for files in F<debian/tmp> in debhelper
-compatibility level 11 and above.
+B<dh_installman> automatically looks for files in default destination directory
+in debhelper compatibility level 11 and above.
 
 =item I<manpage> ...
 

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