[core] Add function for generic error about not found executable

* new function configuration-layer//executable-not-found-error
* use new function for tar and gzip not found errors
This commit is contained in:
syl20bnr 2019-08-21 22:30:24 -04:00
parent 015414ae8c
commit b800694d32
1 changed files with 18 additions and 11 deletions

View File

@ -2604,6 +2604,18 @@ ELPA stable repository."
"Return the absolute path to the signature file." "Return the absolute path to the signature file."
(format "%s.sig" (configuration-layer//stable-elpa-directory))) (format "%s.sig" (configuration-layer//stable-elpa-directory)))
(defun configuration-layer//executable-not-found-error (exec &optional msg)
"Display a generic error message about not found EXECutable file.
MSG is an additional message append to the generic error."
(when (null msg) (setq msg ""))
(configuration-layer//error
(format
(concat
"Cannot find %s executable in your PATH.\n"
"Verify your spacemacs environment variables with [SPC f e e].%s\n"
"Spacelpa installation has been skipped!") exec msg)))
(defun configuration-layer//stable-elpa-untar-archive () (defun configuration-layer//stable-elpa-untar-archive ()
"Untar the downloaded archive of stable ELPA, returns non-nil if succeeded." "Untar the downloaded archive of stable ELPA, returns non-nil if succeeded."
(require 'tar-mode) (require 'tar-mode)
@ -2656,10 +2668,7 @@ ELPA stable repository."
(format "Extracting %s archive..." name) t) (format "Extracting %s archive..." name) t)
(if (and (spacemacs/system-is-mswindows) (if (and (spacemacs/system-is-mswindows)
(not (executable-find "tar"))) (not (executable-find "tar")))
(progn (configuration-layer//executable-not-found-error "tar")
(configuration-layer//error
(concat "Error: Cannot find tar executable in you PATH.\n"
"Spacelpa installation has been skipped!")))
(call-process "tar" nil nil nil "-xzf" archive)))) (call-process "tar" nil nil nil "-xzf" archive))))
untar)) untar))
@ -2681,13 +2690,11 @@ ELPA stable repository."
(not (executable-find "gzip"))) (not (executable-find "gzip")))
;; additional check on Windows platform as tarball are not handled ;; additional check on Windows platform as tarball are not handled
;; natively and requires the installation of gzip. ;; natively and requires the installation of gzip.
(progn (configuration-layer//executable-not-found-error
(configuration-layer//error "gzip"
(format (concat
(concat "Error: Cannot find gzip executable in you PATH.\n" "\nDownload and install gzip here: "
"Download and install gzip here: " "http://gnuwin32.sourceforge.net/packages/gzip.htm. "))
"http://gnuwin32.sourceforge.net/packages/gzip.htm \n"
"%s installation has been skipped!") name)))
;; download tarball and detached signature ;; download tarball and detached signature
(make-directory configuration-layer-stable-elpa-directory t) (make-directory configuration-layer-stable-elpa-directory t)
(url-copy-file url local 'ok-if-already-exists) (url-copy-file url local 'ok-if-already-exists)