Subject: Re: bug#19864: 25.0.50; package-initialize is no more starting

From: Thierry Volpiatto <[email-masked]>
Date: Sat, 14 Feb 2015 09:12:26 +0100

Thierry Volpiatto <[email-masked]> writes:

> Bastien <[email-masked]> writes:
>
>> Hi Thierry,
>>
>> Thierry Volpiatto <[email-masked]> writes:
>>
>>> Actually to start emacs-25 I have to advice `package-initialize' to set
>>> `package--initialized' before.
>>
>> Yes, I reported this here:
>> http://article.gmane.org/gmane.emacs.diffs/129142
>>
>> See the attached patch.
>>
>> Can you double check it's correct for you?
>> CC'ing Artur as he may want to double check too.
>
> Looks more like a work around, (i.e what's package--initialized utility
> if we have to let-bound it to be able to run code) Arthur will decide
> what to do.

Here a patch that set package--initialized when package-archive-contents
is feeded and then setup package--compatibility-table.

diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
index d8b4595..f7b9ef9 100644
--- a/lisp/emacs-lisp/package.el
+++ b/lisp/emacs-lisp/package.el
@@ -1139,13 +1139,17 @@ Will throw an error if the archive version is too new."
                      (car contents) package-archive-version))
           (cdr contents))))))
 
-(defun package-read-all-archive-contents ()
+(defun package-read-all-archive-contents (&optional no-compat-table)
   "Re-read `archive-contents', if it exists.
 If successful, set `package-archive-contents'."
   (setq package-archive-contents nil)
   (dolist (archive package-archives)
     (package-read-archive-contents (car archive)))
   ;; Build compat table.
+  (unless no-compat-table
+    (package--build-compat-table)))
+
+(defun package--build-compat-table ()
   (setq package--compatibility-table (make-hash-table :test 'eq))
   (package--mapc #'package--add-to-compatibility-table))
 
@@ -1738,11 +1742,14 @@ If optional arg NO-ACTIVATE is non-nil, don't activate packages."
   (interactive)
   (setq package-alist nil)
   (package-load-all-descriptors)
-  (package-read-all-archive-contents)
+  (package-read-all-archive-contents t)
+  ;; Decide package is initialized when
+  ;; `package-archive-contents' is feeded.
+  (setq package--initialized t)
+  (package--build-compat-table)
   (unless no-activate
     (dolist (elt package-alist)
-      (package-activate (car elt))))
-  (setq package--initialized t))
+      (package-activate (car elt)))))
 
 (defun package--add-to-compatibility-table (pkg)
   "If PKG is compatible (without dependencies), add to the compatibility table.

-- 
Thierry
Get my Gnupg key:
gpg --keyserver pgp.mit.edu --recv-keys 59F29997