Browse Source

dpkg-buildpackage: Check if rootcommand is present and error otherwise

Guillem Jover 19 years ago
parent
commit
f35e1f63ad
2 changed files with 22 additions and 4 deletions
  1. 6 0
      ChangeLog
  2. 16 4
      scripts/dpkg-buildpackage.pl

+ 6 - 0
ChangeLog

@@ -1,3 +1,9 @@
+2007-10-07  Guillem Jover  <guillem@debian.org>
+
+	* 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  <guillem@debian.org>
 
 	* scripts/dpkg-buildpackage.pl (usage): Remove details about running

+ 16 - 4
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;