From: Jorgen Schaefer <forcer@forcix.cx>
To: 19296@debbugs.gnu.org
Subject: bug#19296: [PATCH] Package archives now have priorities.
Date: Sun, 7 Dec 2014 13:31:50 +0100 [thread overview]
Message-ID: <20141207132244.A14A7200D1E@loki.jorgenschaefer.de> (raw)
When installing packages by name, only packages from archives with
the highest priority are considered, before versions are compared.
This solves the "MELPA problem", where MELPA assigns date-based
version numbers to packages which override all other archives.
Giving MELPA a lower priority means packages are installed from
MELPA only when the package is not available from other archives.
This can be overridden manually by the user.
---
lisp/emacs-lisp/package.el | 45 ++++++++++++++++++++++++++++++++++++++--
test/automated/package-test.el | 17 +++++++++++++++
2 files changed, 60 insertions(+), 2 deletions(-)
diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index 4e5c397..2030482 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -228,6 +228,33 @@ a package can run arbitrary code."
:group 'package
:version "24.1")
+(defcustom package-archive-default-priority 500
+ "The default priority for archives.
+
+This is used if the archive is not found in
+`package-archive-priorities'."
+ :type 'integer
+ :risky t
+ :group 'package
+ :version "25.1")
+
+(defcustom package-archive-priorities nil
+ "An alist of priorities for packages.
+
+Each element has the form (ARCHIVE-ID . PRIORITY).
+
+When installing packages, the package with the highest version
+number from the archive with the highest priority is
+selected. When higher versions are available from archives with
+lower priorities, the user has to select those manually.
+
+Archives not in this list have the priority given in
+`package-archive-default-priority'."
+ :type 'integer
+ :risky t
+ :group 'package
+ :version "25.1")
+
(defcustom package-pinned-packages nil
"An alist of packages that are pinned to specific archives.
This can be useful if you have multiple package archives enabled,
@@ -1063,6 +1090,7 @@ Also, add the originating archive to the `package-desc' structure."
;; Older archive-contents files have only 4
;; elements here.
(package--ac-desc-extras (cdr package)))))
+ (archive-priority (package-archive-priority archive))
(existing-packages (assq name package-archive-contents))
(pinned-to-archive (assoc name package-pinned-packages)))
(cond
@@ -1075,8 +1103,12 @@ Also, add the originating archive to the `package-desc' structure."
(t
(while
(if (and (cdr existing-packages)
- (version-list-<
- version (package-desc-version (cadr existing-packages))))
+ (or (< archive-priority
+ (package-archive-priority
+ (package-desc-archive (cadr existing-packages))))
+ (version-list-<
+ version
+ (package-desc-version (cadr existing-packages)))))
(setq existing-packages (cdr existing-packages))
(push pkg-desc (cdr existing-packages))
nil))))))
@@ -1268,6 +1300,15 @@ The file can either be a tar file or an Emacs Lisp file."
"Return the archive containing the package NAME."
(cdr (assoc (package-desc-archive desc) package-archives)))
+(defun package-archive-priority (archive)
+ "Return the priority of ARCHIVE.
+
+The archive priorities are specified in
+`package-archive-priorities' and
+`package-archive-default-priority'."
+ (or (cdr (assoc archive package-archive-priorities))
+ package-archive-default-priority))
+
(defun package--download-one-archive (archive file)
"Retrieve an archive file FILE from ARCHIVE, and cache it.
ARCHIVE should be a cons cell of the form (NAME . LOCATION),
diff --git a/test/automated/package-test.el b/test/automated/package-test.el
index 6e7994a..2a337fb 100644
--- a/test/automated/package-test.el
+++ b/test/automated/package-test.el
@@ -230,6 +230,23 @@ Must called from within a `tar-mode' buffer."
(package-refresh-contents)
(package-install 'simple-single)))
+(ert-deftest package-test-install-prioritized ()
+ "Install a lower version from a higher-prioritized archive."
+ (with-package-test ()
+ (let* ((newer-version (expand-file-name "data/package/newer-versions"
+ package-test-file-dir))
+ (package-archives `(("older" . ,package-test-data-dir)
+ ("newer" . ,newer-version)))
+ (package-archive-priorities '(("newer" . 100))))
+
+ (package-initialize)
+ (package-refresh-contents)
+ (package-install 'simple-single)
+
+ (let ((installed (cdr (assq 'simple-single package-alist))))
+ (should (version-list-= '(1 3)
+ (package-desc-version installed)))))))
+
(ert-deftest package-test-install-multifile ()
"Check properties of the installed multi-file package."
(with-package-test (:basedir "data/package" :install '(multi-file))
--
1.7.10.4
next reply other threads:[~2014-12-07 12:31 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-07 12:31 Jorgen Schaefer [this message]
2014-12-07 16:07 ` bug#19296: [PATCH] Package archives now have priorities Ted Zlatanov
2014-12-07 17:56 ` Stefan Monnier
2014-12-07 18:21 ` Jorgen Schaefer
2014-12-07 20:00 ` Jorgen Schaefer
2014-12-08 2:48 ` Stefan Monnier
2014-12-08 10:58 ` Jorgen Schaefer
2014-12-08 15:42 ` Stefan Monnier
2014-12-08 18:49 ` Jorgen Schaefer
2014-12-15 4:59 ` Stefan Monnier
2014-12-15 8:36 ` Jorgen Schaefer
2014-12-15 12:08 ` Ted Zlatanov
2014-12-15 14:52 ` Stefan Monnier
2014-12-15 14:55 ` Jorgen Schaefer
2014-12-15 19:07 ` Stefan Monnier
2014-12-07 18:55 ` Achim Gratz
2014-12-08 2:45 ` Stefan Monnier
2014-12-08 7:22 ` Achim Gratz
2014-12-07 21:28 ` Jorgen Schaefer
2014-12-07 21:46 ` Jorgen Schaefer
[not found] <<20141207132244.A14A7200D1E@loki.jorgenschaefer.de>
2014-12-07 14:19 ` Drew Adams
2014-12-07 14:43 ` Jorgen Schaefer
2014-12-07 15:55 ` Drew Adams
2014-12-07 16:10 ` Jorgen Schaefer
2014-12-07 18:16 ` Drew Adams
2014-12-07 16:13 ` Ted Zlatanov
2014-12-07 17:41 ` Stefan Monnier
[not found] ` <<20141207214345.A8216200D2E@loki.jorgenschaefer.de>
2014-12-07 22:27 ` Drew Adams
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141207132244.A14A7200D1E@loki.jorgenschaefer.de \
--to=forcer@forcix.cx \
--cc=19296@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.