[debhelper-devel] [debhelper] 02/02: makefile.pm: Support R³ for calling make install as root
Niels Thykier
nthykier at moszumanska.debian.org
Sat Sep 16 20:18:01 UTC 2017
This is an automated email from the git hooks/post-receive script.
nthykier pushed a commit to branch support-rrr
in repository debhelper.
commit 3570487346f16967ce59d827c9e83cf8ba14cd93
Author: Niels Thykier <niels at thykier.net>
Date: Sat Sep 16 19:09:15 2017 +0000
makefile.pm: Support R³ for calling make install as root
Signed-off-by: Niels Thykier <niels at thykier.net>
---
debian/changelog | 2 ++
lib/Debian/Debhelper/Buildsystem/makefile.pm | 13 +++++++++++--
lib/Debian/Debhelper/Dh_Lib.pm | 9 ++++++++-
t/buildsystems/debian/control | 1 +
4 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 6b298a8..32c475f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -25,6 +25,8 @@ debhelper (10.9) UNRELEASED; urgency=medium
* dh_isntallchangelogs: Ditto.
* dh_installdocs: Ditto.
* dh_testroot: Update check for root to support R³.
+ * makefile.pm: Call "make install" with DPKG_GAIN_ROOT_CMD when
+ R³ contains the "debhelper/upstream-make-install" keyword.
[ Felipe Sateler ]
* dh_systemd_enable: Refactor and add support for timer units.
diff --git a/lib/Debian/Debhelper/Buildsystem/makefile.pm b/lib/Debian/Debhelper/Buildsystem/makefile.pm
index 02008a2..49a368d 100644
--- a/lib/Debian/Debhelper/Buildsystem/makefile.pm
+++ b/lib/Debian/Debhelper/Buildsystem/makefile.pm
@@ -8,7 +8,8 @@ package Debian::Debhelper::Buildsystem::makefile;
use strict;
use warnings;
-use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value escape_shell clean_jobserver_makeflags is_cross_compiling compat);
+use Debian::Debhelper::Dh_Lib qw(dpkg_architecture_value escape_shell clean_jobserver_makeflags is_cross_compiling compat
+ should_use_root gain_root_cmd);
use parent qw(Debian::Debhelper::Buildsystem);
my %DEB_DEFAULT_TOOLS = (
@@ -81,7 +82,11 @@ sub do_make {
# Note that this will override any -j settings in MAKEFLAGS.
unshift @_, "-j" . ($this->get_parallel() > 0 ? $this->get_parallel() : "");
- $this->doit_in_builddir($this->{makecmd}, @_);
+ my @root_cmd;
+ if (exists($this->{_run_make_as_root}) and $this->{_run_make_as_root}) {
+ @root_cmd = gain_root_cmd();
+ }
+ $this->doit_in_builddir(@root_cmd, $this->{makecmd}, @_);
}
sub make_first_existing_target {
@@ -163,6 +168,10 @@ sub install {
$this->disable_parallel();
}
+ if (should_use_root('debhelper/upstream-make-install') and $< != 0) {
+ $this->{_run_make_as_root} = 1;
+ }
+
$this->make_first_existing_target(['install'],
"DESTDIR=$destdir",
"AM_UPDATE_INFO_DIR=no", @_);
diff --git a/lib/Debian/Debhelper/Dh_Lib.pm b/lib/Debian/Debhelper/Dh_Lib.pm
index 0371895..5e7f41e 100644
--- a/lib/Debian/Debhelper/Dh_Lib.pm
+++ b/lib/Debian/Debhelper/Dh_Lib.pm
@@ -65,7 +65,7 @@ our (@EXPORT, %dh);
&glob_expand_error_handler_silently_ignore DH_BUILTIN_VERSION
&print_and_complex_doit &default_sourcedir &qx_cmd
&compute_doc_main_package &is_so_or_exec_elf_file
- &should_use_root
+ &should_use_root &gain_root_cmd
);
# The Makefile changes this if debhelper is installed in a PREFIX.
@@ -1425,6 +1425,13 @@ sub should_use_root {
return 0;
}
+# Returns the "gain root command" as a list suitable for passing as a part of the command to "doit()"
+sub gain_root_cmd {
+ my $raw_cmd = $ENV{DPKG_GAIN_ROOT_CMD};
+ return if not defined($raw_cmd) or $raw_cmd =~ m/^\s*+$/;
+ return split(' ', $raw_cmd);
+}
+
sub root_requirements {
getpackages() if not %rrr;
diff --git a/t/buildsystems/debian/control b/t/buildsystems/debian/control
index 7edd806..d3225ee 100644
--- a/t/buildsystems/debian/control
+++ b/t/buildsystems/debian/control
@@ -3,6 +3,7 @@ Section: devel
Priority: optional
Maintainer: Test <testing at nowhere>
Standards-Version: 3.8.1
+Rules-Requires-Root: no
Package: testpackage
Architecture: all
--
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