From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: Removing packages from archive-contents if removed from elpa-packages Date: Tue, 01 Nov 2022 10:42:37 +0000 Message-ID: <87y1svgdlu.fsf@posteo.net> References: <878rkwe3fv.fsf@posteo.net> <87wn8ggjdo.fsf@posteo.net> <87bkpsgeq3.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4702"; mail-complaints-to="usenet@ciao.gmane.io" Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Nov 01 11:43:48 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1opokG-00010R-3P for ged-emacs-devel@m.gmane-mx.org; Tue, 01 Nov 2022 11:43:48 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1opojV-0000MD-Cr; Tue, 01 Nov 2022 06:43:01 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opojP-0000J0-Ti for emacs-devel@gnu.org; Tue, 01 Nov 2022 06:42:58 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1opojJ-0002lm-8Z for emacs-devel@gnu.org; Tue, 01 Nov 2022 06:42:55 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id A1CE4240103 for ; Tue, 1 Nov 2022 11:42:44 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1667299365; bh=ieviDpk4GKLEBP+zAIN00R68xp8oW6YH+pGbYe2xnfY=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=k77IWdM/bJJ1TII1z9qsgD0KaGQD76TDEt5lvXjeb+I6n21aTp8irCVCtI2yU6cUU MKFB4+T6ip6rFKDzdo8zZGaKqaK8THAYxAAD8oLIlH/SG1U/GQgMCgmh0qhj6iHwkc IIfgfMSrRsH+OdpOYPMtuY3wZR1ClkZvSYIR7AzImqz7120xI++DbdygTZsA3gwy0e 0zyv6hdjhv2g01W4Zl7d1wPmHBbI2zw/TG/lHvGL4DMIGKcJALXROgjjLsEXcIqUxf 7vU3QMZ1HBRURvqOQNEpDxBnDHBEJlt2fVAny9uNxFmToMhYgoPXACwfcfH2q6Esz5 klUzm03Uoulrg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4N1mnH6DMsz6tmG; Tue, 1 Nov 2022 11:42:43 +0100 (CET) In-Reply-To: (Stefan Monnier's message of "Mon, 31 Oct 2022 13:53:18 -0400") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298926 Archived-At: --=-=-= Content-Type: text/plain Stefan Monnier writes: >> +(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 > > Hmm... in `elpaa--scrub-archive-contents` you `elpaa--get-specs` but you > could skip that if you called this function a tiny bit later and passed > `specs` to it instead, right? No, you are absolutely right, I just didn't see that. --=-=-= Content-Type: text/x-patch Content-Disposition: attachment; filename=0001-Remove-deleted-packages-from-archive-contents.patch >From 62fa93b120f664f1be44c1194f701a1c5d965f2a 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..12306ec818 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 specs) + "Remove dead packages from archive contents in DIR. +SPECS is the list of package specifications." + (let* ((filename (expand-file-name "archive-contents" dir)) + (ac (if (file-exists-p filename) + (elpaa--form-from-file-contents filename) + '(1)))) + (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 @@ -815,6 +834,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." (let ((specs (elpaa--get-specs))) + (elpaa--scrub-archive-contents elpaa--release-subdir specs) + (elpaa--scrub-archive-contents elpaa--devel-subdir specs) (dolist (spec specs) (condition-case err (elpaa--make-one-package spec) -- 2.38.0 --=-=-= Content-Type: text/plain > > Stefan > > > PS: Haven't really looked at the rest of the patch, actually, this part > just jumped at me. But now that I see how this is more complex than > your original patch, maybe doing it N times is the better option (and if > not, we can add a global boolean var telling us if we've done it > already). It is slightly more complicated, if only because I extracted `elpaa--write-archive-contents', but I think it is a lot cleaner than my first approach. --=-=-=--