From 585db35d2356193e679dff3eb73d99e65c575f7b Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Sat, 28 Oct 2017 12:56:42 +0200 Subject: dpkg-buildpackage: Add new --rules-requires-root This new option makes it possible to force falling back to the legacy behavior of assuming that debian/rules files require root. --- debian/changelog | 1 + man/dpkg-buildpackage.man | 4 ++++ scripts/dpkg-buildpackage.pl | 8 +++++++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 0a1789908..fcfcf6aff 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,6 +31,7 @@ dpkg (1.19.1) UNRELEASED; urgency=medium * Specify that DEB_GAIN_ROOT_CMD in R³ should preserve the environment. Proposed by Josh Triplett . * Specify new DEB_RULES_REQUIRES_ROOT variable for R³ support. + * Add new --rules-requires-root option to dpkg-buildpackage. * Architecture support: - Add support for riscv64 CPU. Closes: #822914 Thanks to Manuel A. Fernandez Montecelo diff --git a/man/dpkg-buildpackage.man b/man/dpkg-buildpackage.man index 76545ebb8..906351100 100644 --- a/man/dpkg-buildpackage.man +++ b/man/dpkg-buildpackage.man @@ -276,6 +276,10 @@ Do not check built-in build dependencies and conflicts (since dpkg 1.18.2). These are the distribution specific implicit build dependencies usually required in a build environment, the so called Build-Essential package set. .TP +.B \-\-rules\-requires\-root +Do not honor the \fBRules\-Requires\-Root\fP field, falling back to its +legacy default value (since dpkg 1.19.1). +.TP .BR \-nc ", " \-\-no\-pre\-clean Do not clean the source tree (long option since dpkg 1.18.8). Implies \fB\-b\fP if nothing else has been selected among \fB\-F\fP, diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl index bd0a6f6a6..49c7173a4 100755 --- a/scripts/dpkg-buildpackage.pl +++ b/scripts/dpkg-buildpackage.pl @@ -80,6 +80,7 @@ sub usage { do not check builtin build dependencies. -P, --build-profiles= assume comma-separated build profiles as active. + --rules-requires-root assume legacy Rules-Requires-Root field value. -R, --rules-file= rules file to execute (default is debian/rules). -T, --rules-target= call debian/rules . --as-root ensure -T calls the target with root rights. @@ -169,6 +170,7 @@ my $host_type = ''; my $target_arch = ''; my $target_type = ''; my @build_profiles = (); +my $rrr_override; my @call_target = (); my $call_target_as_root = 0; my $since; @@ -309,6 +311,8 @@ while (@ARGV) { } elsif (/^(?:--target=|--rules-target=|-T)(.+)$/) { my $arg = $1; push @call_target, split /,/, $arg; + } elsif (/^--rules-requires-root$/) { + $rrr_override = 'binary-targets'; } elsif (/^--as-root$/) { $call_target_as_root = 1; } elsif (/^--pre-clean$/) { @@ -683,10 +687,12 @@ sub parse_rules_requires_root { my $ctrl = shift; my %rrr; - my $rrr = $ctrl->{'Rules-Requires-Root'} // 'binary-targets'; + my $rrr; my $keywords_base; my $keywords_impl; + $rrr = $rrr_override // $ctrl->{'Rules-Requires-Root'} // 'binary-targets'; + foreach my $keyword (split ' ', $rrr) { if ($keyword =~ m{/}) { if ($keyword =~ m{^dpkg/target/(.*)$}p and $target_official{$1}) { -- cgit v1.2.3