From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.devel Subject: Re: Removing packages from archive-contents if removed from elpa-packages Date: Tue, 01 Nov 2022 22:02:04 -0400 Message-ID: References: <878rkwe3fv.fsf@posteo.net> <87wn8ggjdo.fsf@posteo.net> <87bkpsgeq3.fsf@posteo.net> <87y1svgdlu.fsf@posteo.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38521"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Philip Kaludercic Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Nov 02 03:03:09 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 1oq35w-0009qu-J1 for ged-emacs-devel@m.gmane-mx.org; Wed, 02 Nov 2022 03:03:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oq357-0005hJ-PQ; Tue, 01 Nov 2022 22:02:17 -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 1oq355-0005h0-Pa for emacs-devel@gnu.org; Tue, 01 Nov 2022 22:02:15 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oq354-0002vq-0w for emacs-devel@gnu.org; Tue, 01 Nov 2022 22:02:15 -0400 Original-Received: from pmg2.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id 752558004C; Tue, 1 Nov 2022 22:02:12 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg2.iro.umontreal.ca (Proxmox) with ESMTP id A5A4880723; Tue, 1 Nov 2022 22:02:10 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1667354530; bh=bzbBan0chPY9ycQ/Ii4KrLLjvrIlh9mE0DECyeo3ncA=; h=From:To:Cc:Subject:In-Reply-To:References:Date:From; b=MWMa8lqv3wq1og5vbJVvLmJ/B8SgZ0IYNHllIhNXCMfYjO/D23lhKOaRl4YH7Mu9C Ldj4GpbZ8JIEHXaxQ9DJBDOi2hVjrhA4PSP7IoHokw9HV4faq28S8ylWaTo8UcEFki uJ2XXhsu4Ds+8LaQII9ZCmKimWnL39+JyT/PARpTkDn/fhGnMTZNIgJ++GTyTFmMGb hSZAAA9+wR5yxTQ5iYaGvNUhJ5gVT+TYk8qjlA3M72xE+lQavvI7u0lBPVD9/fSOmO hpj0uewHjU/A8VTTr1n6Iw/Ik9eeWUQTkqHKCroJeAM5ZI5s22NIJKzZaC/NAEvCMi AvpuEwYK/mGJA== Original-Received: from pastel (65-110-220-202.cpe.pppoe.ca [65.110.220.202]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 4315012102F; Tue, 1 Nov 2022 22:02:10 -0400 (EDT) In-Reply-To: <87y1svgdlu.fsf@posteo.net> (Philip Kaludercic's message of "Tue, 01 Nov 2022 10:42:37 +0000") Received-SPF: pass client-ip=132.204.25.50; envelope-from=monnier@iro.umontreal.ca; helo=mailscanner.iro.umontreal.ca X-Spam_score_int: -42 X-Spam_score: -4.3 X-Spam_bar: ---- X-Spam_report: (-4.3 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_MED=-2.3, 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@gnu.org Xref: news.gmane.io gmane.emacs.devel:298987 Archived-At: > No, you are absolutely right, I just didn't see that. > > 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))) LGTM. Feel free to push. Just one comment: we could skip the `elpaa--write-archive-contents` (and associated `elpaa--html-make-index`) in the overwhelmingly common case where nothing was scrubbed. Stefan