From 092dfa49a6735c5a00565ea51dcf2272ba9b64ff Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Mon, 31 Oct 2022 17:01:07 +0100 Subject: [PATCH 1/2] Remove deleted packages from archive-contents * elpa-admin.el (elpaa--write-archive-contents): Extract from 'elpaa--update-archive-contents' (elpaa--update-archive-contents): Use 'elpaa--write-archive-contents'. (elpaa--scrub-archive-contents): Add function. (elpaa-batch-make-all-packages): Call 'elpaa--scrub-archive-contents'. --- elpa-admin.el | 31 ++++++++++++++++++++++++++----- 1 file changed, 26 insertions(+), 5 deletions(-) diff --git a/elpa-admin.el b/elpa-admin.el index c03fea47a1..738a957966 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -154,6 +154,14 @@ Delete backup files also." (backup-file-name-p f)) (delete-file f))))) +(defun elpaa--write-archive-contents (ac dir) + "Write archive contents AC into directory DIR." + (with-temp-buffer + (pp ac (current-buffer)) + (write-region nil nil (expand-file-name "archive-contents" dir))) + (let ((default-directory (expand-file-name dir))) + (elpaa--html-make-index (cdr ac)))) + (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)) @@ -166,11 +174,7 @@ Delete backup files also." (lambda (x y) (string-lessp (symbol-name (car x)) (symbol-name (car y)))))) (elpaa--message "new AC: %S" ac) - (with-temp-buffer - (pp ac (current-buffer)) - (write-region nil nil filename) - (let ((default-directory (expand-file-name dir))) - (elpaa--html-make-index (cdr ac)))))) + (elpaa--write-archive-contents ac dir))) (defun elpaa--get-specs () (elpaa--form-from-file-contents elpaa--specs-file)) @@ -788,6 +792,21 @@ of the current `process-environment'. Return the modified copy." (list pkgname)) spec))) +(defun elpaa--scrub-archive-contents (dir) + "Remove dead packages from archive contents in DIR." + (let* ((filename (expand-file-name "archive-contents" dir)) + (ac (if (file-exists-p filename) + (elpaa--form-from-file-contents filename) + '(1))) + (specs (elpaa--get-specs))) + (elpaa--write-archive-contents + (cons (car ac) + (mapcan + (lambda (pkg) + (and (assoc (car pkg) specs #'string=) (list pkg))) + (cdr ac))) + dir))) + (defun elpaa--publish-package-specs (specs) "Process and publish SPECS in elpa-packages.eld files." (with-temp-buffer @@ -814,6 +833,8 @@ of the current `process-environment'. Return the modified copy." (defun elpaa-batch-make-all-packages (&rest _) "Check all the packages and build the relevant new tarballs." + (elpaa--scrub-archive-contents elpaa--release-subdir) + (elpaa--scrub-archive-contents elpaa--devel-subdir) (let ((specs (elpaa--get-specs))) (dolist (spec specs) (condition-case err -- 2.38.0