From debbugs-submit-bounces@debbugs.gnu.org Sat May 06 16:52:20 2023 Received: (at submit) by debbugs.gnu.org; 6 May 2023 20:52:20 +0000 Received: from localhost ([127.0.0.1]:35859 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvOt9-0007dD-RT for submit@debbugs.gnu.org; Sat, 06 May 2023 16:52:20 -0400 Received: from lists.gnu.org ([209.51.188.17]:44048) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvOt8-0007d6-Hn for submit@debbugs.gnu.org; Sat, 06 May 2023 16:52:19 -0400 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 1pvOt8-00089D-4q for bug-gnu-emacs@gnu.org; Sat, 06 May 2023 16:52:18 -0400 Received: from out-63.mta1.migadu.com ([2001:41d0:203:375::3f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pvOt5-0002eA-Q5 for bug-gnu-emacs@gnu.org; Sat, 06 May 2023 16:52:17 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1683406329; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type; bh=uL7lbFkkO5AKCBewyNQ5CDPXi46iKeYA1r14+XanxV0=; b=lLmjrh2taYgB08NuHpudn+s9stqTZbd9cP4u89Wigi+BG+c+bYg/5TbuFIH+0WD1XpsuFQ 0N3u99p1kDG8J78GmN8dCksLsYPILsH1Ajx+kf3sRdlDe34owFSEcjEUro/Jh1BL1+r1t9 P/woCyoODKLzMEXNEih+HxPzCh0kw3E= From: Joseph Turner To: bug-gnu-emacs@gnu.org Subject: [PATCH] package-vc: Process :make and :shell-command spec args Date: Sat, 06 May 2023 13:39:52 -0700 X-Debbugs-CC: Philip Kaludercic Message-ID: <874joprxmx.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT Received-SPF: pass client-ip=2001:41d0:203:375::3f; envelope-from=joseph@breatheoutbreathe.in; helo=out-63.mta1.migadu.com 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-Spam-Score: -1.4 (-) X-Debbugs-Envelope-To: submit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -2.4 (--) --=-=-= Content-Type: text/plain Hello! Here's a patch to support :make and :shell-command args as discussed: https://lists.gnu.org/archive/html/help-gnu-emacs/2023-04/msg00263.html Best, Joseph --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: attachment; filename=0001-package-vc-Process-make-and-shell-command-spec-args.patch Content-Transfer-Encoding: quoted-printable >From c51161c51f11e6ffcba17758424596fe44f9d42a Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 6 May 2023 13:44:32 -0700 Subject: [PATCH] package-vc: Process :make and :shell-command spec args --- lisp/emacs-lisp/package-vc.el | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index 421947b528d..489610e2a1e 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -344,6 +344,35 @@ asynchronously." "\n") nil pkg-file nil 'silent)))) =20 +(defcustom package-vc-process-make nil + "If non-nil, process :make and :shell-command spec arguments. +Package specs are loaded from trusted package archives." + :type 'boolean) + +(defun package-vc--call (destination program &rest args) + "Like =E2=80=98call-process=E2=80=99 for PROGRAM, DESTINATION, ARGS. +The INFILE and DISPLAY arguments are fixed as nil." + (apply #'call-process program nil destination nil (delq nil args))) + +(defun package-vc--make (pkg-spec dir) + "Process :make and :shell-command spec arguments." + (let ((target (plist-get pkg-spec :make)) + (cmd (plist-get pkg-spec :shell-command))) + (when (or cmd target) + (with-current-buffer (get-buffer-create " *package-vc make*") + (erase-buffer) + (when (and cmd + (/=3D 0 (package-vc--call t shell-file-name + shell-command-switch + cmd))) + (message "Failed to run %s, see buffer %S" + cmd (buffer-name))) + (when (and target + (/=3D 0 (apply #'package-vc--call t "make" + (if (consp target) target (list target))))) + (message "Failed to make %s, see buffer %S" + target (buffer-name))))))) + (declare-function org-export-to-file "ox" (backend file)) =20 (defun package-vc--build-documentation (pkg-desc file) @@ -486,6 +515,9 @@ documentation and marking the package as installed." ;; Generate package file (package-vc--generate-description-file pkg-desc pkg-file) =20 + ;; Process :make and :shell-command arguments before building docume= ntation + (when package-vc-process-make (package-vc--make pkg-spec pkg-dir)) + ;; Detect a manual (when (executable-find "install-info") (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) --=20 2.39.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun May 07 05:03:53 2023 Received: (at 63336) by debbugs.gnu.org; 7 May 2023 09:03:53 +0000 Received: from localhost ([127.0.0.1]:36418 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvaJ7-0003jL-67 for submit@debbugs.gnu.org; Sun, 07 May 2023 05:03:53 -0400 Received: from mout01.posteo.de ([185.67.36.65]:34693) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvaJ4-0003j7-0m for 63336@debbugs.gnu.org; Sun, 07 May 2023 05:03:51 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 5DC002400D6 for <63336@debbugs.gnu.org>; Sun, 7 May 2023 11:03:44 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1683450224; bh=8ROilfBreDwUIF5VZGJu1p9wUPpiK7066zU+csvDjic=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=XG4MFRcT+LobQpjqkr940bzYJgRN475h/zhzMNVIaEAEt8XfbM+IcdRjOovgtBq0P MCrStgdfyhCi+U8g4/DgmgXZCTSdz1bmbOWUSMen2eLQvJbJkSk/p6hz0r/L1xbPzp qPxclg6JTHuNRLAN7iKloGSI7vbnHxW4kmun0T2b/nXAS8Bvqb80fWfCQD//ftwhYc Dcmv0+vzw4zpK2lrfv4rRHlhbC9LAPQ85zxaKoA58mpG424UJp9KqBkjvzMwNVy5cM FQvKGx1f6D01YCmYd46qEEnMuqWT7qpQkqLGGx78EwSJoT+riXZ98Fnu0dWvl+LGKs cJowVXwcM4hWA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QDdkl61jPz6tn4; Sun, 7 May 2023 11:03:43 +0200 (CEST) From: Philip Kaludercic To: Joseph Turner Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args In-Reply-To: <874joprxmx.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Sat, 06 May 2023 13:39:52 -0700") References: <874joprxmx.fsf@breatheoutbreathe.in> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Sun, 07 May 2023 09:03:43 +0000 Message-ID: <87jzxkecnk.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Joseph Turner writes: > Hello! > > Here's a patch to support :make and :shell-command args as discussed: > > https://lists.gnu.org/archive/html/help-gnu-emacs/2023-04/msg00263.html Thanks! > Best, > > Joseph > > From c51161c51f11e6ffcba17758424596fe44f9d42a Mon Sep 17 00:00:00 2001 > From: Joseph Turner > Date: Sat, 6 May 2023 13:44:32 -0700 > Subject: [PATCH] package-vc: Process :make and :shell-command spec args > > --- > lisp/emacs-lisp/package-vc.el | 32 ++++++++++++++++++++++++++++++++ > 1 file changed, 32 insertions(+) > > diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el > index 421947b528d..489610e2a1e 100644 > --- a/lisp/emacs-lisp/package-vc.el > +++ b/lisp/emacs-lisp/package-vc.el > @@ -344,6 +344,35 @@ asynchronously." > "\n") > nil pkg-file nil 'silent)))) >=20=20 > +(defcustom package-vc-process-make nil > + "If non-nil, process :make and :shell-command spec arguments. > +Package specs are loaded from trusted package archives." > + :type 'boolean) As this patch is going to be added to Emacs 30, we should add :version "30.1" tags to this user option. > +(defun package-vc--call (destination program &rest args) > + "Like =E2=80=98call-process=E2=80=99 for PROGRAM, DESTINATION, ARGS. ^ You should replace these quotation marks with regular ASCII `marks', so avoid byte-compiler warnings. > +The INFILE and DISPLAY arguments are fixed as nil." > + (apply #'call-process program nil destination nil (delq nil args))) What is the motivation for this function? Is this where process-isolation would be added in the future? > +(defun package-vc--make (pkg-spec dir) > + "Process :make and :shell-command spec arguments." > + (let ((target (plist-get pkg-spec :make)) > + (cmd (plist-get pkg-spec :shell-command))) > + (when (or cmd target) > + (with-current-buffer (get-buffer-create " *package-vc make*") ^ should the package name be mentioned here? > + (erase-buffer) > + (when (and cmd > + (/=3D 0 (package-vc--call t shell-file-name > + shell-command-switch > + cmd))) > + (message "Failed to run %s, see buffer %S" Could `warn' be a better candidate here, instead of `message'? > + cmd (buffer-name))) > + (when (and target > + (/=3D 0 (apply #'package-vc--call t "make" > + (if (consp target) target (list target))= ))) > + (message "Failed to make %s, see buffer %S" > + target (buffer-name))))))) > + > (declare-function org-export-to-file "ox" (backend file)) >=20=20 > (defun package-vc--build-documentation (pkg-desc file) > @@ -486,6 +515,9 @@ documentation and marking the package as installed." > ;; Generate package file > (package-vc--generate-description-file pkg-desc pkg-file) >=20=20 > + ;; Process :make and :shell-command arguments before building docu= mentation > + (when package-vc-process-make (package-vc--make pkg-spec pkg-dir)) Wasn't the plan to allow `package-vc-process-make' to either be a generic "build-anything" or a selective listing of packages where we allow :make and :shell-command to be executed? > + > ;; Detect a manual > (when (executable-find "install-info") > (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) Otherwise this looks good, but I haven't tried it out yet. --=20 Philip Kaludercic From debbugs-submit-bounces@debbugs.gnu.org Sun May 07 16:28:18 2023 Received: (at 63336) by debbugs.gnu.org; 7 May 2023 20:28:18 +0000 Received: from localhost ([127.0.0.1]:38575 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvkzS-00036v-7K for submit@debbugs.gnu.org; Sun, 07 May 2023 16:28:18 -0400 Received: from out-49.mta0.migadu.com ([91.218.175.49]:35691) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvkzQ-00036j-7G for 63336@debbugs.gnu.org; Sun, 07 May 2023 16:28:17 -0400 References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1683491294; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Xty4WvFOuwgr9v3ejeDiR+VJrVWRSqPS25pWtUI7YSs=; b=TBZw87a3ISoS15AaBimb0wy3i6NEfmhSiXfCYr5Pk6OwwIQAmrdMaBFYxxgDBJZWsNowz1 A9V0rY9Ofmd1Tqx4IoXaHJBwYFzyFHg3D6u4jAIQ0pMdXFcgk0Kv2wHa6mnAZZdxM8QUWk ghwYPNvMGip7gl6aCpiL2smAo9RptfU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Philip Kaludercic Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args Date: Sun, 07 May 2023 11:47:29 -0700 In-reply-to: <87jzxkecnk.fsf@posteo.net> Message-ID: <87pm7b7up0.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Thanks for the review! Philip Kaludercic writes: > Joseph Turner writes: > >> Hello! >> >> Here's a patch to support :make and :shell-command args as discussed: >> >> https://lists.gnu.org/archive/html/help-gnu-emacs/2023-04/msg00263.html > > Thanks! > >> Best, >> >> Joseph >> >> From c51161c51f11e6ffcba17758424596fe44f9d42a Mon Sep 17 00:00:00 2001 >> From: Joseph Turner >> Date: Sat, 6 May 2023 13:44:32 -0700 >> Subject: [PATCH] package-vc: Process :make and :shell-command spec args >> >> --- >> lisp/emacs-lisp/package-vc.el | 32 ++++++++++++++++++++++++++++++++ >> 1 file changed, 32 insertions(+) >> >> diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.= el >> index 421947b528d..489610e2a1e 100644 >> --- a/lisp/emacs-lisp/package-vc.el >> +++ b/lisp/emacs-lisp/package-vc.el >> @@ -344,6 +344,35 @@ asynchronously." >> "\n") >> nil pkg-file nil 'silent)))) >> >> +(defcustom package-vc-process-make nil >> + "If non-nil, process :make and :shell-command spec arguments. >> +Package specs are loaded from trusted package archives." >> + :type 'boolean) > > As this patch is going to be added to Emacs 30, we should add > > :version "30.1" > > tags to this user option. Fixed. >> +(defun package-vc--call (destination program &rest args) >> + "Like =E2=80=98call-process=E2=80=99 for PROGRAM, DESTINATION, ARGS. > ^ > You should replace these quotation marks with regular ASCII `marks', so > avoid byte-compiler warnings. Good catch. >> +The INFILE and DISPLAY arguments are fixed as nil." >> + (apply #'call-process program nil destination nil (delq nil args))) > > What is the motivation for this function? Is this where > process-isolation would be added in the future? In the attached patch, package-vc--call is replaced with call-process. >> +(defun package-vc--make (pkg-spec dir) >> + "Process :make and :shell-command spec arguments." >> + (let ((target (plist-get pkg-spec :make)) >> + (cmd (plist-get pkg-spec :shell-command))) >> + (when (or cmd target) >> + (with-current-buffer (get-buffer-create " *package-vc make*") > ^ > should the package name > be mentioned here? I like this idea, but IIUC package-vc--make would then need to take an extra arg, since pkg-spec doesn't contain the :name of the package. We could also add :name to the pkg-spec plist? For comparison, package-vc--build-documentation creates a buffer called " *package-vc doc*" without the package name. >> + (erase-buffer) >> + (when (and cmd >> + (/=3D 0 (package-vc--call t shell-file-name >> + shell-command-switch >> + cmd))) >> + (message "Failed to run %s, see buffer %S" > > Could `warn' be a better candidate here, instead of `message'? Done. >> + cmd (buffer-name))) >> + (when (and target >> + (/=3D 0 (apply #'package-vc--call t "make" >> + (if (consp target) target (list target)= )))) >> + (message "Failed to make %s, see buffer %S" And this message is changed to warn also. >> + target (buffer-name))))))) >> + >> (declare-function org-export-to-file "ox" (backend file)) >> >> (defun package-vc--build-documentation (pkg-desc file) >> @@ -486,6 +515,9 @@ documentation and marking the package as installed." >> ;; Generate package file >> (package-vc--generate-description-file pkg-desc pkg-file) >> >> + ;; Process :make and :shell-command arguments before building doc= umentation >> + (when package-vc-process-make (package-vc--make pkg-spec pkg-dir)) > > Wasn't the plan to allow `package-vc-process-make' to either be a > generic "build-anything" or a selective listing of packages where we > allow :make and :shell-command to be executed? Let me know if the attached commit accomplishes what you had in mind. >> + >> ;; Detect a manual >> (when (executable-find "install-info") >> (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) > > Otherwise this looks good, but I haven't tried it out yet. I fixed up a couple other issues: - removed unnecessary dir arg to package-vc--make - added function arg to the docstring for package-vc--make I'm not sure if the customization type for package-vc-process-make is correct. Please double check that. Also, should users be able to run :make and :shell-command args defined in a spec passed into package-vc-install? Best, Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-package-vc-Process-make-and-shell-command-spec-args.patch >From f536b42492e1520cc8da4e92b5bb65552ba39e6a Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 6 May 2023 13:44:32 -0700 Subject: [PATCH] package-vc: Process :make and :shell-command spec args --- lisp/emacs-lisp/package-vc.el | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index 421947b528d..476c38916a8 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -344,6 +344,31 @@ asynchronously." "\n") nil pkg-file nil 'silent)))) +(defcustom package-vc-process-make nil + "Whether to process :make and :shell-command spec arguments. + +When set to a list of symbols (packages), run commands for only +packages in the list. When `nil', never run commands. Otherwise +when non-`nil', run commands for any package with :make or +:shell-command specified. + +Package specs are loaded from trusted package archives." + :type '(choice (boolean :tag "Run for all packages") + (repeat (symbol :tag "Run for only selected packages"))) + :version "30.1") + +(defun package-vc--make (pkg-spec) + "Process :make and :shell-command PKG-SPEC arguments." + (let ((target (plist-get pkg-spec :make)) + (cmd (plist-get pkg-spec :shell-command))) + (when (or cmd target) + (with-current-buffer (get-buffer-create " *package-vc make*") + (erase-buffer) + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) + (declare-function org-export-to-file "ox" (backend file)) (defun package-vc--build-documentation (pkg-desc file) @@ -486,6 +511,16 @@ documentation and marking the package as installed." ;; Generate package file (package-vc--generate-description-file pkg-desc pkg-file) + ;; Process :make and :shell-command arguments before building documentation + (pcase package-vc-process-make + ((pred consp) ; When non-`nil' list, check if package is on the list. + (when (memq (package-desc-name pkg-desc) package-vc-process-make) + (package-vc--make pkg-spec))) + ('nil ; When `nil', do nothing. + nil) + (_ ; When otherwise non-`nil', run commands. + (package-vc--make pkg-spec))) + ;; Detect a manual (when (executable-find "install-info") (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) -- 2.39.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon May 08 04:42:36 2023 Received: (at 63336) by debbugs.gnu.org; 8 May 2023 08:42:36 +0000 Received: from localhost ([127.0.0.1]:39112 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvwS4-0001zG-7s for submit@debbugs.gnu.org; Mon, 08 May 2023 04:42:36 -0400 Received: from netyu.xyz ([152.44.41.246]:54132 helo=mail.netyu.xyz) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pvwS2-0001yy-12 for 63336@debbugs.gnu.org; Mon, 08 May 2023 04:42:35 -0400 Received: from smtpclient.apple ( [112.97.61.182]) by netyu.xyz (OpenSMTPD) with ESMTPSA id 463d990d (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Mon, 8 May 2023 08:42:33 +0000 (UTC) Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable From: Ruijie Yu Mime-Version: 1.0 (1.0) Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args Date: Mon, 8 May 2023 16:42:12 +0800 Message-Id: <87B6D8F0-415D-4B16-BDC3-826525FAF04A@netyu.xyz> References: <87pm7b7up0.fsf@breatheoutbreathe.in> In-Reply-To: <87pm7b7up0.fsf@breatheoutbreathe.in> To: Joseph Turner X-Mailer: iPhone Mail (20E252) X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org, Philip Kaludercic X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: 0.0 (/) Hello Joseph,=20 On mobile so please excuse my brevity and top-posting.=20 Minor remark on the defcustom type: I think you should move the current tag f= rom "symbol" to its outer "repeat", and optionally tag "symbol" as something= like "package name". WDYT?=20 -- Best,=20 RY > On May 8, 2023, at 04:29, Joseph Turner via Bug reports for GNU Emacs, the= Swiss army knife of text editors wrote: >=20 > =EF=BB=BFThanks for the review! >=20 > Philip Kaludercic writes: >=20 >> Joseph Turner writes: >>=20 >>> Hello! >>>=20 >>> Here's a patch to support :make and :shell-command args as discussed: >>>=20 >>> https://lists.gnu.org/archive/html/help-gnu-emacs/2023-04/msg00263.html >>=20 >> Thanks! >>=20 >>> Best, >>>=20 >>> Joseph >>>=20 >>> =46rom c51161c51f11e6ffcba17758424596fe44f9d42a Mon Sep 17 00:00:00 2001= >>> From: Joseph Turner >>> Date: Sat, 6 May 2023 13:44:32 -0700 >>> Subject: [PATCH] package-vc: Process :make and :shell-command spec args >>>=20 >>> --- >>> lisp/emacs-lisp/package-vc.el | 32 ++++++++++++++++++++++++++++++++ >>> 1 file changed, 32 insertions(+) >>>=20 >>> diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.= el >>> index 421947b528d..489610e2a1e 100644 >>> --- a/lisp/emacs-lisp/package-vc.el >>> +++ b/lisp/emacs-lisp/package-vc.el >>> @@ -344,6 +344,35 @@ asynchronously." >>> "\n") >>> nil pkg-file nil 'silent)))) >>>=20 >>> +(defcustom package-vc-process-make nil >>> + "If non-nil, process :make and :shell-command spec arguments. >>> +Package specs are loaded from trusted package archives." >>> + :type 'boolean) >>=20 >> As this patch is going to be added to Emacs 30, we should add >>=20 >> :version "30.1" >>=20 >> tags to this user option. >=20 > Fixed. >=20 >>> +(defun package-vc--call (destination program &rest args) >>> + "Like =E2=80=98call-process=E2=80=99 for PROGRAM, DESTINATION, ARGS. >> ^ >> You should replace these quotation marks with regular ASCII `marks', so >> avoid byte-compiler warnings. >=20 > Good catch. >=20 >>> +The INFILE and DISPLAY arguments are fixed as nil." >>> + (apply #'call-process program nil destination nil (delq nil args))) >>=20 >> What is the motivation for this function? Is this where >> process-isolation would be added in the future? >=20 > In the attached patch, package-vc--call is replaced with call-process. >=20 >>> +(defun package-vc--make (pkg-spec dir) >>> + "Process :make and :shell-command spec arguments." >>> + (let ((target (plist-get pkg-spec :make)) >>> + (cmd (plist-get pkg-spec :shell-command))) >>> + (when (or cmd target) >>> + (with-current-buffer (get-buffer-create " *package-vc make*") >> ^ >> should the package name >> be mentioned here? >=20 > I like this idea, but IIUC package-vc--make would then need to take an > extra arg, since pkg-spec doesn't contain the :name of the package. We > could also add :name to the pkg-spec plist? >=20 > For comparison, package-vc--build-documentation creates a buffer called > " *package-vc doc*" without the package name. >=20 >>> + (erase-buffer) >>> + (when (and cmd >>> + (/=3D 0 (package-vc--call t shell-file-name >>> + shell-command-switch >>> + cmd))) >>> + (message "Failed to run %s, see buffer %S" >>=20 >> Could `warn' be a better candidate here, instead of `message'? >=20 > Done. >=20 >>> + cmd (buffer-name))) >>> + (when (and target >>> + (/=3D 0 (apply #'package-vc--call t "make" >>> + (if (consp target) target (list target)= )))) >>> + (message "Failed to make %s, see buffer %S" >=20 > And this message is changed to warn also. >=20 >>> + target (buffer-name))))))) >>> + >>> (declare-function org-export-to-file "ox" (backend file)) >>>=20 >>> (defun package-vc--build-documentation (pkg-desc file) >>> @@ -486,6 +515,9 @@ documentation and marking the package as installed."= >>> ;; Generate package file >>> (package-vc--generate-description-file pkg-desc pkg-file) >>>=20 >>> + ;; Process :make and :shell-command arguments before building doc= umentation >>> + (when package-vc-process-make (package-vc--make pkg-spec pkg-dir)= ) >>=20 >> Wasn't the plan to allow `package-vc-process-make' to either be a >> generic "build-anything" or a selective listing of packages where we >> allow :make and :shell-command to be executed? >=20 > Let me know if the attached commit accomplishes what you had in mind. >=20 >>> + >>> ;; Detect a manual >>> (when (executable-find "install-info") >>> (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) >>=20 >> Otherwise this looks good, but I haven't tried it out yet. >=20 > I fixed up a couple other issues: >=20 > - removed unnecessary dir arg to package-vc--make > - added function arg to the docstring for package-vc--make >=20 > I'm not sure if the customization type for package-vc-process-make is > correct. Please double check that. >=20 > Also, should users be able to run :make and :shell-command args defined > in a spec passed into package-vc-install? >=20 > Best, >=20 > Joseph >=20 > <0001-package-vc-Process-make-and-shell-command-spec-args.patch> From debbugs-submit-bounces@debbugs.gnu.org Mon May 08 15:39:34 2023 Received: (at 63336) by debbugs.gnu.org; 8 May 2023 19:39:35 +0000 Received: from localhost ([127.0.0.1]:41704 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pw6hq-0004lr-En for submit@debbugs.gnu.org; Mon, 08 May 2023 15:39:34 -0400 Received: from out-28.mta0.migadu.com ([91.218.175.28]:42725) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pw6hn-0004le-Kc for 63336@debbugs.gnu.org; Mon, 08 May 2023 15:39:33 -0400 References: <87pm7b7up0.fsf@breatheoutbreathe.in> <87B6D8F0-415D-4B16-BDC3-826525FAF04A@netyu.xyz> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1683574769; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=0m/NnVuDfvICDz9uk9RtGHFBKg+TZIXMkBTeOBMLKRY=; b=ZjvPlMS86IJiORygDZeL3aL1FEdaLSKxaxFG/smE25WKHPJobP79PKkxNDqsWyyxWVLcls rdqz1kfEXqUnuAn6PQWTS/BptD0WtvBCqHrLo3zR29CdOKOnakByr/42+5hmfz8S0o7tls ig/6Y0YvurIEchZXLlW/Ov2bRC/ttaU= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Ruijie Yu Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args Date: Mon, 08 May 2023 12:38:06 -0700 In-reply-to: <87B6D8F0-415D-4B16-BDC3-826525FAF04A@netyu.xyz> Message-ID: <87pm7ahatx.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org, Philip Kaludercic X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Ruijie Yu writes: > Hello Joseph, > > On mobile so please excuse my brevity and top-posting. > > Minor remark on the defcustom type: I think you should move the current tag from "symbol" to its outer "repeat", and optionally tag "symbol" as something like "package name". WDYT? Thanks, Ruijie! I think the defcustom type is now correct. Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-package-vc-Process-make-and-shell-command-spec-args.patch >From 8f9238b841f6deec65fd52d696aa26caf1bf123a Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 6 May 2023 13:44:32 -0700 Subject: [PATCH] package-vc: Process :make and :shell-command spec args --- lisp/emacs-lisp/package-vc.el | 36 +++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index 421947b528d..95e12fc829a 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -344,6 +344,32 @@ asynchronously." "\n") nil pkg-file nil 'silent)))) +(defcustom package-vc-process-make nil + "Whether to process :make and :shell-command spec arguments. + +When set to a list of symbols (packages), run commands for only +packages in the list. When `nil', never run commands. Otherwise +when non-`nil', run commands for any package with :make or +:shell-command specified. + +Package specs are loaded from trusted package archives." + :type '(choice (const :tag "Run for all packages" t) + (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) + (const :tag "Never run" nil)) + :version "30.1") + +(defun package-vc--make (pkg-spec) + "Process :make and :shell-command PKG-SPEC arguments." + (let ((target (plist-get pkg-spec :make)) + (cmd (plist-get pkg-spec :shell-command))) + (when (or cmd target) + (with-current-buffer (get-buffer-create " *package-vc make*") + (erase-buffer) + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) + (declare-function org-export-to-file "ox" (backend file)) (defun package-vc--build-documentation (pkg-desc file) @@ -486,6 +512,16 @@ documentation and marking the package as installed." ;; Generate package file (package-vc--generate-description-file pkg-desc pkg-file) + ;; Process :make and :shell-command arguments before building documentation + (pcase package-vc-process-make + ((pred consp) ; When non-`nil' list, check if package is on the list. + (when (memq (package-desc-name pkg-desc) package-vc-process-make) + (package-vc--make pkg-spec))) + ('nil ; When `nil', do nothing. + nil) + (_ ; When otherwise non-`nil', run commands. + (package-vc--make pkg-spec))) + ;; Detect a manual (when (executable-find "install-info") (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) -- 2.39.2 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon May 08 20:03:35 2023 Received: (at 63336) by debbugs.gnu.org; 9 May 2023 00:03:35 +0000 Received: from localhost ([127.0.0.1]:41905 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pwApK-0004O2-Nu for submit@debbugs.gnu.org; Mon, 08 May 2023 20:03:35 -0400 Received: from eggs.gnu.org ([209.51.188.92]:35902) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pwApJ-0004Nr-Pa for 63336@debbugs.gnu.org; Mon, 08 May 2023 20:03:34 -0400 Received: from fencepost.gnu.org ([2001:470:142:3::e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pwApD-0008Sc-Sw; Mon, 08 May 2023 20:03:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=Date:References:Subject:In-Reply-To:To:From: mime-version; bh=/Ebu8BOtG30pQg3s92ZInUC15ZywEAQxVi2k7g4fO3s=; b=W2yawmSoS2VT ufKKIEPcCeyAC6mdwbc9FFMJtPQv2dJFs31GGDDlIvm/PnF7Ryp+dJ/zXnof2XJsMwOYHXJEMDkGW JjIa/6WYTq1PS6GAtGNxHOZZk/S8WpxqMUk6JTWM47aO5+ATKMLnmbRHVEu12tyzc4mqKQJtq+hnA C771LF7imXvaG2q1fXfRPFCsJ1CyXzGUSIpqrzpw/xeepuN4hIwJ8rsbQR30f8iAyAlIf6Z7/H25F YuqsYW8WkXJBks51p9TnIlPiR3Z6hkJHMGIvIv1/LGYd89q0dOfQuFjKwkbhCsE/EhYsqMxW9z54q jB+DCTkgUqPogyQUb7tNfA==; Received: from rms by fencepost.gnu.org with local (Exim 4.90_1) (envelope-from ) id 1pwAp8-0005FN-2H; Mon, 08 May 2023 20:03:23 -0400 Content-Type: text/plain; charset=Utf-8 From: Richard Stallman To: Ruijie Yu In-Reply-To: <87B6D8F0-415D-4B16-BDC3-826525FAF04A@netyu.xyz> (bug-gnu-emacs@gnu.org) Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args References: <87pm7b7up0.fsf@breatheoutbreathe.in> <87B6D8F0-415D-4B16-BDC3-826525FAF04A@netyu.xyz> Message-Id: Date: Mon, 08 May 2023 20:03:22 -0400 X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org, philipk@posteo.net, joseph@breatheoutbreathe.in X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: rms@gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) [[[ To any NSA and FBI agents reading my email: please consider ]]] [[[ whether defending the US Constitution against all enemies, ]]] [[[ foreign or domestic, requires you to follow Snowden's example. ]]] > On mobile so please excuse my brevity and top-posting. I have a feeling that means you are running nonfree malware. It's too bad. But anyway, thanks for contributing to Emacs. -- Dr Richard Stallman (https://stallman.org) Chief GNUisance of the GNU Project (https://gnu.org) Founder, Free Software Foundation (https://fsf.org) Internet Hall-of-Famer (https://internethalloffame.org) From debbugs-submit-bounces@debbugs.gnu.org Wed May 10 02:35:13 2023 Received: (at 63336) by debbugs.gnu.org; 10 May 2023 06:35:13 +0000 Received: from localhost ([127.0.0.1]:45049 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pwdPt-00026y-5B for submit@debbugs.gnu.org; Wed, 10 May 2023 02:35:13 -0400 Received: from mout02.posteo.de ([185.67.36.66]:33869) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pwdPq-00026f-CU for 63336@debbugs.gnu.org; Wed, 10 May 2023 02:35:11 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 57044240350 for <63336@debbugs.gnu.org>; Wed, 10 May 2023 08:35:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1683700504; bh=nuQpf1V3TVYzeVsE3ExjNzCzR4lsWoiz9dfhp2QMxHQ=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=DmdRwl/Y5siLNxO585/PZbcencw/JzvQ1VNnbniyEaEbLqB/nsUS4lmbppgkwIGX2 1yMqiWfhjAXGLHPrT8c7dda5lNxEVOrT3gi9t05FYjc1gdqjqd/jaa6ZaLcjf3ZJ9R UPJ3KOyR07lsdkduWu9exeNMCpfl5m1boa1ZarOuh9bIxGx5OlI7qNKOaWe7FOBa81 PVOu3dfBp9sVpDRSodtgPYkp3+LVdw7VNYnnoCExbVt7gEEv6ca4k6TRbcnDJ2a5v3 S5UScgVDgYz2U1AynOTNwQzu8eD8OOmd3psxJZONNL1LoOgV65O7J5JQ7qjXpDvm2E QxIDN0P1xcYug== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QGQHq5Hpxz9rxT; Wed, 10 May 2023 08:35:03 +0200 (CEST) From: Philip Kaludercic To: Joseph Turner Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args In-Reply-To: <87pm7b7up0.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Sun, 07 May 2023 11:47:29 -0700") References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Wed, 10 May 2023 06:35:03 +0000 Message-ID: <877ctghey0.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Joseph Turner writes: >>> +(defun package-vc--make (pkg-spec dir) >>> + "Process :make and :shell-command spec arguments." >>> + (let ((target (plist-get pkg-spec :make)) >>> + (cmd (plist-get pkg-spec :shell-command))) >>> + (when (or cmd target) >>> + (with-current-buffer (get-buffer-create " *package-vc make*") >> ^ >> should the package name >> be mentioned here? > > I like this idea, but IIUC package-vc--make would then need to take an > extra arg, since pkg-spec doesn't contain the :name of the package. We > could also add :name to the pkg-spec plist? I wouldn't be in favour of that, I think that passing the name as a separate argument would be a better solution. > For comparison, package-vc--build-documentation creates a buffer called > " *package-vc doc*" without the package name. The difference I see here is that documentation usually builds fine, while :make or :shell-command have a higher chance of failing because some software is missing, especially if people don't use :make the way it is used on the ELPA server but to build external dependencies (I'm thinking of mail clients like notmuch) >>> + target (buffer-name))))))) >>> + >>> (declare-function org-export-to-file "ox" (backend file)) >>> >>> (defun package-vc--build-documentation (pkg-desc file) >>> @@ -486,6 +515,9 @@ documentation and marking the package as installed." >>> ;; Generate package file >>> (package-vc--generate-description-file pkg-desc pkg-file) >>> >>> + ;; Process :make and :shell-command arguments before building documentation >>> + (when package-vc-process-make (package-vc--make pkg-spec pkg-dir)) >> >> Wasn't the plan to allow `package-vc-process-make' to either be a >> generic "build-anything" or a selective listing of packages where we >> allow :make and :shell-command to be executed? > > Let me know if the attached commit accomplishes what you had in mind. Yes, that (or rather the newest version from a different message) looks good. >>> + >>> ;; Detect a manual >>> (when (executable-find "install-info") >>> (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) >> >> Otherwise this looks good, but I haven't tried it out yet. > > I fixed up a couple other issues: > > - removed unnecessary dir arg to package-vc--make > - added function arg to the docstring for package-vc--make > > I'm not sure if the customization type for package-vc-process-make is > correct. Please double check that. > > Also, should users be able to run :make and :shell-command args defined > in a spec passed into package-vc-install? Yes, is that currently not supported? > Best, > > Joseph From debbugs-submit-bounces@debbugs.gnu.org Sat May 13 13:18:32 2023 Received: (at 63336) by debbugs.gnu.org; 13 May 2023 17:18:32 +0000 Received: from localhost ([127.0.0.1]:39492 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxst6-0002cr-5I for submit@debbugs.gnu.org; Sat, 13 May 2023 13:18:32 -0400 Received: from mout01.posteo.de ([185.67.36.65]:57013) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxst4-0002cb-V5 for 63336@debbugs.gnu.org; Sat, 13 May 2023 13:18:31 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 6EE7524002F for <63336@debbugs.gnu.org>; Sat, 13 May 2023 19:18:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1683998305; bh=D/5pqouVJTcKYaFVF6jWQkUz4xenE0eOExfKN0mNbeA=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=BMsA7rVN9kL4sqDr5NPwUyILJp96U4152TDoXqTKAeJppyZh6RCwr6S+6uqexdVAj pj+JfSo6t054mbRa1HvCqu61q5B+M82YO3yn78nRC7jwOWCnMCflSYz2sHoGQ+01XH TeagUK/FQI9NxDDc7Axp1/IMyoDns3qcaXSfHyz10/Y7eF9hT0P9s0BWJZ2s7O508A cZ0SzGme2ZNASyrocOL8TwW+Aeh8sVg7lkQx9hd9ynoi7rr0iZ4zmKRcnTuxf65OS1 iPMN52tpnad7jfYQKl6otdgxU0LfWH/AwDkusAtvJNeSxmjxlvSI0pPI/2buNkFQIa cPr6neqjn+urQ== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QJXQn0kwGz9rxB; Sat, 13 May 2023 19:18:25 +0200 (CEST) From: Philip Kaludercic To: Joseph Turner Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args In-Reply-To: <877ctghey0.fsf@posteo.net> (Philip Kaludercic's message of "Wed, 10 May 2023 06:35:03 +0000") References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Sat, 13 May 2023 17:18:24 +0000 Message-ID: <87r0rk880v.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) ping? Philip Kaludercic writes: > Joseph Turner writes: > >>>> +(defun package-vc--make (pkg-spec dir) >>>> + "Process :make and :shell-command spec arguments." >>>> + (let ((target (plist-get pkg-spec :make)) >>>> + (cmd (plist-get pkg-spec :shell-command))) >>>> + (when (or cmd target) >>>> + (with-current-buffer (get-buffer-create " *package-vc make*") >>> ^ >>> should the package name >>> be mentioned here? >> >> I like this idea, but IIUC package-vc--make would then need to take an >> extra arg, since pkg-spec doesn't contain the :name of the package. We >> could also add :name to the pkg-spec plist? > > I wouldn't be in favour of that, I think that passing the name as a > separate argument would be a better solution. > >> For comparison, package-vc--build-documentation creates a buffer called >> " *package-vc doc*" without the package name. > > The difference I see here is that documentation usually builds fine, > while :make or :shell-command have a higher chance of failing because > some software is missing, especially if people don't use :make the way > it is used on the ELPA server but to build external dependencies (I'm > thinking of mail clients like notmuch) > >>>> + target (buffer-name))))))) >>>> + >>>> (declare-function org-export-to-file "ox" (backend file)) >>>> >>>> (defun package-vc--build-documentation (pkg-desc file) >>>> @@ -486,6 +515,9 @@ documentation and marking the package as installed." >>>> ;; Generate package file >>>> (package-vc--generate-description-file pkg-desc pkg-file) >>>> >>>> + ;; Process :make and :shell-command arguments before building documentation >>>> + (when package-vc-process-make (package-vc--make pkg-spec pkg-dir)) >>> >>> Wasn't the plan to allow `package-vc-process-make' to either be a >>> generic "build-anything" or a selective listing of packages where we >>> allow :make and :shell-command to be executed? >> >> Let me know if the attached commit accomplishes what you had in mind. > > Yes, that (or rather the newest version from a different message) looks good. > >>>> + >>>> ;; Detect a manual >>>> (when (executable-find "install-info") >>>> (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) >>> >>> Otherwise this looks good, but I haven't tried it out yet. >> >> I fixed up a couple other issues: >> >> - removed unnecessary dir arg to package-vc--make >> - added function arg to the docstring for package-vc--make >> >> I'm not sure if the customization type for package-vc-process-make is >> correct. Please double check that. >> >> Also, should users be able to run :make and :shell-command args defined >> in a spec passed into package-vc-install? > > Yes, is that currently not supported? > >> Best, >> >> Joseph From debbugs-submit-bounces@debbugs.gnu.org Sat May 13 15:15:13 2023 Received: (at 63336) by debbugs.gnu.org; 13 May 2023 19:15:13 +0000 Received: from localhost ([127.0.0.1]:39670 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxui1-0008N2-4i for submit@debbugs.gnu.org; Sat, 13 May 2023 15:15:13 -0400 Received: from out-57.mta1.migadu.com ([95.215.58.57]:11563) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pxuhz-0008Mu-5M for 63336@debbugs.gnu.org; Sat, 13 May 2023 15:15:12 -0400 References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1684005309; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=vYQR5y1u0olTWIMDqXeKTCvHbgpBds47qRBDxH5Dx+c=; b=SNEp1rT977o0RUSltV572rEx3lodWZTV9IXv1//d4ytMXLn9F7wvKol5apaoTjvePaBWSq 4pQs8+iuLufe4PTocIphHgPijKMxKXoqjk3jRFTxumfDzuxrKJU9tfF85sUxPcE2SkjJ4T Ekv2cBY1+zv5cceYNQf6eOg73tp/DX4= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Philip Kaludercic Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args Date: Wed, 10 May 2023 18:37:15 -0700 In-reply-to: <877ctghey0.fsf@posteo.net> Message-ID: <873540rqkm.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Philip Kaludercic writes: > Joseph Turner writes: > >>>> +(defun package-vc--make (pkg-spec dir) >>>> + "Process :make and :shell-command spec arguments." >>>> + (let ((target (plist-get pkg-spec :make)) >>>> + (cmd (plist-get pkg-spec :shell-command))) >>>> + (when (or cmd target) >>>> + (with-current-buffer (get-buffer-create " *package-vc make*") >>> ^ >>> should the package name >>> be mentioned here? >> >> I like this idea, but IIUC package-vc--make would then need to take an >> extra arg, since pkg-spec doesn't contain the :name of the package. We >> could also add :name to the pkg-spec plist? > > I wouldn't be in favour of that, I think that passing the name as a > separate argument would be a better solution. I agree. >> For comparison, package-vc--build-documentation creates a buffer called >> " *package-vc doc*" without the package name. > > The difference I see here is that documentation usually builds fine, > while :make or :shell-command have a higher chance of failing because > some software is missing, especially if people don't use :make the way > it is used on the ELPA server but to build external dependencies (I'm > thinking of mail clients like notmuch) That makes sense to me. In the attached patch, I pass pkg-desc to package-vc--make instead just name. Want me to submit a separate patch which adds the package name to the " *package-vc doc*" buffer name? >>>> + target (buffer-name))))))) >>>> + >>>> (declare-function org-export-to-file "ox" (backend file)) >>>> >>>> (defun package-vc--build-documentation (pkg-desc file) >>>> @@ -486,6 +515,9 @@ documentation and marking the package as installed." >>>> ;; Generate package file >>>> (package-vc--generate-description-file pkg-desc pkg-file) >>>> >>>> + ;; Process :make and :shell-command arguments before building documentation >>>> + (when package-vc-process-make (package-vc--make pkg-spec pkg-dir)) >>> >>> Wasn't the plan to allow `package-vc-process-make' to either be a >>> generic "build-anything" or a selective listing of packages where we >>> allow :make and :shell-command to be executed? >> >> Let me know if the attached commit accomplishes what you had in mind. > > Yes, that (or rather the newest version from a different message) looks good. > >>>> + >>>> ;; Detect a manual >>>> (when (executable-find "install-info") >>>> (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) >>> >>> Otherwise this looks good, but I haven't tried it out yet. >> >> I fixed up a couple other issues: >> >> - removed unnecessary dir arg to package-vc--make >> - added function arg to the docstring for package-vc--make >> >> I'm not sure if the customization type for package-vc-process-make is >> correct. Please double check that. >> >> Also, should users be able to run :make and :shell-command args defined >> in a spec passed into package-vc-install? > > Yes, is that currently not supported? Nevermind! It is supported. I didn't notice that package-vc--unpack adds the user-defined pkg-spec to package-vc-selected-packages just before calling package-vc--unpack-1. Best, Joseph --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-package-vc-Process-make-and-shell-command-spec-args.patch >From b27724197acd4ee72f9d336843f0e6ed9fcee87b Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 13 May 2023 10:05:04 -0700 Subject: [PATCH] package-vc: Process :make and :shell-command spec args --- lisp/emacs-lisp/package-vc.el | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index beca0bd00e2..8529d1dad5c 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -344,6 +344,33 @@ asynchronously." "\n") nil pkg-file nil 'silent)))) +(defcustom package-vc-process-make nil + "Whether to process :make and :shell-command spec arguments. + +When set to a list of symbols (packages), run commands for only +packages in the list. When `nil', never run commands. Otherwise +when non-`nil', run commands for any package with :make or +:shell-command specified. + +Package specs are loaded from trusted package archives." + :type '(choice (const :tag "Run for all packages" t) + (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) + (const :tag "Never run" nil)) + :version "30.1") + +(defun package-vc--make (pkg-spec pkg-desc) + "Process :make and :shell-command PKG-SPEC arguments for PKG-DESC." + (let ((target (plist-get pkg-spec :make)) + (cmd (plist-get pkg-spec :shell-command))) + (when (or cmd target) + (with-current-buffer (get-buffer-create + (format " *package-vc make %s*" (package-desc-name pkg-desc))) + (erase-buffer) + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) + (declare-function org-export-to-file "ox" (backend file)) (defun package-vc--build-documentation (pkg-desc file) @@ -486,6 +513,16 @@ documentation and marking the package as installed." ;; Generate package file (package-vc--generate-description-file pkg-desc pkg-file) + ;; Process :make and :shell-command arguments before building documentation + (pcase package-vc-process-make + ((pred consp) ; When non-`nil' list, check if package is on the list. + (when (memq (package-desc-name pkg-desc) package-vc-process-make) + (package-vc--make pkg-spec pkg-desc))) + ('nil ; When `nil', do nothing. + nil) + (_ ; When otherwise non-`nil', run commands. + (package-vc--make pkg-spec pkg-desc))) + ;; Detect a manual (when (executable-find "install-info") (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) -- 2.40.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun May 14 03:44:27 2023 Received: (at 63336) by debbugs.gnu.org; 14 May 2023 07:44:27 +0000 Received: from localhost ([127.0.0.1]:40232 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1py6P5-0007De-1A for submit@debbugs.gnu.org; Sun, 14 May 2023 03:44:27 -0400 Received: from mout02.posteo.de ([185.67.36.66]:34769) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1py6P2-0007DJ-2q for 63336@debbugs.gnu.org; Sun, 14 May 2023 03:44:26 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B1B2524010B for <63336@debbugs.gnu.org>; Sun, 14 May 2023 09:44:17 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1684050257; bh=XpWW9/XMzpk18TAROaUvaUemmr8Am0Q2Eax9CEYSImE=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=frU6zbzMkaxJFi1SsURQUTDZI1/K8Z7GMFJ0hFpGb+S5x2DOQ3MJishWHKsfs1206 14BD0eiseNTow1Q0xa3WgAUN9ivdVW+tEa776zyu5NyJmXBjTTqQpac0UoRAIf0RgI 31Tk0kak+lHolLqjOXnqv2FsqL7xKERphMTCjLgNIYbCndAk3civZ6q0O2DkSEphcb mqfOlhr8ciPzzURuDDt2ZBHl7xgPElmDsoXxBgWwIQWCPaysqq+pB8pPU1J2SNWuvm DgyIfJZTA3mgSmY5nb9AOK5GYsQb7SXs8rcQm7jAVyhsNzqqt3EzaWKuooUZzoaHQq 3P44TcTNMRN1w== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QJvds1qwyz6tv5; Sun, 14 May 2023 09:44:17 +0200 (CEST) From: Philip Kaludercic To: Joseph Turner Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args In-Reply-To: <873540rqkm.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Wed, 10 May 2023 18:37:15 -0700") References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> <873540rqkm.fsf@breatheoutbreathe.in> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Sun, 14 May 2023 07:44:16 +0000 Message-ID: <87ilcvichb.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Joseph Turner writes: > Philip Kaludercic writes: > >> Joseph Turner writes: >> >>>>> +(defun package-vc--make (pkg-spec dir) >>>>> + "Process :make and :shell-command spec arguments." >>>>> + (let ((target (plist-get pkg-spec :make)) >>>>> + (cmd (plist-get pkg-spec :shell-command))) >>>>> + (when (or cmd target) >>>>> + (with-current-buffer (get-buffer-create " *package-vc make*") >>>> ^ >>>> should the package name >>>> be mentioned here? >>> >>> I like this idea, but IIUC package-vc--make would then need to take an >>> extra arg, since pkg-spec doesn't contain the :name of the package. We >>> could also add :name to the pkg-spec plist? >> >> I wouldn't be in favour of that, I think that passing the name as a >> separate argument would be a better solution. > > I agree. > >>> For comparison, package-vc--build-documentation creates a buffer called >>> " *package-vc doc*" without the package name. >> >> The difference I see here is that documentation usually builds fine, >> while :make or :shell-command have a higher chance of failing because >> some software is missing, especially if people don't use :make the way >> it is used on the ELPA server but to build external dependencies (I'm >> thinking of mail clients like notmuch) > > That makes sense to me. In the attached patch, I pass pkg-desc to > package-vc--make instead just name. > > Want me to submit a separate patch which adds the package name to the > " *package-vc doc*" buffer name? No, I don't think it is necessary. But thanks. >>>>> + target (buffer-name))))))) >>>>> + >>>>> (declare-function org-export-to-file "ox" (backend file)) >>>>> >>>>> (defun package-vc--build-documentation (pkg-desc file) >>>>> @@ -486,6 +515,9 @@ documentation and marking the package as installed." >>>>> ;; Generate package file >>>>> (package-vc--generate-description-file pkg-desc pkg-file) >>>>> >>>>> + ;; Process :make and :shell-command arguments before building documentation >>>>> + (when package-vc-process-make (package-vc--make pkg-spec pkg-dir)) >>>> >>>> Wasn't the plan to allow `package-vc-process-make' to either be a >>>> generic "build-anything" or a selective listing of packages where we >>>> allow :make and :shell-command to be executed? >>> >>> Let me know if the attached commit accomplishes what you had in mind. >> >> Yes, that (or rather the newest version from a different message) looks good. >> >>>>> + >>>>> ;; Detect a manual >>>>> (when (executable-find "install-info") >>>>> (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) >>>> >>>> Otherwise this looks good, but I haven't tried it out yet. >>> >>> I fixed up a couple other issues: >>> >>> - removed unnecessary dir arg to package-vc--make >>> - added function arg to the docstring for package-vc--make >>> >>> I'm not sure if the customization type for package-vc-process-make is >>> correct. Please double check that. >>> >>> Also, should users be able to run :make and :shell-command args defined >>> in a spec passed into package-vc-install? >> >> Yes, is that currently not supported? > > Nevermind! It is supported. I didn't notice that package-vc--unpack adds > the user-defined pkg-spec to package-vc-selected-packages just before > calling package-vc--unpack-1. 1+ > Best, > > Joseph > > From b27724197acd4ee72f9d336843f0e6ed9fcee87b Mon Sep 17 00:00:00 2001 > From: Joseph Turner > Date: Sat, 13 May 2023 10:05:04 -0700 > Subject: [PATCH] package-vc: Process :make and :shell-command spec args > > --- > lisp/emacs-lisp/package-vc.el | 37 +++++++++++++++++++++++++++++++++++ > 1 file changed, 37 insertions(+) > > diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el > index beca0bd00e2..8529d1dad5c 100644 > --- a/lisp/emacs-lisp/package-vc.el > +++ b/lisp/emacs-lisp/package-vc.el > @@ -344,6 +344,33 @@ asynchronously." > "\n") > nil pkg-file nil 'silent)))) > > +(defcustom package-vc-process-make nil Have we discussed the name of this user option? I feel it is too immediate, and therefore not intuitively obvious what purpose it serves. I would imagine something along the lines of "package-vc-allow-side-effects" or "package-vc-permit-building" could be better? WDYT? > + "Whether to process :make and :shell-command spec arguments. I guess here too an explanation would be warranted (and in the manual). Explaining what the issue is, and why one might be wary to enable the option. > +When set to a list of symbols (packages), run commands for only > +packages in the list. When `nil', never run commands. Otherwise > +when non-`nil', run commands for any package with :make or > +:shell-command specified. > + > +Package specs are loaded from trusted package archives." > + :type '(choice (const :tag "Run for all packages" t) > + (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) > + (const :tag "Never run" nil)) > + :version "30.1") > + > +(defun package-vc--make (pkg-spec pkg-desc) > + "Process :make and :shell-command PKG-SPEC arguments for PKG-DESC." > + (let ((target (plist-get pkg-spec :make)) > + (cmd (plist-get pkg-spec :shell-command))) > + (when (or cmd target) > + (with-current-buffer (get-buffer-create I'd format the buffer name in the top let to prevent this line-break here. > + (format " *package-vc make %s*" (package-desc-name pkg-desc))) > + (erase-buffer) > + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) > + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) > + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) > + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) If :shell-command fails, do we really want to proceed to :make? > (declare-function org-export-to-file "ox" (backend file)) > > (defun package-vc--build-documentation (pkg-desc file) > @@ -486,6 +513,16 @@ documentation and marking the package as installed." > ;; Generate package file > (package-vc--generate-description-file pkg-desc pkg-file) > > + ;; Process :make and :shell-command arguments before building documentation > + (pcase package-vc-process-make > + ((pred consp) ; When non-`nil' list, check if package is on the list. > + (when (memq (package-desc-name pkg-desc) package-vc-process-make) > + (package-vc--make pkg-spec pkg-desc))) > + ('nil ; When `nil', do nothing. > + nil) Perhaps swap the two conditions, first checking nil then listp which I think reads more natural. Then again, is pcase actually serving anything here? > + (_ ; When otherwise non-`nil', run commands. > + (package-vc--make pkg-spec pkg-desc))) > + > ;; Detect a manual > (when (executable-find "install-info") > (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) From debbugs-submit-bounces@debbugs.gnu.org Sun May 14 04:39:40 2023 Received: (at 63336) by debbugs.gnu.org; 14 May 2023 08:39:40 +0000 Received: from localhost ([127.0.0.1]:40271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1py7GV-0000Oo-Lo for submit@debbugs.gnu.org; Sun, 14 May 2023 04:39:40 -0400 Received: from out-37.mta0.migadu.com ([91.218.175.37]:30319) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1py7GS-0000Oe-Fu for 63336@debbugs.gnu.org; Sun, 14 May 2023 04:39:38 -0400 References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> <873540rqkm.fsf@breatheoutbreathe.in> <87ilcvichb.fsf@posteo.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1684053574; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=MFMg82/aSxEpmnbBOjPAp8+wLCFZXaJUaQr+35FzTGE=; b=Dej9W7Z8k916qO8WA7trraTsQ+0yuynCwWue1ewotXuOGZ+wANJU0XJa2r3+LP4SCtsDGj NW/3yN3MzLi/uMxeECY6sj36VAZEVa0NG5m5UFN2pwIhhHDuLMMY9Dfx76gmBc7Ovs23e1 dfa5gC8rann5n0ZXypsCVnjVZ7Rl544= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Philip Kaludercic Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args Date: Sun, 14 May 2023 01:08:29 -0700 In-reply-to: <87ilcvichb.fsf@posteo.net> Message-ID: <87cz33parh.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Philip Kaludercic writes: > Joseph Turner writes: > >> Philip Kaludercic writes: >> >>> Joseph Turner writes: >> From b27724197acd4ee72f9d336843f0e6ed9fcee87b Mon Sep 17 00:00:00 2001 >> From: Joseph Turner >> Date: Sat, 13 May 2023 10:05:04 -0700 >> Subject: [PATCH] package-vc: Process :make and :shell-command spec args >> >> --- >> lisp/emacs-lisp/package-vc.el | 37 +++++++++++++++++++++++++++++++++++ >> 1 file changed, 37 insertions(+) >> >> diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el >> index beca0bd00e2..8529d1dad5c 100644 >> --- a/lisp/emacs-lisp/package-vc.el >> +++ b/lisp/emacs-lisp/package-vc.el >> @@ -344,6 +344,33 @@ asynchronously." >> "\n") >> nil pkg-file nil 'silent)))) >> >> +(defcustom package-vc-process-make nil > > Have we discussed the name of this user option? I feel it is too > immediate, and therefore not intuitively obvious what purpose it serves. > I would imagine something along the lines of > "package-vc-allow-side-effects" or "package-vc-permit-building" could be > better? WDYT? I like "package-vc-allow-side-effects". Changed in attached patch. >> + "Whether to process :make and :shell-command spec arguments. > > I guess here too an explanation would be warranted (and in the manual). > Explaining what the issue is, and why one might be wary to enable the option. Does my addition suffice? We also might want to add another option for package-vc-allow-side-effects like 'user-defined, which only runs :make and :shell-command args which were specified by the user (as opposed to those which were downloaded from elpa). WDYT? To update the manual, shall I edit doc/emacs/package.texi directly or is there another file to edit? >> +When set to a list of symbols (packages), run commands for only >> +packages in the list. When `nil', never run commands. Otherwise >> +when non-`nil', run commands for any package with :make or >> +:shell-command specified. >> + >> +Package specs are loaded from trusted package archives." >> + :type '(choice (const :tag "Run for all packages" t) >> + (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) >> + (const :tag "Never run" nil)) >> + :version "30.1") >> + >> +(defun package-vc--make (pkg-spec pkg-desc) >> + "Process :make and :shell-command PKG-SPEC arguments for PKG-DESC." >> + (let ((target (plist-get pkg-spec :make)) >> + (cmd (plist-get pkg-spec :shell-command))) >> + (when (or cmd target) >> + (with-current-buffer (get-buffer-create > > I'd format the buffer name in the top let to prevent this line-break here. Done. >> + (format " *package-vc make %s*" (package-desc-name pkg-desc))) >> + (erase-buffer) >> + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) >> + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) >> + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) >> + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) > > If :shell-command fails, do we really want to proceed to :make? Up to you! I was following the lead of elpa-admin.el. >> (declare-function org-export-to-file "ox" (backend file)) >> >> (defun package-vc--build-documentation (pkg-desc file) >> @@ -486,6 +513,16 @@ documentation and marking the package as installed." >> ;; Generate package file >> (package-vc--generate-description-file pkg-desc pkg-file) >> >> + ;; Process :make and :shell-command arguments before building documentation >> + (pcase package-vc-process-make >> + ((pred consp) ; When non-`nil' list, check if package is on the list. >> + (when (memq (package-desc-name pkg-desc) package-vc-process-make) >> + (package-vc--make pkg-spec pkg-desc))) >> + ('nil ; When `nil', do nothing. >> + nil) > > Perhaps swap the two conditions, first checking nil then listp which I > think reads more natural. Then again, is pcase actually serving > anything here? I switched the first two cases. I think pcase is readable here, especially if we add an 'user-defined option. What would you use instead? >> + (_ ; When otherwise non-`nil', run commands. >> + (package-vc--make pkg-spec pkg-desc))) >> + >> ;; Detect a manual >> (when (executable-find "install-info") >> (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-package-vc-Process-make-and-shell-command-spec-args.patch >From 3e7084e8e3e3ba142f383e90bfa656f59f3cc1ad Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 13 May 2023 10:05:04 -0700 Subject: [PATCH] package-vc: Process :make and :shell-command spec args --- lisp/emacs-lisp/package-vc.el | 40 +++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index beca0bd00e2..8403add364c 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -344,6 +344,36 @@ asynchronously." "\n") nil pkg-file nil 'silent)))) +(defcustom package-vc-allow-side-effects nil + "Whether to process :make and :shell-command spec arguments. + +Be careful when changing this option as processing :make and +:shell-command will run potentially harmful code. + +When set to a list of symbols (packages), run commands for only +packages in the list. When `nil', never run commands. Otherwise +when non-`nil', run commands for any package with :make or +:shell-command specified. + +Package specs are loaded from trusted package archives." + :type '(choice (const :tag "Run for all packages" t) + (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) + (const :tag "Never run" nil)) + :version "30.1") + +(defun package-vc--make (pkg-spec pkg-desc) + "Process :make and :shell-command PKG-SPEC arguments for PKG-DESC." + (let ((target (plist-get pkg-spec :make)) + (cmd (plist-get pkg-spec :shell-command)) + (buf (format " *package-vc make %s*" (package-desc-name pkg-desc)))) + (when (or cmd target) + (with-current-buffer (get-buffer-create buf) + (erase-buffer) + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) + (declare-function org-export-to-file "ox" (backend file)) (defun package-vc--build-documentation (pkg-desc file) @@ -486,6 +516,16 @@ documentation and marking the package as installed." ;; Generate package file (package-vc--generate-description-file pkg-desc pkg-file) + ;; Process :make and :shell-command arguments before building documentation + (pcase package-vc-allow-side-effects + ('nil ; When `nil', do nothing. + nil) + ((pred consp) ; When non-`nil' list, check if package is on the list. + (when (memq (package-desc-name pkg-desc) package-vc-allow-side-effects) + (package-vc--make pkg-spec pkg-desc))) + (_ ; When otherwise non-`nil', run commands. + (package-vc--make pkg-spec pkg-desc))) + ;; Detect a manual (when (executable-find "install-info") (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) -- 2.40.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Sun May 14 15:30:33 2023 Received: (at 63336) by debbugs.gnu.org; 14 May 2023 19:30:33 +0000 Received: from localhost ([127.0.0.1]:41604 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyHQO-0004tY-LN for submit@debbugs.gnu.org; Sun, 14 May 2023 15:30:33 -0400 Received: from mout01.posteo.de ([185.67.36.65]:55551) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyHQM-0004tH-DQ for 63336@debbugs.gnu.org; Sun, 14 May 2023 15:30:31 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id 78BCC240033 for <63336@debbugs.gnu.org>; Sun, 14 May 2023 21:30:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1684092624; bh=hXhQKjK0PEYXSwg+7GbH2uYuIAflyIjk9hksVc0YWWI=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=gWGrvw9lO/eQxkuen1VuPV73FTTEm5Eb4A8hnIvcal9Mb66qFYLU3wnS6Sf3zaDjV 1djNE0Fc0bIeFHSqWU3LrxVSjNhuTbQB2/btEW5aEbiWnT5cG1+Wit7ewyOXfPL+Ky hKgi2Cf8O1r1J8+7HT0m9HR9CzW/yWsxsWNMYLbCGF4xi5s2uDW7f/ZfQOAG//ortD 2ab2qtJwRbMwot4D+VhmNkNNxYLu2wiXify9rxoXkzua8zWBXFz6sTiotHOS7v+XGn EB6fUuxhftWavZ0ZFQPmC2zZIbYHYHs8QOZ39Y0nJPycMMBjy2pbBSrnc+MnrA+12P 7NKwzLtHL8BAA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QKCJc0JYVz6twF; Sun, 14 May 2023 21:30:23 +0200 (CEST) From: Philip Kaludercic To: Joseph Turner Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args In-Reply-To: <87cz33parh.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Sun, 14 May 2023 01:08:29 -0700") References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> <873540rqkm.fsf@breatheoutbreathe.in> <87ilcvichb.fsf@posteo.net> <87cz33parh.fsf@breatheoutbreathe.in> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Sun, 14 May 2023 19:30:23 +0000 Message-ID: <871qjiiucw.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Joseph Turner writes: > Philip Kaludercic writes: > >> Joseph Turner writes: >> >>> Philip Kaludercic writes: >>> >>>> Joseph Turner writes: >>> From b27724197acd4ee72f9d336843f0e6ed9fcee87b Mon Sep 17 00:00:00 2001 >>> From: Joseph Turner >>> Date: Sat, 13 May 2023 10:05:04 -0700 >>> Subject: [PATCH] package-vc: Process :make and :shell-command spec args >>> >>> --- >>> lisp/emacs-lisp/package-vc.el | 37 +++++++++++++++++++++++++++++++++++ >>> 1 file changed, 37 insertions(+) >>> >>> diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el >>> index beca0bd00e2..8529d1dad5c 100644 >>> --- a/lisp/emacs-lisp/package-vc.el >>> +++ b/lisp/emacs-lisp/package-vc.el >>> @@ -344,6 +344,33 @@ asynchronously." >>> "\n") >>> nil pkg-file nil 'silent)))) >>> >>> +(defcustom package-vc-process-make nil >> >> Have we discussed the name of this user option? I feel it is too >> immediate, and therefore not intuitively obvious what purpose it serves. >> I would imagine something along the lines of >> "package-vc-allow-side-effects" or "package-vc-permit-building" could be >> better? WDYT? > > I like "package-vc-allow-side-effects". Changed in attached patch. > >>> + "Whether to process :make and :shell-command spec arguments. >> >> I guess here too an explanation would be warranted (and in the manual). >> Explaining what the issue is, and why one might be wary to enable the option. > > Does my addition suffice? > > We also might want to add another option for > package-vc-allow-side-effects like 'user-defined, which only runs :make > and :shell-command args which were specified by the user (as opposed to > those which were downloaded from elpa). WDYT? That sounds like a good idea, but let us do that in a separate patch. > To update the manual, shall I edit doc/emacs/package.texi directly or is > there another file to edit? Yes, just update the table under the "Specifying Package Sources" subsection. >>> +When set to a list of symbols (packages), run commands for only >>> +packages in the list. When `nil', never run commands. Otherwise >>> +when non-`nil', run commands for any package with :make or >>> +:shell-command specified. >>> + >>> +Package specs are loaded from trusted package archives." >>> + :type '(choice (const :tag "Run for all packages" t) >>> + (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) >>> + (const :tag "Never run" nil)) >>> + :version "30.1") >>> + >>> +(defun package-vc--make (pkg-spec pkg-desc) >>> + "Process :make and :shell-command PKG-SPEC arguments for PKG-DESC." >>> + (let ((target (plist-get pkg-spec :make)) >>> + (cmd (plist-get pkg-spec :shell-command))) >>> + (when (or cmd target) >>> + (with-current-buffer (get-buffer-create >> >> I'd format the buffer name in the top let to prevent this line-break here. > > Done. > >>> + (format " *package-vc make %s*" (package-desc-name pkg-desc))) >>> + (erase-buffer) >>> + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) >>> + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) >>> + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) >>> + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) >> >> If :shell-command fails, do we really want to proceed to :make? > > Up to you! I was following the lead of elpa-admin.el. In that case let us do that too, unless there is a good reason not to. >>> (declare-function org-export-to-file "ox" (backend file)) >>> >>> (defun package-vc--build-documentation (pkg-desc file) >>> @@ -486,6 +513,16 @@ documentation and marking the package as installed." >>> ;; Generate package file >>> (package-vc--generate-description-file pkg-desc pkg-file) >>> >>> + ;; Process :make and :shell-command arguments before building documentation >>> + (pcase package-vc-process-make >>> + ((pred consp) ; When non-`nil' list, check if package is on the list. >>> + (when (memq (package-desc-name pkg-desc) package-vc-process-make) >>> + (package-vc--make pkg-spec pkg-desc))) >>> + ('nil ; When `nil', do nothing. >>> + nil) >> >> Perhaps swap the two conditions, first checking nil then listp which I >> think reads more natural. Then again, is pcase actually serving >> anything here? > > I switched the first two cases. I think pcase is readable here, > especially if we add an 'user-defined option. What would you use > instead? I would have just used a regular cond. --8<---------------cut here---------------start------------->8--- (cond ((null package-vc-process-make) ...) ((listp package-vc-process-make) ...) (...)) --8<---------------cut here---------------end--------------->8--- But this doesn't matter, do what you prefer. >>> + (_ ; When otherwise non-`nil', run commands. >>> + (package-vc--make pkg-spec pkg-desc))) >>> + >>> ;; Detect a manual >>> (when (executable-find "install-info") >>> (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) > > From 3e7084e8e3e3ba142f383e90bfa656f59f3cc1ad Mon Sep 17 00:00:00 2001 > From: Joseph Turner > Date: Sat, 13 May 2023 10:05:04 -0700 > Subject: [PATCH] package-vc: Process :make and :shell-command spec args > > --- > lisp/emacs-lisp/package-vc.el | 40 +++++++++++++++++++++++++++++++++++ > 1 file changed, 40 insertions(+) > > diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el > index beca0bd00e2..8403add364c 100644 > --- a/lisp/emacs-lisp/package-vc.el > +++ b/lisp/emacs-lisp/package-vc.el > @@ -344,6 +344,36 @@ asynchronously." > "\n") > nil pkg-file nil 'silent)))) > > +(defcustom package-vc-allow-side-effects nil > + "Whether to process :make and :shell-command spec arguments. > + > +Be careful when changing this option as processing :make and > +:shell-command will run potentially harmful code. Sounds scary. I guess that is the point, but what do you think about something like Be careful when changing this option, as installing and updating a package can potentially run harmful code. If possible, allow packages you trust to run code, if it is necessary for a package to be properly initialised. > + > +When set to a list of symbols (packages), run commands for only > +packages in the list. When `nil', never run commands. Otherwise > +when non-`nil', run commands for any package with :make or > +:shell-command specified. Watch out. According to (elisp) Documentation Tips, nil is not quoted. > + > +Package specs are loaded from trusted package archives." > + :type '(choice (const :tag "Run for all packages" t) > + (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) > + (const :tag "Never run" nil)) > + :version "30.1") > + > +(defun package-vc--make (pkg-spec pkg-desc) > + "Process :make and :shell-command PKG-SPEC arguments for PKG-DESC." > + (let ((target (plist-get pkg-spec :make)) > + (cmd (plist-get pkg-spec :shell-command)) > + (buf (format " *package-vc make %s*" (package-desc-name pkg-desc)))) > + (when (or cmd target) > + (with-current-buffer (get-buffer-create buf) > + (erase-buffer) > + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) > + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) > + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) > + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) > + > (declare-function org-export-to-file "ox" (backend file)) > > (defun package-vc--build-documentation (pkg-desc file) > @@ -486,6 +516,16 @@ documentation and marking the package as installed." > ;; Generate package file > (package-vc--generate-description-file pkg-desc pkg-file) > > + ;; Process :make and :shell-command arguments before building documentation > + (pcase package-vc-allow-side-effects > + ('nil ; When `nil', do nothing. > + nil) > + ((pred consp) ; When non-`nil' list, check if package is on the list. > + (when (memq (package-desc-name pkg-desc) package-vc-allow-side-effects) > + (package-vc--make pkg-spec pkg-desc))) > + (_ ; When otherwise non-`nil', run commands. > + (package-vc--make pkg-spec pkg-desc))) > + > ;; Detect a manual > (when (executable-find "install-info") > (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) From debbugs-submit-bounces@debbugs.gnu.org Sun May 14 19:58:16 2023 Received: (at 63336) by debbugs.gnu.org; 14 May 2023 23:58:16 +0000 Received: from localhost ([127.0.0.1]:42325 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyLbT-0006p6-Sl for submit@debbugs.gnu.org; Sun, 14 May 2023 19:58:16 -0400 Received: from out-31.mta1.migadu.com ([95.215.58.31]:12694) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyLbR-0006ou-9H for 63336@debbugs.gnu.org; Sun, 14 May 2023 19:58:14 -0400 References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> <873540rqkm.fsf@breatheoutbreathe.in> <87ilcvichb.fsf@posteo.net> <87cz33parh.fsf@breatheoutbreathe.in> <871qjiiucw.fsf@posteo.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1684108691; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=tc9UvzoXBcWZ1ZgofWBn4u1hW78w5CYbjVIKXNEDcSo=; b=dNEon+kUED9B3Q5qLLU4DDK/wFEVXOD8ALzyjV1JMgy9ZmpOfAL6Xda5A3r9K6gqJ6BfUq MTUYG9HD7GSQL3La79oaeWbr4nTTeRzvajbWFRRoLh22fFeG0i1aCuVqZ8xJ/NYBhRWTMC 6fsh7Y92o+5WHlVYIu5Hlmf1rcCg+go= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Philip Kaludercic Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args Date: Sun, 14 May 2023 16:01:10 -0700 In-reply-to: <871qjiiucw.fsf@posteo.net> Message-ID: <87jzxafotr.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) --=-=-= Content-Type: text/plain Philip Kaludercic writes: > Joseph Turner writes: > >> Philip Kaludercic writes: >> >>> Joseph Turner writes: >>> >>>> Philip Kaludercic writes: >>>> >>>>> Joseph Turner writes: >> We also might want to add another option for >> package-vc-allow-side-effects like 'user-defined, which only runs :make >> and :shell-command args which were specified by the user (as opposed to >> those which were downloaded from elpa). WDYT? > > That sounds like a good idea, but let us do that in a separate patch. Okay! >> To update the manual, shall I edit doc/emacs/package.texi directly or is >> there another file to edit? > > Yes, just update the table under the "Specifying Package Sources" subsection. See patch. >>> If :shell-command fails, do we really want to proceed to :make? >> >> Up to you! I was following the lead of elpa-admin.el. > > In that case let us do that too, unless there is a good reason not to. +1 >> I switched the first two cases. I think pcase is readable here, >> especially if we add an 'user-defined option. What would you use >> instead? > > I would have just used a regular cond. > > --8<---------------cut here---------------start------------->8--- > (cond > ((null package-vc-process-make) > ...) > ((listp package-vc-process-make) > ...) > (...)) > --8<---------------cut here---------------end--------------->8--- > > But this doesn't matter, do what you prefer. Thank you! I like pcase here. >> +Be careful when changing this option as processing :make and >> +:shell-command will run potentially harmful code. > > Sounds scary. I guess that is the point, but what do you think about > something like > > Be careful when changing this option, as installing and updating a > package can potentially run harmful code. If possible, allow packages > you trust to run code, if it is necessary for a package to be properly > initialised. Thank you! What do you think about the version in the attached patch? >> +When set to a list of symbols (packages), run commands for only >> +packages in the list. When `nil', never run commands. Otherwise >> +when non-`nil', run commands for any package with :make or >> +:shell-command specified. > > Watch out. According to (elisp) Documentation Tips, nil is not quoted. Good to know! Fixed. --=-=-= Content-Type: text/x-diff Content-Disposition: attachment; filename=0001-package-vc-Process-make-and-shell-command-spec-args.patch >From 812e32ea6c3f7b2d71174658db0e272b0b4fb84b Mon Sep 17 00:00:00 2001 From: Joseph Turner Date: Sat, 13 May 2023 10:05:04 -0700 Subject: [PATCH] package-vc: Process :make and :shell-command spec args --- doc/emacs/package.texi | 9 ++++++++ lisp/emacs-lisp/package-vc.el | 42 +++++++++++++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi index 6722185cb20..4f606b22e54 100644 --- a/doc/emacs/package.texi +++ b/doc/emacs/package.texi @@ -682,6 +682,15 @@ A string providing the repository-relative name of the documentation file from which to build an Info file. This can be a Texinfo file or an Org file. +@item :make +A string or list of strings providing the target or targets defined in +the repository Makefile which should run before building the Info +file. Only takes effect when package-vc-allow-side-effects is non-nil. + +@item :shell-command +A string providing the shell command to run before building the Info +file. Only takes effect when package-vc-allow-side-effects is non-nil. + @item :vc-backend A symbol naming the VC backend to use for downloading a copy of the package's repository (@pxref{Version Control Systems,,,emacs, The GNU diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index beca0bd00e2..d2f6d287224 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -344,6 +344,38 @@ asynchronously." "\n") nil pkg-file nil 'silent)))) +(defcustom package-vc-allow-side-effects nil + "Whether to process :make and :shell-command spec arguments. + +It may be necessary to run :make and :shell-command arguments in +order to initialize a package or build its documentation, but +please be careful when changing this option, as installing and +updating a package can run potentially harmful code. + +When set to a list of symbols (packages), run commands for only +packages in the list. When nil, never run commands. Otherwise +when non-nil, run commands for any package with :make or +:shell-command specified. + +Package specs are loaded from trusted package archives." + :type '(choice (const :tag "Run for all packages" t) + (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) + (const :tag "Never run" nil)) + :version "30.1") + +(defun package-vc--make (pkg-spec pkg-desc) + "Process :make and :shell-command PKG-SPEC arguments for PKG-DESC." + (let ((target (plist-get pkg-spec :make)) + (cmd (plist-get pkg-spec :shell-command)) + (buf (format " *package-vc make %s*" (package-desc-name pkg-desc)))) + (when (or cmd target) + (with-current-buffer (get-buffer-create buf) + (erase-buffer) + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) + (declare-function org-export-to-file "ox" (backend file)) (defun package-vc--build-documentation (pkg-desc file) @@ -486,6 +518,16 @@ documentation and marking the package as installed." ;; Generate package file (package-vc--generate-description-file pkg-desc pkg-file) + ;; Process :make and :shell-command arguments before building documentation + (pcase package-vc-allow-side-effects + ('nil ; When `nil', do nothing. + nil) + ((pred consp) ; When non-`nil' list, check if package is on the list. + (when (memq (package-desc-name pkg-desc) package-vc-allow-side-effects) + (package-vc--make pkg-spec pkg-desc))) + (_ ; When otherwise non-`nil', run commands. + (package-vc--make pkg-spec pkg-desc))) + ;; Detect a manual (when (executable-find "install-info") (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) -- 2.40.1 --=-=-=-- From debbugs-submit-bounces@debbugs.gnu.org Mon May 15 05:12:38 2023 Received: (at 63336) by debbugs.gnu.org; 15 May 2023 09:12:39 +0000 Received: from localhost ([127.0.0.1]:42749 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyUFy-00060E-9Q for submit@debbugs.gnu.org; Mon, 15 May 2023 05:12:38 -0400 Received: from mout02.posteo.de ([185.67.36.66]:49729) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pyUFv-0005zw-5w for 63336@debbugs.gnu.org; Mon, 15 May 2023 05:12:36 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 57139240104 for <63336@debbugs.gnu.org>; Mon, 15 May 2023 11:12:28 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1684141948; bh=Y9kGgvJlz63ZvPdwEOhzG0oMnZLecENgT1e7q3+zQ6Q=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=QYJNDmAMtKSX7M1ubRZ54GvGfx4LsIxPZlbTJuCCUoqHCUhJZT0BfD4IimdddD3k/ ox5uhqhm5reIlGzMxZBt5wpoKNHz7PNRiEmKii4S4cJLnTx60jPzgQGUQyddFIweCZ 2tuKVvJteeGncq6QSz3oskOdp51xB4cN1VUUL+iAlrba1EctaxxtPRF0O88frOO4XB AliXIP+DBiX4OK0tJCPFtGxWPDNKPnWj+6WJEnpRqN75HVGZLL/aepXzByjciiejik bVFT3EISVmmvXfJptd/AbRlrceUX/S9tFhNkQZXx3fy4r3J5AP0UfpwUtI4DJv9k17 9/f2IILsJQFDA== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QKYY74XZ8z6tvZ; Mon, 15 May 2023 11:12:27 +0200 (CEST) From: Philip Kaludercic To: Joseph Turner Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args In-Reply-To: <87jzxafotr.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Sun, 14 May 2023 16:01:10 -0700") References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> <873540rqkm.fsf@breatheoutbreathe.in> <87ilcvichb.fsf@posteo.net> <87cz33parh.fsf@breatheoutbreathe.in> <871qjiiucw.fsf@posteo.net> <87jzxafotr.fsf@breatheoutbreathe.in> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Mon, 15 May 2023 09:12:26 +0000 Message-ID: <87sfbynekl.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Joseph Turner writes: > Philip Kaludercic writes: > >> Joseph Turner writes: >> >>> Philip Kaludercic writes: >>> >>>> Joseph Turner writes: >>>> >>>>> Philip Kaludercic writes: >>>>> >>>>>> Joseph Turner writes: > >>> We also might want to add another option for >>> package-vc-allow-side-effects like 'user-defined, which only runs :make >>> and :shell-command args which were specified by the user (as opposed to >>> those which were downloaded from elpa). WDYT? >> >> That sounds like a good idea, but let us do that in a separate patch. > > Okay! > >>> To update the manual, shall I edit doc/emacs/package.texi directly or is >>> there another file to edit? >> >> Yes, just update the table under the "Specifying Package Sources" subsection. > > See patch. > >>>> If :shell-command fails, do we really want to proceed to :make? >>> >>> Up to you! I was following the lead of elpa-admin.el. >> >> In that case let us do that too, unless there is a good reason not to. > > +1 > >>> I switched the first two cases. I think pcase is readable here, >>> especially if we add an 'user-defined option. What would you use >>> instead? >> >> I would have just used a regular cond. >> >> --8<---------------cut here---------------start------------->8--- >> (cond >> ((null package-vc-process-make) >> ...) >> ((listp package-vc-process-make) >> ...) >> (...)) >> --8<---------------cut here---------------end--------------->8--- >> >> But this doesn't matter, do what you prefer. > > Thank you! I like pcase here. > >>> +Be careful when changing this option as processing :make and >>> +:shell-command will run potentially harmful code. >> >> Sounds scary. I guess that is the point, but what do you think about >> something like >> >> Be careful when changing this option, as installing and updating a >> package can potentially run harmful code. If possible, allow packages >> you trust to run code, if it is necessary for a package to be properly >> initialised. > > Thank you! What do you think about the version in the attached patch? > >>> +When set to a list of symbols (packages), run commands for only >>> +packages in the list. When `nil', never run commands. Otherwise >>> +when non-`nil', run commands for any package with :make or >>> +:shell-command specified. >> >> Watch out. According to (elisp) Documentation Tips, nil is not quoted. > > Good to know! Fixed. > > From 812e32ea6c3f7b2d71174658db0e272b0b4fb84b Mon Sep 17 00:00:00 2001 > From: Joseph Turner > Date: Sat, 13 May 2023 10:05:04 -0700 > Subject: [PATCH] package-vc: Process :make and :shell-command spec args > > --- > doc/emacs/package.texi | 9 ++++++++ > lisp/emacs-lisp/package-vc.el | 42 +++++++++++++++++++++++++++++++++++ > 2 files changed, 51 insertions(+) > > diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi > index 6722185cb20..4f606b22e54 100644 > --- a/doc/emacs/package.texi > +++ b/doc/emacs/package.texi > @@ -682,6 +682,15 @@ A string providing the repository-relative name of the documentation > file from which to build an Info file. This can be a Texinfo file or > an Org file. > > +@item :make > +A string or list of strings providing the target or targets defined in > +the repository Makefile which should run before building the Info > +file. Only takes effect when package-vc-allow-side-effects is non-nil. A @var is missing here > + > +@item :shell-command > +A string providing the shell command to run before building the Info > +file. Only takes effect when package-vc-allow-side-effects is non-nil. and here. I can take care of that. > + > @item :vc-backend > A symbol naming the VC backend to use for downloading a copy of the > package's repository (@pxref{Version Control Systems,,,emacs, The GNU > diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el > index beca0bd00e2..d2f6d287224 100644 > --- a/lisp/emacs-lisp/package-vc.el > +++ b/lisp/emacs-lisp/package-vc.el > @@ -344,6 +344,38 @@ asynchronously." > "\n") > nil pkg-file nil 'silent)))) > > +(defcustom package-vc-allow-side-effects nil > + "Whether to process :make and :shell-command spec arguments. > + > +It may be necessary to run :make and :shell-command arguments in > +order to initialize a package or build its documentation, but > +please be careful when changing this option, as installing and > +updating a package can run potentially harmful code. > + > +When set to a list of symbols (packages), run commands for only > +packages in the list. When nil, never run commands. Otherwise > +when non-nil, run commands for any package with :make or > +:shell-command specified. > + > +Package specs are loaded from trusted package archives." > + :type '(choice (const :tag "Run for all packages" t) > + (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) > + (const :tag "Never run" nil)) > + :version "30.1") > + > +(defun package-vc--make (pkg-spec pkg-desc) > + "Process :make and :shell-command PKG-SPEC arguments for PKG-DESC." > + (let ((target (plist-get pkg-spec :make)) > + (cmd (plist-get pkg-spec :shell-command)) > + (buf (format " *package-vc make %s*" (package-desc-name pkg-desc)))) > + (when (or cmd target) > + (with-current-buffer (get-buffer-create buf) > + (erase-buffer) > + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) > + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) > + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) > + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) > + > (declare-function org-export-to-file "ox" (backend file)) > > (defun package-vc--build-documentation (pkg-desc file) > @@ -486,6 +518,16 @@ documentation and marking the package as installed." > ;; Generate package file > (package-vc--generate-description-file pkg-desc pkg-file) > > + ;; Process :make and :shell-command arguments before building documentation > + (pcase package-vc-allow-side-effects > + ('nil ; When `nil', do nothing. > + nil) > + ((pred consp) ; When non-`nil' list, check if package is on the list. > + (when (memq (package-desc-name pkg-desc) package-vc-allow-side-effects) > + (package-vc--make pkg-spec pkg-desc))) > + (_ ; When otherwise non-`nil', run commands. > + (package-vc--make pkg-spec pkg-desc))) Thinking about this again, I am still not convinced. Isn't --8<---------------cut here---------------start------------->8--- (when (or (eq package-vc-allow-side-effects t) (memq (package-desc-name pkg-desc) package-vc-allow-side-effects)) (package-vc--make pkg-spec pkg-desc)) --8<---------------cut here---------------end--------------->8--- much simpler? Again, you don't have to prepare another patch, I'm just interested in what you think. > + > ;; Detect a manual > (when (executable-find "install-info") > (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) From debbugs-submit-bounces@debbugs.gnu.org Mon May 15 15:10:37 2023 Received: (at 63336) by debbugs.gnu.org; 15 May 2023 19:10:37 +0000 Received: from localhost ([127.0.0.1]:44436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pydae-0003WD-Da for submit@debbugs.gnu.org; Mon, 15 May 2023 15:10:37 -0400 Received: from out-4.mta0.migadu.com ([91.218.175.4]:50287) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pydaZ-0003W1-Ks for 63336@debbugs.gnu.org; Mon, 15 May 2023 15:10:35 -0400 References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> <873540rqkm.fsf@breatheoutbreathe.in> <87ilcvichb.fsf@posteo.net> <87cz33parh.fsf@breatheoutbreathe.in> <871qjiiucw.fsf@posteo.net> <87jzxafotr.fsf@breatheoutbreathe.in> <87sfbynekl.fsf@posteo.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1684177830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=UBU2wswkC5d4kvR12AmPPfoU6iF3yWaCN8KWoFvlD1s=; b=D3lk/iRYlvZZDB/j/W7gUdwAA2VrA58FN8QeM4H6W/iDYVGbJ+NYC/a6ZUi66csPVIyALb 9oI2zC5VMAqj9qT/unKKhqQK5KsAvfNwvjcAHwZvgwKLBSN7fr1CwnIgi62bcv8h3wpk9m hmcK2ZBA5Cghu+wouRVyhErST84SDxk= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Philip Kaludercic Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args Date: Mon, 15 May 2023 12:03:14 -0700 In-reply-to: <87sfbynekl.fsf@posteo.net> Message-ID: <87h6sdtnq4.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63336 Cc: 63336@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Philip Kaludercic writes: > Joseph Turner writes: > >> Philip Kaludercic writes: >> >>> Joseph Turner writes: >>> >>>> Philip Kaludercic writes: >>>> >>>>> Joseph Turner writes: >>>>> >>>>>> Philip Kaludercic writes: >>>>>> >>>>>>> Joseph Turner writes: >> >>>> We also might want to add another option for >>>> package-vc-allow-side-effects like 'user-defined, which only runs :make >>>> and :shell-command args which were specified by the user (as opposed to >>>> those which were downloaded from elpa). WDYT? >>> >>> That sounds like a good idea, but let us do that in a separate patch. >> >> Okay! >> >>>> To update the manual, shall I edit doc/emacs/package.texi directly or is >>>> there another file to edit? >>> >>> Yes, just update the table under the "Specifying Package Sources" subsection. >> >> See patch. >> >>>>> If :shell-command fails, do we really want to proceed to :make? >>>> >>>> Up to you! I was following the lead of elpa-admin.el. >>> >>> In that case let us do that too, unless there is a good reason not to. >> >> +1 >> >>>> I switched the first two cases. I think pcase is readable here, >>>> especially if we add an 'user-defined option. What would you use >>>> instead? >>> >>> I would have just used a regular cond. >>> >>> --8<---------------cut here---------------start------------->8--- >>> (cond >>> ((null package-vc-process-make) >>> ...) >>> ((listp package-vc-process-make) >>> ...) >>> (...)) >>> --8<---------------cut here---------------end--------------->8--- >>> >>> But this doesn't matter, do what you prefer. >> >> Thank you! I like pcase here. >> >>>> +Be careful when changing this option as processing :make and >>>> +:shell-command will run potentially harmful code. >>> >>> Sounds scary. I guess that is the point, but what do you think about >>> something like >>> >>> Be careful when changing this option, as installing and updating a >>> package can potentially run harmful code. If possible, allow packages >>> you trust to run code, if it is necessary for a package to be properly >>> initialised. >> >> Thank you! What do you think about the version in the attached patch? >> >>>> +When set to a list of symbols (packages), run commands for only >>>> +packages in the list. When `nil', never run commands. Otherwise >>>> +when non-`nil', run commands for any package with :make or >>>> +:shell-command specified. >>> >>> Watch out. According to (elisp) Documentation Tips, nil is not quoted. >> >> Good to know! Fixed. >> >> From 812e32ea6c3f7b2d71174658db0e272b0b4fb84b Mon Sep 17 00:00:00 2001 >> From: Joseph Turner >> Date: Sat, 13 May 2023 10:05:04 -0700 >> Subject: [PATCH] package-vc: Process :make and :shell-command spec args >> >> --- >> doc/emacs/package.texi | 9 ++++++++ >> lisp/emacs-lisp/package-vc.el | 42 +++++++++++++++++++++++++++++++++++ >> 2 files changed, 51 insertions(+) >> >> diff --git a/doc/emacs/package.texi b/doc/emacs/package.texi >> index 6722185cb20..4f606b22e54 100644 >> --- a/doc/emacs/package.texi >> +++ b/doc/emacs/package.texi >> @@ -682,6 +682,15 @@ A string providing the repository-relative name of the documentation >> file from which to build an Info file. This can be a Texinfo file or >> an Org file. >> >> +@item :make >> +A string or list of strings providing the target or targets defined in >> +the repository Makefile which should run before building the Info >> +file. Only takes effect when package-vc-allow-side-effects is non-nil. > > A @var is missing here Thank you! >> + >> +@item :shell-command >> +A string providing the shell command to run before building the Info >> +file. Only takes effect when package-vc-allow-side-effects is non-nil. > > and here. I can take care of that. Thank you! >> + >> @item :vc-backend >> A symbol naming the VC backend to use for downloading a copy of the >> package's repository (@pxref{Version Control Systems,,,emacs, The GNU >> diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el >> index beca0bd00e2..d2f6d287224 100644 >> --- a/lisp/emacs-lisp/package-vc.el >> +++ b/lisp/emacs-lisp/package-vc.el >> @@ -344,6 +344,38 @@ asynchronously." >> "\n") >> nil pkg-file nil 'silent)))) >> >> +(defcustom package-vc-allow-side-effects nil >> + "Whether to process :make and :shell-command spec arguments. >> + >> +It may be necessary to run :make and :shell-command arguments in >> +order to initialize a package or build its documentation, but >> +please be careful when changing this option, as installing and >> +updating a package can run potentially harmful code. >> + >> +When set to a list of symbols (packages), run commands for only >> +packages in the list. When nil, never run commands. Otherwise >> +when non-nil, run commands for any package with :make or >> +:shell-command specified. >> + >> +Package specs are loaded from trusted package archives." >> + :type '(choice (const :tag "Run for all packages" t) >> + (repeat :tag "Run only for selected packages" (symbol :tag "Package name")) >> + (const :tag "Never run" nil)) >> + :version "30.1") >> + >> +(defun package-vc--make (pkg-spec pkg-desc) >> + "Process :make and :shell-command PKG-SPEC arguments for PKG-DESC." >> + (let ((target (plist-get pkg-spec :make)) >> + (cmd (plist-get pkg-spec :shell-command)) >> + (buf (format " *package-vc make %s*" (package-desc-name pkg-desc)))) >> + (when (or cmd target) >> + (with-current-buffer (get-buffer-create buf) >> + (erase-buffer) >> + (when (and cmd (/= 0 (call-process shell-file-name nil t nil shell-command-switch cmd))) >> + (warn "Failed to run %s, see buffer %S" cmd (buffer-name))) >> + (when (and target (/= 0 (apply #'call-process "make" nil t nil (if (consp target) target (list target))))) >> + (warn "Failed to make %s, see buffer %S" target (buffer-name))))))) >> + >> (declare-function org-export-to-file "ox" (backend file)) >> >> (defun package-vc--build-documentation (pkg-desc file) >> @@ -486,6 +518,16 @@ documentation and marking the package as installed." >> ;; Generate package file >> (package-vc--generate-description-file pkg-desc pkg-file) >> >> + ;; Process :make and :shell-command arguments before building documentation >> + (pcase package-vc-allow-side-effects >> + ('nil ; When `nil', do nothing. >> + nil) >> + ((pred consp) ; When non-`nil' list, check if package is on the list. >> + (when (memq (package-desc-name pkg-desc) package-vc-allow-side-effects) >> + (package-vc--make pkg-spec pkg-desc))) >> + (_ ; When otherwise non-`nil', run commands. >> + (package-vc--make pkg-spec pkg-desc))) > > Thinking about this again, I am still not convinced. Isn't > > --8<---------------cut here---------------start------------->8--- > (when (or (eq package-vc-allow-side-effects t) > (memq (package-desc-name pkg-desc) > package-vc-allow-side-effects)) > (package-vc--make pkg-spec pkg-desc)) > --8<---------------cut here---------------end--------------->8--- > > much simpler? Again, you don't have to prepare another patch, I'm just > interested in what you think. I take it all back and insist upon the opposite :) You are right, that's much simpler. >> + >> ;; Detect a manual >> (when (executable-find "install-info") >> (dolist (doc-file (ensure-list (plist-get pkg-spec :doc))) From debbugs-submit-bounces@debbugs.gnu.org Tue May 16 15:30:02 2023 Received: (at 63336-done) by debbugs.gnu.org; 16 May 2023 19:30:02 +0000 Received: from localhost ([127.0.0.1]:48103 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pz0Mz-0005tZ-Nk for submit@debbugs.gnu.org; Tue, 16 May 2023 15:30:01 -0400 Received: from mout02.posteo.de ([185.67.36.66]:47731) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pz0Mx-0005tJ-L2 for 63336-done@debbugs.gnu.org; Tue, 16 May 2023 15:30:00 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id B615F24011A for <63336-done@debbugs.gnu.org>; Tue, 16 May 2023 21:29:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1684265393; bh=LcgAR1Xh5LKKeBGqedeTsnkuOuqHlwRptuCInHdQJWo=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=ZMdNyd7zEA8suatR6Zu9PgDhjRoEps/QN3eXLl+82VjQj8C/7YGLrlH2vc9h3VfpE 4n4KNAf/6hdGiXKNiFZh9tdCcNJ15JKi7FTtaxMfHW4ND5NvkPM+3b/C6Qy78GYdzF AfEA4VUWj9F6vZhP2bBg5J1hWdCiDC3Wx100PIT8L4dpREMKEJ9A47CnzmjUWbZhoN yYPiZcv5JiaY3qBDLiBzHufQBZq6WqZaOAru+EVzW9ozjUrvHRRj4ZMYb9+wenuBAk Evw6MVVvf8XrN2gdBKoF5PG5/wYIc3fL7H3saA9ffthBzIrtPOdbo6rYMh0mAcSO97 zUHxRUOu16ihw== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QLRC50cgtz6txf; Tue, 16 May 2023 21:29:53 +0200 (CEST) From: Philip Kaludercic To: Joseph Turner Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args In-Reply-To: <87h6sdtnq4.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Mon, 15 May 2023 12:03:14 -0700") References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> <873540rqkm.fsf@breatheoutbreathe.in> <87ilcvichb.fsf@posteo.net> <87cz33parh.fsf@breatheoutbreathe.in> <871qjiiucw.fsf@posteo.net> <87jzxafotr.fsf@breatheoutbreathe.in> <87sfbynekl.fsf@posteo.net> <87h6sdtnq4.fsf@breatheoutbreathe.in> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Tue, 16 May 2023 19:29:52 +0000 Message-ID: <874jocaxcf.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63336-done Cc: 63336-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) I've pushed the changes to master. If you are still interested in improving the granularity of the issue, create a new report when you have a patch we can discuss. From debbugs-submit-bounces@debbugs.gnu.org Tue May 16 17:10:08 2023 Received: (at 63336-done) by debbugs.gnu.org; 16 May 2023 21:10:08 +0000 Received: from localhost ([127.0.0.1]:48179 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pz1vr-0000V5-W5 for submit@debbugs.gnu.org; Tue, 16 May 2023 17:10:08 -0400 Received: from out-32.mta0.migadu.com ([91.218.175.32]:50191) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pz1vm-0000UO-Ck for 63336-done@debbugs.gnu.org; Tue, 16 May 2023 17:10:06 -0400 References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> <873540rqkm.fsf@breatheoutbreathe.in> <87ilcvichb.fsf@posteo.net> <87cz33parh.fsf@breatheoutbreathe.in> <871qjiiucw.fsf@posteo.net> <87jzxafotr.fsf@breatheoutbreathe.in> <87sfbynekl.fsf@posteo.net> <87h6sdtnq4.fsf@breatheoutbreathe.in> <874jocaxcf.fsf@posteo.net> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=breatheoutbreathe.in; s=key1; t=1684271400; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=nqrhuqxLn6uBqK4TWOEkhmpqzdMyxCKkkr1yvqIAgfY=; b=VzbjTspZcP3KMhFpJ9bPHDNXWkJsAGCcwMZrkurTSI1yP78c8yxzeIKneDFAkVkqq5woEX 9yUE07ESfotw75gI9tuAtjh3a3mOfD2cZsFAtSU92PVY+kgW31V9wsxmUhmtPVEXzpUr+s rojKx1cU1SBFGvbC2whnPE5P6G3QN6k= X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Joseph Turner To: Philip Kaludercic Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args Date: Tue, 16 May 2023 14:08:33 -0700 In-reply-to: <874jocaxcf.fsf@posteo.net> Message-ID: <87zg64rniy.fsf@breatheoutbreathe.in> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Flow: FLOW_OUT X-Spam-Score: 0.0 (/) X-Debbugs-Envelope-To: 63336-done Cc: 63336-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -1.0 (-) Philip Kaludercic writes: > I've pushed the changes to master. If you are still interested in > improving the granularity of the issue, create a new report when you > have a patch we can discuss. Thank you! I assume you're referring to something like a 'user-defined option for package-vc-allow-side-effects. At some point, I may submit another patch adding that feature! Best, Joseph From debbugs-submit-bounces@debbugs.gnu.org Wed May 17 10:07:13 2023 Received: (at 63336-done) by debbugs.gnu.org; 17 May 2023 14:07:13 +0000 Received: from localhost ([127.0.0.1]:50543 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzHo8-0002FV-TD for submit@debbugs.gnu.org; Wed, 17 May 2023 10:07:13 -0400 Received: from mout01.posteo.de ([185.67.36.65]:55057) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pzHo6-0002FE-Mj for 63336-done@debbugs.gnu.org; Wed, 17 May 2023 10:07:11 -0400 Received: from submission (posteo.de [185.67.36.169]) by mout01.posteo.de (Postfix) with ESMTPS id F178024002A for <63336-done@debbugs.gnu.org>; Wed, 17 May 2023 16:07:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1684332425; bh=TnG4HftiIUl8aXP885V4ne/Yrhkp/Jn/XYLDI3s4E1M=; h=From:To:Cc:Subject:Autocrypt:Date:Message-ID:MIME-Version:From; b=qPijwZUaulBqGune/N7ZP22iohlsLHQi26EbfBwR4bDWJOilUqFwiziOH5MJyakIP /blrg4431G9B94u91VV7n+M0OI2sm9w++LX5uAq4aaDC7+jnHOvLwoXjiuhbenGcu9 HvR45m45rDsCRClmp4Z6VzVf1ZPkw9n22eP2qFAeIHgjBR8W+80W97rZuDFWFj/GjM jJweY0h73CMItE8R1JsTE6RTGgYjJtlT/R4j0wJUYX6tCKZ6ukMIc3UvaM1EBUR87U cWjLXkJau/eUUyAwDbOGGK6VBpTWytfIFvhPE2ChJK5O2jpp3ZZMMJWywl9uIGFNf8 ULB7iseniOibg== Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4QLw0835vJz9rxN; Wed, 17 May 2023 16:07:04 +0200 (CEST) From: Philip Kaludercic To: Joseph Turner Subject: Re: bug#63336: [PATCH] package-vc: Process :make and :shell-command spec args In-Reply-To: <87zg64rniy.fsf@breatheoutbreathe.in> (Joseph Turner's message of "Tue, 16 May 2023 14:08:33 -0700") References: <874joprxmx.fsf@breatheoutbreathe.in> <87jzxkecnk.fsf@posteo.net> <87pm7b7up0.fsf@breatheoutbreathe.in> <877ctghey0.fsf@posteo.net> <873540rqkm.fsf@breatheoutbreathe.in> <87ilcvichb.fsf@posteo.net> <87cz33parh.fsf@breatheoutbreathe.in> <871qjiiucw.fsf@posteo.net> <87jzxafotr.fsf@breatheoutbreathe.in> <87sfbynekl.fsf@posteo.net> <87h6sdtnq4.fsf@breatheoutbreathe.in> <874jocaxcf.fsf@posteo.net> <87zg64rniy.fsf@breatheoutbreathe.in> Autocrypt: addr=philipk@posteo.net; keydata= mDMEZBBQQhYJKwYBBAHaRw8BAQdAHJuofBrfqFh12uQu0Yi7mrl525F28eTmwUDflFNmdui0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiWBBMWCAA+FiEEDg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwMFCQHhM4AFCwkI BwIGFQoJCAsCBBYCAwECHgECF4AACgkQ8xYDWXahwulikAEA77hloUiSrXgFkUVJhlKBpLCHUjA0 mWZ9j9w5d08+jVwBAK6c4iGP7j+/PhbkxaEKa4V3MzIl7zJkcNNjHCXmvFcEuDgEZBBQQhIKKwYB BAGXVQEFAQEHQI5NLiLRjZy3OfSt1dhCmFyn+fN/QKELUYQetiaoe+MMAwEIB4h+BBgWCAAmFiEE Dg7HY17ghYlni8XN8xYDWXahwukFAmQQUEICGwwFCQHhM4AACgkQ8xYDWXahwukm+wEA8cml4JpK NeAu65rg+auKrPOP6TP/4YWRCTIvuYDm0joBALw98AMz7/qMHvSCeU/hw9PL6u6R2EScxtpKnWof z4oM Date: Wed, 17 May 2023 14:07:03 +0000 Message-ID: <87fs7v9hmg.fsf@posteo.net> MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -2.3 (--) X-Debbugs-Envelope-To: 63336-done Cc: 63336-done@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: debbugs-submit-bounces@debbugs.gnu.org Sender: "Debbugs-submit" X-Spam-Score: -3.3 (---) Joseph Turner writes: > Philip Kaludercic writes: > >> I've pushed the changes to master. If you are still interested in >> improving the granularity of the issue, create a new report when you >> have a patch we can discuss. > > Thank you! I assume you're referring to something like a 'user-defined > option for package-vc-allow-side-effects. Right, > At some point, I may submit > another patch adding that feature! but there is no hurry for that. > Best, > > Joseph From unknown Mon Aug 18 09:02:55 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Thu, 15 Jun 2023 11:24:07 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator