aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaurence Rochfort2018-09-12 17:53:26 +0100
committerLaurence Rochfort2018-09-12 19:12:49 +0100
commitca39ed155f2ac4e127b0c5787cf0f1598ff93da7 (patch)
tree34d9073f6d043be2419f0386b9a115e4e91ab6af
parent4a34b41f960b2507b34795d37ecff94ea90d8ea8 (diff)
downloademacs-ca39ed155f2ac4e127b0c5787cf0f1598ff93da7.tar.gz
emacs-ca39ed155f2ac4e127b0c5787cf0f1598ff93da7.zip
[] Install system packages using system-packages-install
:ensure-system-package was installing packages by running system-packages-get-command via async-shell-command. This meant that system-packages-use-sudo wasn't being honoured. This patch makes :ensure-system-package use system-packages-install for all cases, except where a custom install command is supplied, in which case async-shell-command is used. This issue was introduced in 9f034a0bcfdd8c4 [https://github.com/jwiegley/use-package/issues/673], as a fix for [https://github.com/jwiegley/use-package/issues/661]. Prior to that commit, system-packages-use-sudo was being honoured. This patch also fixes a bug where a cons containing a lone symbol in a list of conses causes nil to used as the package to install. GitHub-reference: fix https://github.com/jwiegley/use-package/issues/720 Copyright-paperwork-exempt: yes
-rw-r--r--lisp/use-package/use-package-ensure-system-package.el22
1 files changed, 12 insertions, 10 deletions
diff --git a/lisp/use-package/use-package-ensure-system-package.el b/lisp/use-package/use-package-ensure-system-package.el
index eaf6de79a12..87abf407020 100644
--- a/lisp/use-package/use-package-ensure-system-package.el
+++ b/lisp/use-package/use-package-ensure-system-package.el
@@ -5,7 +5,7 @@
5;; Author: Justin Talbott <justin@waymondo.com> 5;; Author: Justin Talbott <justin@waymondo.com>
6;; Keywords: convenience, tools, extensions 6;; Keywords: convenience, tools, extensions
7;; URL: https://github.com/waymondo/use-package-ensure-system-package 7;; URL: https://github.com/waymondo/use-package-ensure-system-package
8;; Version: 0.1 8;; Version: 0.2
9;; Package-Requires: ((use-package "2.1") (system-packages "1.0.4")) 9;; Package-Requires: ((use-package "2.1") (system-packages "1.0.4"))
10;; Filename: use-package-ensure-system-package.el 10;; Filename: use-package-ensure-system-package.el
11;; License: GNU General Public License version 3, or (at your option) any later version 11;; License: GNU General Public License version 3, or (at your option) any later version
@@ -25,22 +25,23 @@
25(eval-when-compile 25(eval-when-compile
26 (declare-function system-packages-get-command "system-packages")) 26 (declare-function system-packages-get-command "system-packages"))
27 27
28(defun use-package-ensure-system-package-install-command (pack)
29 "Return the default install command for PACK."
30 (system-packages-get-command 'install pack))
31 28
32(defun use-package-ensure-system-package-consify (arg) 29(defun use-package-ensure-system-package-consify (arg)
33 "Turn `arg' into a cons of (`package-name' . `install-command')." 30 "Turn `arg' into a cons of (`package-name' . `install-command')."
34 (cond 31 (cond
35 ((stringp arg) 32 ((stringp arg)
36 (cons arg (use-package-ensure-system-package-install-command arg))) 33 (cons arg `(system-packages-install ,arg)))
37 ((symbolp arg) 34 ((symbolp arg)
38 (cons arg (use-package-ensure-system-package-install-command (symbol-name arg)))) 35 (cons arg `(system-packages-install ,(symbol-name arg))))
39 ((consp arg) 36 ((consp arg)
40 (if (stringp (cdr arg)) 37 (cond
41 arg 38 ((not (cdr arg))
39 (use-package-ensure-system-package-consify (car arg)))
40 ((stringp (cdr arg))
41 (cons (car arg) `(async-shell-command ,(cdr arg))))
42 (t
42 (cons (car arg) 43 (cons (car arg)
43 (use-package-ensure-system-package-install-command (symbol-name (cdr arg)))))))) 44 `(system-packages-install ,(symbol-name (cdr arg)))))))))
44 45
45;;;###autoload 46;;;###autoload
46(defun use-package-normalize/:ensure-system-package (_name-symbol keyword args) 47(defun use-package-normalize/:ensure-system-package (_name-symbol keyword args)
@@ -60,6 +61,7 @@ If it is a symbol, ensure the binary exist."
60 (file-exists-p file-or-exe) 61 (file-exists-p file-or-exe)
61 (executable-find (symbol-name file-or-exe)))) 62 (executable-find (symbol-name file-or-exe))))
62 63
64
63;;;###autoload 65;;;###autoload
64(defun use-package-handler/:ensure-system-package (name _keyword arg rest state) 66(defun use-package-handler/:ensure-system-package (name _keyword arg rest state)
65 "Execute the handler for `:ensure-system-package' keyword in `use-package'." 67 "Execute the handler for `:ensure-system-package' keyword in `use-package'."
@@ -67,7 +69,7 @@ If it is a symbol, ensure the binary exist."
67 (use-package-concat 69 (use-package-concat
68 (mapcar #'(lambda (cons) 70 (mapcar #'(lambda (cons)
69 `(unless (use-package-ensure-system-package-exists? ',(car cons)) 71 `(unless (use-package-ensure-system-package-exists? ',(car cons))
70 (async-shell-command ,(cdr cons)))) arg) 72 ,(cdr cons))) arg)
71 body))) 73 body)))
72 74
73(add-to-list 'use-package-keywords :ensure-system-package t) 75(add-to-list 'use-package-keywords :ensure-system-package t)