emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals/system-packages e42e8e7 096/117: Simplify sudo handling


From: Stefan Monnier
Subject: [elpa] externals/system-packages e42e8e7 096/117: Simplify sudo handling
Date: Fri, 14 Dec 2018 17:02:16 -0500 (EST)

branch: externals/system-packages
commit e42e8e7a281a29afc6d7bae363f0e73e7617b117
Author: Alex Branham <address@hidden>
Commit: Alex Branham <address@hidden>

    Simplify sudo handling
    
    Rely on default-directory to let TRAMP handle sudo stuff
---
 system-packages.el           |  7 ++++---
 test/system-packages-test.el | 12 ++++++------
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/system-packages.el b/system-packages.el
index f9d0da8..1cc79ff 100644
--- a/system-packages.el
+++ b/system-packages.el
@@ -324,8 +324,6 @@ of passing additional arguments to the package manager."
       (error (format "%S not supported in %S" action 
system-packages-package-manager)))
     (unless (listp command)
       (setq command (list command)))
-    (when system-packages-use-sudo
-      (setq command (mapcar (lambda (part) (concat "sudo " part)) command)))
     (setq command (mapconcat 'identity command " && "))
     (setq command (mapconcat 'identity (list command pack) " "))
     (when noconfirm
@@ -336,7 +334,10 @@ of passing additional arguments to the package manager."
   "Run a command asynchronously using the system's package manager.
 See `system-packages-get-command' for how to use ACTION, PACK,
 and ARGS."
-  (let ((command (system-packages-get-command action pack args)))
+  (let ((command (system-packages-get-command action pack args))
+        (default-directory (if system-packages-use-sudo
+                               "/sudo::"
+                             default-directory)))
     (async-shell-command command "*system-packages*")))
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
diff --git a/test/system-packages-test.el b/test/system-packages-test.el
index 67b1d7a..a392d4f 100644
--- a/test/system-packages-test.el
+++ b/test/system-packages-test.el
@@ -15,10 +15,10 @@
              (system-packages-get-command 'install))
            "guix package -i "))
   (should (string=
-           (let ((system-packages-use-sudo t)
+           (let ((system-packages-use-sudo nil)
                  (system-packages-package-manager 'pacman))
              (system-packages-get-command 'install))
-           "sudo pacman -S ")))
+           "pacman -S ")))
 
 (ert-deftest system-packages-get-install-noconfirm ()
   "Return correct installation command."
@@ -30,16 +30,16 @@
            "guix package -i "))
   (should (string=
            (let ((system-packages-noconfirm t)
-                 (system-packages-use-sudo t)
+                 (system-packages-use-sudo nil)
                  (system-packages-package-manager 'pacman))
              (system-packages-get-command 'install))
-           "sudo pacman -S --noconfirm"))
+           "pacman -S --noconfirm"))
   (should (string=
            (let ((system-packages-noconfirm t)
-                 (system-packages-use-sudo t)
+                 (system-packages-use-sudo nil)
                  (system-packages-package-manager 'apt))
              (system-packages-get-command 'install "rg"))
-           "sudo apt-get install rg -y")))
+           "apt-get install rg -y")))
 
 (ert-deftest system-packages-errors ()
   "Error when we don't know a command."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]