[debhelper-devel] [debhelper] 02/09: Let dh_auto_install provide default source dir via --buildlabel

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 aece752cca474ffd449e9a838edafd53a613d4f5
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Jul 16 15:50:51 2017 +0000

    Let dh_auto_install provide default source dir via --buildlabel
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 Debian/Debhelper/Dh_Buildsystems.pm |  3 +++
 Debian/Debhelper/Dh_Lib.pm          | 16 ++++++++++++----
 dh_auto_build                       |  7 +++++++
 dh_auto_clean                       |  7 +++++++
 dh_auto_configure                   |  7 +++++++
 dh_auto_install                     | 34 ++++++++++++++++++++++++++++++----
 dh_auto_test                        |  7 +++++++
 7 files changed, 73 insertions(+), 8 deletions(-)

diff --git a/Debian/Debhelper/Dh_Buildsystems.pm b/Debian/Debhelper/Dh_Buildsystems.pm
index 7d4b421..cc0f5c5 100644
--- a/Debian/Debhelper/Dh_Buildsystems.pm
+++ b/Debian/Debhelper/Dh_Buildsystems.pm
@@ -178,6 +178,8 @@ sub buildsystems_init {
 	    "S=s" => \$opt_buildsys,
 	    "buildsystem=s" => \$opt_buildsys,
 
+	    'buildlabel=s' => \$dh{BUILDLABEL},
+
 	    "l" => \$opt_list,
 	    "list" => \$opt_list,
 
@@ -189,6 +191,7 @@ sub buildsystems_init {
 	Debian::Debhelper::Dh_Lib::init(%args);
 	Debian::Debhelper::Dh_Lib::set_buildflags();
 	set_parallel($max_parallel);
+	$dh{BUILDLABEL} //= 'default';
 }
 
 sub set_parallel {
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index 63ac68e..9eac452 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -681,10 +681,18 @@ 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}";
-	}
+	my $label = package_dh_option($package, 'buildlabel') // 'default';
+	my $label_file = "debian/.debhelper/buildlabels/${label}/install-dir";
+	if (-f $label_file) {
+		my $dest_dir;
+		open(my $fd, '<', $label_file) or error("open($label_file): $!");
+		$dest_dir = <$fd>;
+		close($fd);
+		error("Internal error: No install path for ${label} !?") if not defined($dest_dir);
+		chomp($dest_dir);
+		return $dest_dir;
+	}
+	return "debian/tmp-${label}" if $label ne 'default';
 
 	return 'debian/tmp';
 }
diff --git a/dh_auto_build b/dh_auto_build
index c189a21..0035de0 100755
--- a/dh_auto_build
+++ b/dh_auto_build
@@ -36,6 +36,13 @@ system selection and control options.
 
 =over 4
 
+=item B<--buildlabel=>I<label>
+
+Set the label for this command.  If all packages related to the chosen label is
+skipped, the command will skip the build.
+
+If omitted, the command behaves like B<--buildlabel> was set to I<default>.
+
 =item B<--> I<params>
 
 Pass I<params> to the program that is run, after the parameters that
diff --git a/dh_auto_clean b/dh_auto_clean
index e71448e..01d044c 100755
--- a/dh_auto_clean
+++ b/dh_auto_clean
@@ -37,6 +37,13 @@ system selection and control options.
 
 =over 4
 
+=item B<--buildlabel=>I<label>
+
+Set the label for this command.  If all packages related to the chosen label is
+skipped, the command will skip the build.
+
+If omitted, the command behaves like B<--buildlabel> was set to I<default>.
+
 =item B<--> I<params>
 
 Pass I<params> to the program that is run, after the parameters that
diff --git a/dh_auto_configure b/dh_auto_configure
index 4bd1b36..4f46000 100755
--- a/dh_auto_configure
+++ b/dh_auto_configure
@@ -39,6 +39,13 @@ system selection and control options.
 
 =over 4
 
+=item B<--buildlabel=>I<label>
+
+Set the label for this command.  If all packages related to the chosen label is
+skipped, the command will skip the build.
+
+If omitted, the command behaves like B<--buildlabel> was set to I<default>.
+
 =item B<--> I<params>
 
 Pass I<params> to the program that is run, after the parameters that
diff --git a/dh_auto_install b/dh_auto_install
index 6b34eb1..d1b218a 100755
--- a/dh_auto_install
+++ b/dh_auto_install
@@ -31,9 +31,9 @@ so B<dh_auto_install> will not install files built using Ant.
 
 Unless B<--destdir> option is specified, the files are installed into
 debian/I<package>/ if there is only one binary package. In the multiple binary
-package case, the files are instead installed into F<debian/tmp/>, and should be
-moved from there to the appropriate package build directory using
-L<dh_install(1)>.
+package case, the files are instead installed into F<debian/tmp/> (or
+F<< debian/tmp-I<label> >> with B<--buildlabel>), and should be moved from
+there to the appropriate package build directory using L<dh_install(1)>.
 
 B<DESTDIR> is used to tell make where to install the files. 
 If the Makefile was generated by MakeMaker from a F<Makefile.PL>, it will
@@ -50,12 +50,24 @@ system selection and control options.
 
 =over 4
 
+=item B<--buildlabel=>I<label>
+
+Set the label for this command.  If all packages related to the chosen label is
+skipped, the command will skip the build.
+
+If omitted, the command behaves like B<--buildlabel> was set to I<default>.  The
+I<default> buildlabel uses F<debian/tmp> as default destination directory.
+
 =item B<--destdir=>I<directory>
 
 Install files into the specified I<directory>. If this option is not specified,
 destination directory is determined automatically as described in the
 L</B<DESCRIPTION>> section.
 
+Other tools B<debhelper> tools that support the B<--sourcedir> option will
+default to using the specified directory for packages related to the selected
+buildlabel.
+
 =item B<--> I<params>
 
 Pass I<params> to the program that is run, after the parameters that
@@ -65,7 +77,7 @@ B<dh_auto_install> usually passes.
 
 =cut
 
-my $destdir;
+my ($destdir, $orig_dest_dir);
 
 buildsystems_init(options => {
 	"destdir=s" => \$destdir,
@@ -76,10 +88,13 @@ if (!$destdir) {
 	my @allpackages=getpackages();
 	if (@allpackages > 1) {
 		$destdir="debian/tmp";
+		$destdir="debian/tmp-$dh{BUILDLABEL}" if $dh{BUILDLABEL} ne 'default';
 	}
 	else {
 		$destdir=tmpdir($dh{MAINPACKAGE});
 	}
+} else {
+	$orig_dest_dir = $destdir;
 }
 $destdir = File::Spec->rel2abs($destdir, cwd());
 
@@ -92,6 +107,17 @@ if (compat(10)) {
 
 buildsystems_do("install", $destdir);
 
+my $label_dir = "debian/.debhelper/buildlabels/$dh{BUILDLABEL}";
+if (defined($orig_dest_dir)) {
+	# only set this, if we are not using the default
+	install_dir($label_dir);
+	open(my $fd, '>', "${label_dir}/install-dir") or error("open(${label_dir}/install-dir): $!");
+	print {$fd} "$orig_dest_dir\n";
+	close($fd) or error("close(${label_dir}/install-dir): $!");
+} else {
+	rm_files("${label_dir}/install-dir");
+}
+
 =head1 SEE ALSO
 
 L<debhelper(7)>
diff --git a/dh_auto_test b/dh_auto_test
index a64bb2d..442d436 100755
--- a/dh_auto_test
+++ b/dh_auto_test
@@ -38,6 +38,13 @@ system selection and control options.
 
 =over 4
 
+=item B<--buildlabel=>I<label>
+
+Set the label for this command.  If all packages related to the chosen label is
+skipped, the command will skip the build.
+
+If omitted, the command behaves like B<--buildlabel> was set to I<default>.
+
 =item B<--> I<params>
 
 Pass I<params> to the program that is run, after the parameters that

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