From: Philip Kaludercic <philipk@posteo.net>
To: emacs-devel@gnu.org
Subject: Removing packages from archive-contents if removed from elpa-packages
Date: Mon, 31 Oct 2022 09:40:36 +0000 [thread overview]
Message-ID: <878rkwe3fv.fsf@posteo.net> (raw)
[-- 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.
next reply other threads:[~2022-10-31 9:40 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-31 9:40 Philip Kaludercic [this message]
2022-10-31 12:11 ` Removing packages from archive-contents if removed from elpa-packages 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
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=878rkwe3fv.fsf@posteo.net \
--to=philipk@posteo.net \
--cc=emacs-devel@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.