Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit 508fb7e1 authored by Ryan C. Thompson's avatar Ryan C. Thompson

Don't assume that first build command is a string

Build commands are supposed to be either strings or lists of strings.
But the code for deciding whether to eval the :build property only
checks for a string, not a list. This commit fixes this, so that a
build property whose commands are all lists of strings should no
longer cause an error. Evaluation of the :build property now only
happens when the car is a symbol, since that is the only time that
evaluation would not result in an error.

Also in this commit:

* Ensure build commands are all strings or lists of strings and raise
  an error otherwise. The check happens after flattening, so nested
  lists of strings should also pass.
* A few syntax fixes
* Add a function "el-get-list-of-strings-p"
parent a388bceb
......@@ -28,18 +28,32 @@ interpreted as a shell command; or a list of lists of
strings, each string representing a single shell argument."
(let* ((source (el-get-package-def package))
(build-type (intern (format ":build/%s" system-type)))
(or (plist-get source build-type)
(plist-get source :build))))
(unless (listp build-commands)
(error "build commands for package %s are not a list" package))
(unless (stringp (car build-commands))
(setq build-commands (eval build-commands)))
(mapcar (lambda (x) (if (stringp x) x (el-get-flatten x)))
(plist-get source :build)))
(if (listp (raw-build-commands))
;; If the :build property's car is a symbol, assume that it is an
;; expression that evaluates to a command list, rather than a
;; literal command list.
(if (symbolp (car raw-build-commands))
(eval raw-build-commands)
(error "build commands for package %s are not a list" package)))
;; Flatten lists, but not strings
(mapcar (lambda (x) (if (stringp x) x (el-get-flatten x)))
;; Verify that each build command is a string or a list of strings
(let ((invalid-cmds
(remove-if (lambda (cmd)
(or (stringp cmd)
(el-get-list-of-strings-p cmd)))
(when invalid-cmds
(error "Package %s has invalid build commands: %S" package invalid-cmds)))
(defun el-get-build-command-program (name)
"Given the user command name, get the command program to execute.
......@@ -77,6 +77,12 @@ returning a list that contains it (and only it)."
(if (listp element-or-list) element-or-list
(list element-or-list)))
(defun el-get-list-of-strings-p (obj)
(or (null obj)
(and (consp obj)
(stringp (car obj))
(el-get-list-of-strings-p (cdr obj)))))
(defun el-get-source-name (source)
"Return the package name (stringp) given an `el-get-sources'
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment