core: add function to create spacelpa archive-contents

This is the first stone toward Spacemacs own ELPA repository.
New function configuration-layer/create-spacelpa-repository which creates the
archive-contents file for the Spacelpa repository containing all the ELPA
packages supported by Spacemacs (and only them).
This commit is contained in:
syl20bnr 2017-01-17 00:24:32 -05:00
parent afb2efcf56
commit 273e1e94d6
1 changed files with 43 additions and 0 deletions

View File

@ -2049,6 +2049,49 @@ FILE-TO-LOAD is an explicit file to load after the installation."
(load-file (concat pkg-elpa-dir file-to-load)))
pkg-elpa-dir))))
(defun configuration-layer//get-elpa-packages ()
"Return a list of all ELPA packages in indexed packages and dependencies."
(let (result)
(dolist (pkg-sym (configuration-layer//get-distant-packages
(ht-keys configuration-layer--indexed-packages) nil))
(when (assq pkg-sym package-archive-contents)
(let* ((deps (mapcar 'car
(configuration-layer//get-package-deps-from-archive
pkg-sym)))
(elpa-deps (configuration-layer/filter-objects
deps (lambda (x)
(assq x package-archive-contents)))))
(dolist (pkg (cons pkg-sym elpa-deps))
;; avoid duplicates
(add-to-list 'result pkg)))))
result))
(defun configuration-layer//create-archive-contents-item (pkg-name)
"Return an item with an ELPA archive-contents compliant format."
(let ((obj (cadr (assq pkg-name package-archive-contents))))
(cons pkg-name `[,(package-desc-version obj)
,(package-desc-reqs obj)
,(package-desc-summary obj)
,(package-desc-kind obj)
,(package-desc-extras obj)])))
(defun configuration-layer/create-spacelpa-repository (output-dir)
"Create an ELPA repository containing an exhaustive list of packages."
(configuration-layer/make-all-packages 'no-discover)
(let* ((packages (configuration-layer//get-elpa-packages))
(spacelpa-archive-contents
(mapcar 'configuration-layer//create-archive-contents-item
packages)))
(push 1 spacelpa-archive-contents)
(unless (file-exists-p output-dir)
(make-directory output-dir t))
(with-current-buffer (find-file-noselect
(concat output-dir "archive-contents"))
(erase-buffer)
(prin1 spacelpa-archive-contents (current-buffer))
(save-buffer))))
(defun configuration-layer//increment-error-count ()
"Increment the error counter."
(if configuration-layer-error-count