Condition in elpa install with refresh package

Added a check for new `package-archives' entries to fetch/update their
archive-contents and regenerate for new configuration of
`package-archives'.
This commit is contained in:
myeffort 2014-02-11 21:45:11 +04:00
parent 2bd1891e90
commit 6294b849df

View File

@ -81,12 +81,24 @@ the recipe, then return nil."
"Ask elpa to install given PACKAGE."
(let* ((elpa-dir (el-get-elpa-package-directory package))
(elpa-repo (el-get-elpa-package-repo package))
;; Indicates new archive requiring to download its archive-contents
(elpa-new-repo (when (and elpa-repo)
(unless (rassoc (cdr-safe elpa-repo)
(bound-and-true-p package-archives))
elpa-repo)))
;; Set `package-archive-base' to elpa-repo for old package.el
(package-archive-base (or (cdr-safe elpa-repo)
(bound-and-true-p package-archive-base)))
;; Prepend elpa-repo to `package-archives' for new package.el
(package-archives (append (when elpa-repo (list elpa-repo))
(when (boundp 'package-archives) package-archives))))
(when elpa-new-repo
(condition-case-unless-debug nil
(package--download-one-archive elpa-new-repo "archive-contents")
(error (message "Failed to download `%s' archive." (car archive))))
(package-read-all-archive-contents))
(unless (and elpa-dir (file-directory-p elpa-dir))
;; package-install does these only for interactive calls
(unless package--initialized