[debhelper-devel] [debhelper] 01/06: Support alternative installation paths

Niels Thykier nthykier at moszumanska.debian.org
Tue Nov 28 14:01:18 UTC 2017


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

nthykier pushed a commit to branch experimental/flatpak-support
in repository debhelper.

commit 305b23546150badf9bb26e7f64c1f0c1eb097257
Author: Niels Thykier <niels at thykier.net>
Date:   Sun Oct 2 17:08:51 2016 +0000

    Support alternative installation paths
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 lib/Debian/Debhelper/Buildsystem/autoconf.pm       | 24 +++++--
 lib/Debian/Debhelper/Buildsystem/cmake.pm          | 19 ++++--
 lib/Debian/Debhelper/Buildsystem/perl_build.pm     |  4 +-
 lib/Debian/Debhelper/Buildsystem/perl_makemaker.pm |  4 +-
 .../Debhelper/Buildsystem/python_distutils.pm      |  6 +-
 lib/Debian/Debhelper/Buildsystem/qmake.pm          |  9 +--
 lib/Debian/Debhelper/Dh_Lib.pm                     | 76 +++++++++++++++++++++-
 t/buildsystems/autoconf/configure                  |  4 +-
 8 files changed, 124 insertions(+), 22 deletions(-)

diff --git a/lib/Debian/Debhelper/Buildsystem/autoconf.pm b/lib/Debian/Debhelper/Buildsystem/autoconf.pm
index e31951b..26c60f3 100644
--- a/lib/Debian/Debhelper/Buildsystem/autoconf.pm
+++ b/lib/Debian/Debhelper/Buildsystem/autoconf.pm
@@ -8,7 +8,8 @@ package Debian::Debhelper::Buildsystem::autoconf;
 
 use strict;
 use warnings;
-use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value sourcepackage compat);
+use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value sourcepackage compat
+	get_installation_directory);
 use parent qw(Debian::Debhelper::Buildsystem::makefile);
 
 sub DESCRIPTION {
@@ -26,18 +27,27 @@ sub check_auto_buildable {
 	return $this->SUPER::check_auto_buildable(@_);
 }
 
+sub _get_paths {
+	my ($this, @paths) = @_;
+	return map {
+		"--${_}=" . get_installation_directory($_, 'autoconf')
+	} @paths;
+}
+
 sub configure {
 	my $this=shift;
 
 	# Standard set of options for configure.
 	my @opts;
 	push @opts, "--build=" . dpkg_architecture_value("DEB_BUILD_GNU_TYPE");
-	push @opts, "--prefix=/usr";
-	push @opts, "--includedir=\${prefix}/include";
-	push @opts, "--mandir=\${prefix}/share/man";
-	push @opts, "--infodir=\${prefix}/share/info";
-	push @opts, "--sysconfdir=/etc";
-	push @opts, "--localstatedir=/var";
+	push(@opts, $this->_get_paths(qw(
+			prefix
+			includedir
+			mandir
+			infodir
+			sysconfdir
+			localstatedir
+		)));
 	if (defined $ENV{DH_QUIET} && $ENV{DH_QUIET} ne "") {
 		push @opts, "--enable-silent-rules";
 	} else {
diff --git a/lib/Debian/Debhelper/Buildsystem/cmake.pm b/lib/Debian/Debhelper/Buildsystem/cmake.pm
index 5e3ce08..d614065 100644
--- a/lib/Debian/Debhelper/Buildsystem/cmake.pm
+++ b/lib/Debian/Debhelper/Buildsystem/cmake.pm
@@ -8,15 +8,13 @@ package Debian::Debhelper::Buildsystem::cmake;
 
 use strict;
 use warnings;
-use Debian::Debhelper::Dh_Lib qw(compat dpkg_architecture_value error is_cross_compiling);
+use Debian::Debhelper::Dh_Lib qw(compat dpkg_architecture_value error is_cross_compiling
+	get_installation_directory);
 use parent qw(Debian::Debhelper::Buildsystem::makefile);
 
 my @STANDARD_CMAKE_FLAGS = qw(
-  -DCMAKE_INSTALL_PREFIX=/usr
   -DCMAKE_VERBOSE_MAKEFILE=ON
   -DCMAKE_BUILD_TYPE=None
-  -DCMAKE_INSTALL_SYSCONFDIR=/etc
-  -DCMAKE_INSTALL_LOCALSTATEDIR=/var
   -DCMAKE_EXPORT_NO_PACKAGE_REGISTRY=ON
   -DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=ON
 );
@@ -53,10 +51,21 @@ sub new {
 	return $this;
 }
 
+sub _get_path {
+	my ($this, $cmake_flag, $dh_name) = @_;
+	my $path = get_installation_directory($dh_name);
+	return ("-D${cmake_flag}=${path}");
+}
+
 sub configure {
 	my $this=shift;
 	# Standard set of cmake flags
-	my @flags = @STANDARD_CMAKE_FLAGS;
+	my @flags = (
+		$this->_get_path('CMAKE_INSTALL_PREFIX', 'prefix'),
+		$this->_get_path('CMAKE_INSTALL_SYSCONFDIR', 'sysconfdir'),
+		$this->_get_path('CMAKE_INSTALL_LOCALSTATEDIR', 'localstatedir'),
+		@STANDARD_CMAKE_FLAGS
+	);
 
 	if (not compat(10)) {
 		push(@flags, '-DCMAKE_INSTALL_RUNSTATEDIR=/run');
diff --git a/lib/Debian/Debhelper/Buildsystem/perl_build.pm b/lib/Debian/Debhelper/Buildsystem/perl_build.pm
index 2817797..16af2b7 100644
--- a/lib/Debian/Debhelper/Buildsystem/perl_build.pm
+++ b/lib/Debian/Debhelper/Buildsystem/perl_build.pm
@@ -8,7 +8,7 @@ package Debian::Debhelper::Buildsystem::perl_build;
 
 use strict;
 use warnings;
-use Debian::Debhelper::Dh_Lib qw(compat);
+use Debian::Debhelper::Dh_Lib qw(compat get_installation_directory);
 use parent qw(Debian::Debhelper::Buildsystem);
 use Config;
 
@@ -42,6 +42,8 @@ sub new {
 sub configure {
 	my $this=shift;
 	my (@flags, @perl_flags);
+	my $prefix = get_installation_directory('prefix');
+	push(@flags, '--prefix', $prefix) if $prefix ne '/usr';
 	$ENV{PERL_MM_USE_DEFAULT}=1;
 	if ($ENV{CFLAGS} && ! compat(8)) {
 		push @flags, "--config", "optimize=$ENV{CFLAGS} $ENV{CPPFLAGS}";
diff --git a/lib/Debian/Debhelper/Buildsystem/perl_makemaker.pm b/lib/Debian/Debhelper/Buildsystem/perl_makemaker.pm
index 6a6f452..657c670 100644
--- a/lib/Debian/Debhelper/Buildsystem/perl_makemaker.pm
+++ b/lib/Debian/Debhelper/Buildsystem/perl_makemaker.pm
@@ -8,7 +8,7 @@ package Debian::Debhelper::Buildsystem::perl_makemaker;
 
 use strict;
 use warnings;
-use Debian::Debhelper::Dh_Lib qw(compat);
+use Debian::Debhelper::Dh_Lib qw(compat get_installation_directory);
 use parent qw(Debian::Debhelper::Buildsystem::makefile);
 use Config;
 
@@ -42,6 +42,8 @@ sub new {
 sub configure {
 	my $this=shift;
 	my (@flags, @perl_flags);
+	my $prefix = get_installation_directory('prefix');
+	push(@flags, '--prefix', $prefix) if $prefix ne '/usr';
 	# If set to a true value then MakeMaker's prompt function will
 	# # always return the default without waiting for user input.
 	$ENV{PERL_MM_USE_DEFAULT}=1;
diff --git a/lib/Debian/Debhelper/Buildsystem/python_distutils.pm b/lib/Debian/Debhelper/Buildsystem/python_distutils.pm
index 4c2a5f8..6cc5bb3 100644
--- a/lib/Debian/Debhelper/Buildsystem/python_distutils.pm
+++ b/lib/Debian/Debhelper/Buildsystem/python_distutils.pm
@@ -10,7 +10,7 @@ package Debian::Debhelper::Buildsystem::python_distutils;
 use strict;
 use warnings;
 use Cwd ();
-use Debian::Debhelper::Dh_Lib qw(error);
+use Debian::Debhelper::Dh_Lib qw(error get_installation_directory);
 use parent qw(Debian::Debhelper::Buildsystem);
 
 sub DESCRIPTION {
@@ -186,11 +186,15 @@ sub build {
 sub install {
 	my $this=shift;
 	my $destdir=shift;
+	my @flags;
+	my $prefix = get_installation_directory('prefix');
+	push(@flags, "--prefix=${prefix}") if $prefix ne '/usr';
 	$this->setup_py("install",
 		"--force",
 		"--root=$destdir",
 		"--no-compile",
 		"-O0",
+		@flags,
 		@_);
 }
 
diff --git a/lib/Debian/Debhelper/Buildsystem/qmake.pm b/lib/Debian/Debhelper/Buildsystem/qmake.pm
index 6e7f87f..1554bba 100644
--- a/lib/Debian/Debhelper/Buildsystem/qmake.pm
+++ b/lib/Debian/Debhelper/Buildsystem/qmake.pm
@@ -8,7 +8,8 @@ package Debian::Debhelper::Buildsystem::qmake;
 
 use strict;
 use warnings;
-use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value error generated_file is_cross_compiling);
+use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value error generated_file is_cross_compiling
+  get_installation_directory);
 use parent qw(Debian::Debhelper::Buildsystem::makefile);
 
 our $qmake="qmake";
@@ -53,8 +54,7 @@ sub check_auto_buildable {
 
 sub configure {
 	my $this=shift;
-	my @options;
-	my @flags;
+	my (@options, @flags, $prefix);
 
 	push @options, '-makefile';
 	if (is_cross_compiling()) {
@@ -112,7 +112,8 @@ sub configure {
 		push @flags, "QMAKE_LFLAGS_DEBUG=$ENV{LDFLAGS}";
 	}
 	push @flags, "QMAKE_STRIP=:";
-	push @flags, "PREFIX=/usr";
+	$prefix = get_installation_directory('prefix');
+	push(@flags, "PREFIX=${prefix}");
 
 	if (is_cross_compiling()) {
 		# qmake calls $$QMAKE_CXX in toolchain.prf to get a list of library/include paths,
diff --git a/lib/Debian/Debhelper/Dh_Lib.pm b/lib/Debian/Debhelper/Dh_Lib.pm
index b44ca7e..97a813a 100644
--- a/lib/Debian/Debhelper/Dh_Lib.pm
+++ b/lib/Debian/Debhelper/Dh_Lib.pm
@@ -69,9 +69,34 @@ our (@EXPORT, %dh);
 	    &compute_doc_main_package &is_so_or_exec_elf_file &hostarch
 	    &assert_opt_is_known_package &dbgsym_tmpdir &find_hardlinks
 	    &should_use_root &gain_root_cmd DEFAULT_PACKAGE_TYPE
-	    DBGSYM_PACKAGE_TYPE
+	    DBGSYM_PACKAGE_TYPE &get_installation_directory
+	    &get_rel_installation_directory
 );
 
+
+# Our default paths for upstream build-systems.  Uses the same names
+# as autoconf's configure scripts (where applicable).
+# Ideally derivatives would be able to override these without having
+# to modify debhelper
+my %INSTALLATION_DIRECTORIES = (
+	'prefix'        => '/usr',
+	'eprefix'       => '${prefix}',
+	'bindir'        => '${eprefix}/bin',
+	'sbindir'       => '${eprefix}/sbin',
+	'sysconfdir'    => '/etc',
+	'localstatedir' => '/var',
+	'runstatedir'   => '/run',
+	#'libdir'        => '${eprefix}/lib/${DEB_BUILD_MULTIARCH}',
+	'includedir'    => '${prefix}/include',
+	'datarootdir'   => '${prefix}/share',
+	'datadir'       => '${datarootdir}',
+	'mandir'        => '${datarootdir}/man',
+	'infodir'       => '${datarootdir}/info',
+	'dh_docrootdir' => '${datarootdir}/doc', # Not from autotols (made up to support debhelper)
+#	'docdir'        => '${dh_docroot}/${package}' # debhelper assumes docdir is a direct subdir of dh_docdir
+);
+
+
 # The Makefile changes this if debhelper is installed in a PREFIX.
 my $prefix="/usr";
 
@@ -2225,4 +2250,53 @@ sub dbgsym_tmpdir {
 	}
 }
 
+{
+	# Our default paths for upstream build-systems.  Uses the same names
+	# as autoconf's configure scripts (where applicable).
+	# Ideally derivatives would be able to override these without having
+	# to modify debhelper
+	my %INSTALLATION_DIRECTORIES;
+
+	sub _init_paths {
+		%INSTALLATION_DIRECTORIES = (
+			 'prefix'        => '/usr',
+			 'eprefix'       => '${prefix}',
+			 'bindir'        => '${eprefix}/bin',
+			 'sbindir'       => '${eprefix}/sbin',
+			 'sysconfdir'    => '/etc',
+			 'localstatedir' => '/var',
+			 'runstatedir'   => '/run',
+			 #'libdir'        => '${eprefix}/lib/${DEB_BUILD_MULTIARCH}',
+			 'includedir'    => '${prefix}/include',
+			 'datarootdir'   => '${prefix}/share',
+			 'datadir'       => '${datarootdir}',
+			 'mandir'        => '${datarootdir}/man',
+			 'infodir'       => '${datarootdir}/info',
+			 'dh_docrootdir' => '${datarootdir}/doc', # Not from autotols (made up to support debhelper)
+			 #	'docdir'        => '${dh_docroot}/${package}' # debhelper assumes docdir is a direct subdir of dh_docdir
+		);
+	}
+
+	sub get_installation_directory {
+		my ($path_type, $style) = @_;
+		_init_paths if not %INSTALLATION_DIRECTORIES;
+		my $path = $INSTALLATION_DIRECTORIES{$path_type} // error("No path defined for $path_type\n");
+		my $expand = 0;
+		$expand = 1 if not defined($style) or $style ne 'autoconf';
+		if ($expand) {
+			1 while ($path =~ s<
+				    \$\{([^{}]+)\}  # Turn ${prefix}/lib into /usr/lib
+				><
+				    $INSTALLATION_DIRECTORIES{$1} // error("Cannot resolve $1 for $path_type\n")
+				>gex);
+		}
+		return $path;
+	}
+}
+
+sub get_rel_installation_directory {
+	my $res = get_installation_directory(@_);
+	return substr($res, 1);
+}
+
 1
diff --git a/t/buildsystems/autoconf/configure b/t/buildsystems/autoconf/configure
index 73715c8..04e2d47 100755
--- a/t/buildsystems/autoconf/configure
+++ b/t/buildsystems/autoconf/configure
@@ -9,8 +9,8 @@ my @OPTIONS=qw(
    ^--build=.*$
    ^--prefix=/usr$
    ^--includedir=\$\{prefix\}/include$
-   ^--mandir=\$\{prefix\}/share/man$
-   ^--infodir=\$\{prefix\}/share/info$
+   ^--mandir=(\$\{prefix\}/share/man|\$\{datarootdir\}/man)$
+   ^--infodir=(\$\{prefix\}/share/info|\$\{datarootdir\}/info)$
    ^--sysconfdir=/etc$
    ^--localstatedir=/var$
    ^--libexecdir=\$\{prefix\}/lib/.*$

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