Subject: bug#16762: Installed packages are not considered part of the archive contents

From: Dmitry Gutov <[email-masked]>
Date: Sat, 22 Mar 2014 01:07:37 +0200

On 21.03.2014 17:33, Stefan Monnier wrote:

> Clearly, the intention of my changes was to move towards a situation
> where package-archive-contents indeed holds all the packages in the
> archives.

AFAICS, the revision in question did the reverse: it made installed 
packages excluded from package-archive-contents (as long as the 
installed version is not obsolete). Here's the relevant part:

@@ -914,19 +889,25 @@
           (entry (cons name pkg-desc))
           (existing-package (assq name package-archive-contents))
           (pinned-to-archive (assoc name package-pinned-packages)))
-    (cond ((and pinned-to-archive
-                ;; If pinned to another archive, skip entirely.
-                (not (equal (cdr pinned-to-archive) archive)))
-           nil)
-          ((not existing-package)
-	   (push entry package-archive-contents))
-	  ((version-list-< (package-desc-version (cdr existing-package))
-			   (package-desc-version pkg-desc))
-	   ;; Replace the entry with this one.
-	   (setq package-archive-contents
-		 (cons entry
-		       (delq existing-package
-			     package-archive-contents)))))))
+    (cond
+     ;; Skip entirely if pinned to another archive or if no more recent
+     ;; than what we already have installed.
+     ((or (and pinned-to-archive
+               (not (equal (cdr pinned-to-archive) archive)))
+          (let ((bi (assq name package--builtin-versions)))
+            (and bi (version-list-<= version (cdr bi))))
+          (let ((ins (cdr (assq name package-alist))))
+            (and ins (version-list-<= version (package-desc-version 
ins)))))
+      nil)
+     ((not existing-package)
+      (push entry package-archive-contents))
+     ((version-list-< (package-desc-version (cdr existing-package))
+                      version)
+      ;; Replace the entry with this one.
+      (setq package-archive-contents
+            (cons entry
+                  (delq existing-package
+                        package-archive-contents)))))))

  (defun package-download-transaction (package-list)
    "Download and install all the packages in PACKAGE-LIST.

> If you can show an actual problem that this causes (from the user's
> point of view), we can try to fix it.

Johan?

> And in trunk feel free to try and change things so that those packages
> are included in package-archive-contents.

I think this change, might be more beneficial to apply in 24.4.

This way, the packages interfacing with package.el (like Epl, already 
mentioned here) won't have to deal with the sudden jump in behavior 
specific only to 24.4, but not versions before or after it.

 > (as would be a change that gets rid of the other
 > exceptions such as the packages that are "on-hold").

I agree that it would make sense, and that would be better left for trunk.