From f35e1f63adf2793972825f5ed951c4d54d1acd67 Mon Sep 17 00:00:00 2001 From: Guillem Jover Date: Fri, 28 Sep 2007 05:44:56 +0300 Subject: [PATCH] dpkg-buildpackage: Check if rootcommand is present and error otherwise --- ChangeLog | 6 ++++++ scripts/dpkg-buildpackage.pl | 20 ++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index ceff5e8f..19b3742e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2007-10-07 Guillem Jover + + * scripts/dpkg-buildpackage.pl: Warn if run as root and $rootcommand + has been specified. Error if run as non-root and $rootcommand is not + found. + 2007-10-07 Guillem Jover * scripts/dpkg-buildpackage.pl (usage): Remove details about running diff --git a/scripts/dpkg-buildpackage.pl b/scripts/dpkg-buildpackage.pl index 3b374ef8..232fd884 100644 --- a/scripts/dpkg-buildpackage.pl +++ b/scripts/dpkg-buildpackage.pl @@ -84,10 +84,6 @@ sub testcommand { } my $rootcommand = ''; -if (testcommand('fakeroot')) { - $rootcommand = 'fakeroot'; -} - my $signcommand = ''; if ( ( ($ENV{GNUPGHOME} && -e $ENV{GNUPGHOME}) || ($ENV{HOME} && -e "$ENV{HOME}/.gnupg") ) @@ -200,6 +196,22 @@ while (@ARGV) { } } +if ($< == 0) { + warning(_g("using a gain-root-command while being root")) if ($rootcommand); +} else { + $rootcommand ||= 'fakeroot'; + + if (!testcommand($rootcommand)) { + if ($rootcommand eq 'fakeroot') { + error(_g("fakeroot not found, either install the fakeroot\n" . + "package, specify a command with the -r option, " . + "or run this as root")); + } else { + error(sprintf(_g("gain-root-commmand '%s' not found"), $rootcommand)); + } + } +} + unless ($signcommand) { $signsource = 0; $signchanges = 0; -- 2.39.5