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 c5160971 authored by Dimitri Fontaine's avatar Dimitri Fontaine

Add recipe into the status file and use that at init time, to fix #553.

parent d9d14a71
......@@ -21,48 +21,68 @@
(require 'el-get-core)
(defun el-get-package-symbol (package-name)
"Returns a symbol :package."
(if (and (symbolp package-name)
(string= (substring (symbol-name package-name) 0 1) ":"))
package-name
(intern (format ":%s" package-name))))
(defun el-get-save-package-status (package status)
"Save given package status"
(let* ((recipe (el-get-package-def package))
(package-status-alist
(assq-delete-all package (el-get-read-status-file)))
(new-package-status-alist
(sort (append package-status-alist
(list ; alist of (PACKAGE . PROPERTIES-LIST)
(cons package (list 'status status 'recipe recipe))))
(lambda (p1 p2)
(string< (el-get-as-string (car p1))
(el-get-as-string (car p2)))))))
(with-temp-file el-get-status-file
(pp new-package-status-alist (current-buffer)))
new-package-status-alist))
(defun el-get-package-name (package-symbol)
"Returns a string package"
(if (symbolp package-symbol)
(cadr (split-string (format "%s" package-symbol) ":"))
package-symbol))
(defun el-get-read-status-file ()
"read `el-get-status-file' and return an alist of plist like:
(PACKAGE . (status \"status\" recipe (:name ...)))"
(let ((ps
(when (file-exists-p el-get-status-file)
(car (with-temp-buffer
(insert-file-contents-literally el-get-status-file)
(read-from-string (buffer-string)))))))
(if (consp (car ps)) ; check for an alist, new format
ps
;; convert to the new format, fetching recipes as we go
(loop for (p s) on ps by 'cddr
for x = (el-get-as-symbol (el-get-package-name p))
when x
collect (cons x (list 'status s
'recipe (el-get-package-def x)))))))
(defun el-get-read-all-packages-status ()
"Return the current plist of packages status"
(when (file-exists-p el-get-status-file)
(car (with-temp-buffer
(insert-file-contents-literally el-get-status-file)
(read-from-string (buffer-string))))))
(defun el-get-package-status-alist (&optional package-status-alist)
"return an alist of (PACKAGE . STATUS)"
(loop for (p . prop) in (or package-status-alist
(el-get-convert-status-format))
collect (cons p (plist-get prop 'status))))
(defun el-get-read-package-status (package)
"Return the current known status for given package."
(plist-get (el-get-read-all-packages-status)
(el-get-package-symbol package)))
(defun el-get-read-package-status (package &optional package-status-alist)
"return current status for PACKAGE"
(let ((p-alist (or package-status-alist (el-get-read-status-file))))
(plist-get (cdr (assq package p-alist)) 'status)))
(defun el-get-save-package-status (package status)
"Save given package status"
(let ((p (el-get-package-symbol package))
(s (el-get-read-all-packages-status))
print-length print-level)
(with-temp-file el-get-status-file
(insert
(format "%S" (if s (plist-put s p status)
`(,p ,status)))))))
(defun el-get-read-package-status-recipe (package &optional package-status-alist)
"return current status for PACKAGE"
(let ((p-alist (or package-status-alist (el-get-read-status-file))))
(plist-get (cdr (assq package p-alist)) 'recipe)))
(defun el-get-list-package-names-with-status (&rest status)
"Return package names that are currently in given status"
(loop for (p s) on (el-get-read-all-packages-status) by 'cddr
;; it can happen that (el-get-package-name) returns nil here and
;; that breaks the completion-read command
when (and (member s status) (el-get-package-name p))
collect (el-get-package-name p)))
(loop for (p . prop) in (el-get-read-status-file)
for s = (plist-get prop 'status)
when (member s status)
collect (el-get-as-string p)))
(defun el-get-filter-package-alist-with-status (package-status-alist &rest status)
"Return package names that are currently in given status"
(loop for (p . prop) in package-status-alist
for s = (plist-get prop 'status)
when (member s status)
collect (el-get-as-string p)))
(defun el-get-read-package-with-status (action &rest status)
"Read a package name in given status"
......@@ -71,20 +91,14 @@
(defun el-get-count-package-with-status (&rest status)
"Return how many packages are currently in given status"
(loop for (p s) on (el-get-read-all-packages-status) by 'cddr
if (member s status) sum 1))
(loop for (p . prop) in (el-get-read-status-file)
count (member (plist-get prop 'status) status)))
(defun el-get-count-packages-with-status (packages &rest status)
"Return how many packages are currently in given status in PACKAGES"
(loop for (p s) on (el-get-read-all-packages-status) by 'cddr
when (and (member (el-get-as-symbol p) packages)
(member s status))
sum 1))
(defun el-get-package-status (package &optional package-status-plist)
"Return current status of package from given list"
(let ((status-plist (or package-status-plist (el-get-read-all-packages-status))))
(plist-get status-plist (el-get-package-symbol package))))
(loop for (p . prop) in (el-get-read-status-file)
count (and (member (el-get-as-symbol p) packages)
(member (plist-get prop 'status) status))))
(defun el-get-extra-packages (&rest packages)
"Return installed or required packages that are not in given package list"
......@@ -94,7 +108,8 @@
when (listp p) append (mapcar 'el-get-as-symbol p)
else collect (el-get-as-symbol p))))
(when packages
(loop for (p s) on (el-get-read-all-packages-status) by 'cddr
(loop for (p . prop) in (el-get-read-status-file)
for s = (plist-get prop 'status)
for x = (el-get-as-symbol (el-get-package-name p))
unless (member x packages)
unless (equal s "removed")
......
......@@ -429,7 +429,7 @@ which defaults to the first element in `el-get-recipe-path'."
`(el-get-run-package-support ',form ',fname ',package)))
(defun el-get-init (package)
(defun el-get-init (package &optional package-status-alist)
"Make the named PACKAGE available for use.
Add PACKAGE's directory (or `:load-path' if specified) to the
......@@ -439,7 +439,8 @@ called by `el-get' (usually at startup) for each installed package."
(interactive (list (el-get-read-package-name "Init")))
(el-get-verbose-message "el-get-init: %s" package)
(condition-case err
(let* ((source (el-get-package-def package))
(let* ((source
(el-get-read-package-status-recipe package package-status-alist))
(method (el-get-package-method source))
(loads (el-get-as-list (plist-get source :load)))
(autoloads (plist-get source :autoloads))
......@@ -810,8 +811,9 @@ Also put the checksum in the kill-ring."
When PACKAGES is non-nil, only process entries from this list.
Those packages from the list we don't know the status of are
considered \"required\"."
(let* ((required (el-get-list-package-names-with-status "required"))
(installed (el-get-list-package-names-with-status "installed"))
(let* ((p-s-alist (el-get-read-status-file))
(required (el-get-filter-package-alist-with-status p-s-alist "required"))
(installed (el-get-filter-package-alist-with-status p-s-alist "installed"))
(to-init (if packages
(loop for p in packages
when (member (el-get-as-string p) installed)
......@@ -876,7 +878,6 @@ already installed packages is considered."
(let* ((packages
;; (el-get 'sync 'a 'b my-package-list)
(loop for p in packages when (listp p) append p else collect p))
(p-status (el-get-read-all-packages-status))
(total (length packages))
(installed (el-get-count-packages-with-status packages "installed"))
(progress (and (eq sync 'wait)
......
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