Subject: Re: bug#53805: 27.2; NonGNU ELPA: helm does not install dependencies

From: Philip Kaludercic <[email-masked]>
Date: Sat, 05 Feb 2022 19:08:50 +0000

Xingyu Pu <[email-masked]> writes:

> When installing helm from the NonGNU ELPA, packages that helm requires
> is not installed.
>
> Step to reproduce:
>
> Add nongnu repository to package-archives.
> List packages by M-x list-packages.
> Select helm from nongnu and install.
> Package helm-core, async, popup that helm requires is not installed.

It seems to me that the core of the issue is that the ELPA build system
overrides the existing -pkg.el files, by trying to infer all the package
metadata from the main files (helm.el, helm-core.el).  If as in the case
of helm and helm-core these are empty, this leads to unexpected results.

This patch seems to fix the issue on my end:

diff --git a/elpa-admin.el b/elpa-admin.el
index d570c3c6aa..6714cd07a4 100644
--- a/elpa-admin.el
+++ b/elpa-admin.el
@@ -1015,14 +1015,25 @@ EXTRAS is an alist with additional metadata.
 PKG is the name of the package and DIR is the directory where it is."
   (let* ((pkg (car pkg-spec))
          (mainfile (expand-file-name (elpaa--main-file pkg-spec) dir))
+         (desc-file (expand-file-name (concat pkg "-pkg.el") dir))
          (files (directory-files dir nil "\\`dir\\'\\|\\.el\\'")))
     (setq files (delete (concat pkg "-pkg.el") files))
     (setq files (delete (concat pkg "-autoloads.el") files))
     (cond
+     ((file-exists-p desc-file)
+      (with-temp-buffer
+        (insert-file-contents desc-file)
+        (let* ((form (read (current-buffer)))
+               (pkg-desc (apply #'package-desc-from-define (cdr form))))
+          (list (= (length files) 1)
+                (package-version-join (package-desc-version pkg-desc))
+                (package-desc-summary pkg-desc)
+                (package-desc-reqs pkg-desc)
+                nil))))
      ((file-exists-p mainfile)
       (with-temp-buffer
-	(insert-file-contents mainfile)
-	(goto-char (point-min))
+        (insert-file-contents mainfile)
+        (goto-char (point-min))
         (let* ((pkg-desc
                 (unwind-protect
                     (progn

But it hasn't been thoroughly tested.

Another possibility I don't want to exclude is that I messed up the
package specification when adding the packages to the archive.

-- 
	Philip Kaludercic