From: Guillem Jover Date: Fri, 28 Sep 2007 02:44:56 +0000 (+0300) Subject: dpkg-buildpackage: Check if rootcommand is present and error otherwise X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f35e1f63adf2793972825f5ed951c4d54d1acd67;p=dpkg dpkg-buildpackage: Check if rootcommand is present and error otherwise --- 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;