>From 501309b5507e9e87eb59fbaab65184ee915a5386 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic 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