[jhbuild] systeminstall: Use pkexec over sudo



commit 562b7036abc7ea0d5debbaa30da51241d058c3ff
Author: Colin Walters <walters verbum org>
Date:   Wed Aug 31 10:14:40 2011 -0400

    systeminstall: Use pkexec over sudo
    
    Actually let's just use pkexec always; this should work on any
    Debian install that has policykit.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=654701

 jhbuild/utils/systeminstall.py |    6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/jhbuild/utils/systeminstall.py b/jhbuild/utils/systeminstall.py
index c7fff46..860c73a 100644
--- a/jhbuild/utils/systeminstall.py
+++ b/jhbuild/utils/systeminstall.py
@@ -51,7 +51,9 @@ def get_installed_pkgconfigs(config):
 
 class SystemInstall(object):
     def __init__(self):
-        pass
+        if not cmds.has_command('pkexec'):
+            raise SystemExit, _('No suitable root privilege command found; you should install "pkexec"')
+        self._root_command_prefix_args = ['pkexec']
 
     def install(self, pkgconfig_ids):
         """Takes a list of pkg-config identifiers and uses a system-specific method to install them."""
@@ -159,7 +161,7 @@ class AptSystemInstall(SystemInstall):
             
         if native_packages:
             logging.info(_('Installing: %(pkgs)s') % {'pkgs': ' '.join(native_packages)})
-            args = ['sudo', 'apt-get', 'install']
+            args = self._root_command_prefix_args + ['apt-get', 'install']
             args.extend(native_packages)
             subprocess.check_call(args)
         else:



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]