unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* Removing packages from archive-contents if removed from elpa-packages
@ 2022-10-31  9:40 Philip Kaludercic
  2022-10-31 12:11 ` Stefan Monnier
  0 siblings, 1 reply; 10+ messages in thread
From: Philip Kaludercic @ 2022-10-31  9:40 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 345 bytes --]


Hi,

there is at least one broken package on NonGNU ELPA
(color-theme-tangotango) that was added, then removed as dependencies
were missing, but it remained in the archive because it was added to the
archive-contents file.  The following patch would make sure that any
package not listed in elpa-packages is also remove from
archive-contents:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Remove-packages-from-archive-if-they-are-not-listed-.patch --]
[-- Type: text/x-patch, Size: 1659 bytes --]

From 501309b5507e9e87eb59fbaab65184ee915a5386 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Mon, 31 Oct 2022 10:18:17 +0100
Subject: [PATCH] Remove packages from archive if they are not listed in
 elpa-packages

* elpa-admin.el (elpaa--update-archive-contents): Cross-examine the
package specifications before updating archive contents.
---
 elpa-admin.el | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/elpa-admin.el b/elpa-admin.el
index c03fea47a1..ac36aa686a 100644
--- a/elpa-admin.el
+++ b/elpa-admin.el
@@ -156,15 +156,19 @@ Delete backup files also."
 
 (defun elpaa--update-archive-contents (pkg-desc dir)
   "Update the `archive-contents' file in DIR with new package PKG-DESC."
-  (let* ((filename (expand-file-name "archive-contents" dir))
+  (let* ((specs (elpaa--get-specs))
+         (filename (expand-file-name "archive-contents" dir))
          (ac (if (file-exists-p filename)
                  (elpaa--form-from-file-contents filename)
                '(1))))
     (elpaa--message "current AC: %S" ac)
     (setf (alist-get (car pkg-desc) (cdr ac)) (cdr pkg-desc))
-    (setf (cdr ac) (sort (cdr ac)
-                         (lambda (x y)
-                           (string-lessp (symbol-name (car x)) (symbol-name (car y))))))
+    (setf (cdr ac)
+          (sort (mapcan
+                 (lambda (pkg)
+                   (and (assoc (car pkg) specs #'string=) (list pkg)))
+                 (cdr ac))
+                (lambda (x y) (string-lessp (car x) (car y)))))
     (elpaa--message "new AC: %S" ac)
     (with-temp-buffer
       (pp ac (current-buffer))
-- 
2.38.0


[-- Attachment #3: Type: text/plain, Size: 111 bytes --]


It might be a good idea to cache the interpretation of elpa-packages, so
I would also suggest the following:


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #4: 0001-Cache-elpaa-get-specs-invocations.patch --]
[-- Type: text/x-patch, Size: 1008 bytes --]

From 539e36cc448315cb26bae400cb52de4308a0a747 Mon Sep 17 00:00:00 2001
From: Philip Kaludercic <philipk@posteo.net>
Date: Mon, 31 Oct 2022 10:35:21 +0100
Subject: [PATCH] Cache 'elpaa--get-specs' invocations

* elpa-admin.el (elpa--specs-cache): Add new variable.
(elpaa--get-specs): Use 'elpa--specs-cache'.
---
 elpa-admin.el | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/elpa-admin.el b/elpa-admin.el
index ac36aa686a..3fb1d756fb 100644
--- a/elpa-admin.el
+++ b/elpa-admin.el
@@ -176,8 +176,11 @@ Delete backup files also."
       (let ((default-directory (expand-file-name dir)))
         (elpaa--html-make-index (cdr ac))))))
 
+(defvar elpa--specs-cache nil)
+
 (defun elpaa--get-specs ()
-  (elpaa--form-from-file-contents elpaa--specs-file))
+  (or elpa--specs-cache
+      (setq elpa--specs-cache (elpaa--form-from-file-contents elpaa--specs-file))))
 
 (defun elpaa--spec-get (pkg-spec prop &optional default)
   (or (plist-get (cdr pkg-spec) prop) default))
-- 
2.38.0


[-- Attachment #5: Type: text/plain, Size: 484 bytes --]


While this would fix the above problem, two points remain:

1. This does not remove any tarballs.  It wouldn't be hard to do, but I
   am not sure if there would be any unintended side effects of doing
   so -- at least immediately.

2. There are functioning packages on NonGNU ELPA like haskell-mode that
   were also added to elpa-packages then removed, and still linger in
   the archive without being updated.  This would get rid of those too,
   which might not be a good idea.

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2022-11-02  6:59 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-10-31  9:40 Removing packages from archive-contents if removed from elpa-packages Philip Kaludercic
2022-10-31 12:11 ` Stefan Monnier
2022-10-31 14:25   ` Philip Kaludercic
2022-10-31 14:47     ` Stefan Kangas
2022-10-31 15:10       ` Philip Kaludercic
2022-10-31 16:06     ` Philip Kaludercic
2022-10-31 17:53       ` Stefan Monnier
2022-11-01 10:42         ` Philip Kaludercic
2022-11-02  2:02           ` Stefan Monnier
2022-11-02  6:59             ` Philip Kaludercic

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).