From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philip Kaludercic Newsgroups: gmane.emacs.devel Subject: Re: feature/package+vc 04c4c578c7 3/4: Allow for packages to be installed directly from VCS Date: Fri, 28 Oct 2022 17:24:03 +0000 Message-ID: <87ilk33lqk.fsf@posteo.net> References: <164484721900.31751.1453162457552427931@vcs2.savannah.gnu.org> <87bkqmqpvb.fsf@posteo.net> <87edv96q4j.fsf@posteo.net> <83tu455a5s.fsf@gnu.org> <87a65v2ytp.fsf@posteo.net> <834jw33rmx.fsf@gnu.org> <87pmer0xtz.fsf@posteo.net> <83wn8z2aze.fsf@gnu.org> <878rle1i0k.fsf@posteo.net> <87ilkelc10.fsf@posteo.net> <878rl6syg8.fsf@posteo.net> <87zgdjqcu0.fsf@posteo.net> <87zgdivc3f.fsf@posteo.net> <874jvqv2u3.fsf@posteo.net> <875yg6qtbl.fsf@posteo.net> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13623"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Richard Stallman , emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Fri Oct 28 19:25:27 2022 Return-path: Envelope-to: ged-emacs-devel@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1ooT6k-0003OL-Vl for ged-emacs-devel@m.gmane-mx.org; Fri, 28 Oct 2022 19:25:27 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ooT5Z-00089r-42; Fri, 28 Oct 2022 13:24:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooT5X-00089C-C8 for emacs-devel@gnu.org; Fri, 28 Oct 2022 13:24:11 -0400 Original-Received: from mout02.posteo.de ([185.67.36.66]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1ooT5U-0002Nq-UU for emacs-devel@gnu.org; Fri, 28 Oct 2022 13:24:11 -0400 Original-Received: from submission (posteo.de [185.67.36.169]) by mout02.posteo.de (Postfix) with ESMTPS id 9FA95240109 for ; Fri, 28 Oct 2022 19:24:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=posteo.net; s=2017; t=1666977846; bh=BhuaQcPopB2cReHzTxeGyCm57focOJ5UlXl8B8vTCJE=; h=From:To:Cc:Subject:Autocrypt:Date:From; b=aZNUy4dgerbfAsAhCs9YhSFS+M9D4sdzsbuKzB0hF16FH0bB6cwEvn2H3BCkhZ23n mz3Qvsuo7pwpa6/XYYEko2XfFRscPD7bu/KLjZBQgIYbayInoOVw7gcDwQPwYN9DHs sAguRD8za5uyIRftKq2P3i+5veSTqNJ2tIKLpVfjFhe2KMdBaySiF5XIS5VYMa24kt o9dZ2X7S6RfHKTknhlIvp1Kz6hF4cQKSspJDaOT63lXduhGOMiRa6JNNG6tk3VsU4I LUuwmVfvH+s/fk+Pp6n9S92xNm5h9e3QXa/NArTyBufL68J++exy4c9z4F6ClG0PKE 6hlCuNEpSMGlg== Original-Received: from customer (localhost [127.0.0.1]) by submission (posteo.de) with ESMTPSA id 4MzTtF4J9tz9rxD; Fri, 28 Oct 2022 19:24:04 +0200 (CEST) In-Reply-To: <875yg6qtbl.fsf@posteo.net> (Philip Kaludercic's message of "Wed, 26 Oct 2022 21:27:10 +0200") Autocrypt: addr=philipk@posteo.net; prefer-encrypt=nopreference; keydata= mDMEYHHqUhYJKwYBBAHaRw8BAQdAp3GdmYJ6tm5McweY6dEvIYIiry+Oz9rU4MH6NHWK0Ee0QlBo aWxpcCBLYWx1ZGVyY2ljIChnZW5lcmF0ZWQgYnkgYXV0b2NyeXB0LmVsKSA8cGhpbGlwa0Bwb3N0 ZW8ubmV0PoiQBBMWCAA4FiEEDM2H44ZoPt9Ms0eHtVrAHPRh1FwFAmBx6lICGwMFCwkIBwIGFQoJ CAsCBBYCAwECHgECF4AACgkQtVrAHPRh1FyTkgEAjlbGPxFchvMbxzAES3r8QLuZgCxeAXunM9gh io0ePtUBALVhh9G6wIoZhl0gUCbQpoN/UJHI08Gm1qDob5zDxnIHuDgEYHHqUhIKKwYBBAGXVQEF AQEHQNcRB+MUimTMqoxxMMUERpOR+Q4b1KgncDZkhrO2ql1tAwEIB4h4BBgWCAAgFiEEDM2H44Zo Pt9Ms0eHtVrAHPRh1FwFAmBx6lICGwwACgkQtVrAHPRh1Fw1JwD/Qo7kvtib8jy7puyWrSv0MeTS g8qIxgoRWJE/KKdkCLEA/jb9b9/g8nnX+UcwHf/4VfKsjExlnND3FrBviXUW6NcB Received-SPF: pass client-ip=185.67.36.66; envelope-from=philipk@posteo.net; helo=mout02.posteo.de X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: "Emacs-devel" Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:298685 Archived-At: --=-=-= Content-Type: text/plain Philip Kaludercic writes: > Stefan Monnier writes: > >>>> AFAIK this is sufficiently hypothetical that I'm really not convinced >>>> it's worth the extra work (and the risk of incompatibilities between >>>> the `elpa-admin.el` behavior and that if `package-vc`, e.g. where they >>>> might disagree on which commit is "the" release). >>> >>> I don't know, to me this sounds more like an argument against merging >>> elpa-admin.el and package-vc.el... >> >> It's not about sharing the code here (for which I have lobbied in other >> messages), but about sharing the behavior. >> `elpa-admin.el` de facto defines a "protocol" that upstream maintainers >> have to follow. If `package-vc` doesn't follow the same protocol, >> end-users will suffer unexpected discrepancies. > > That is sort of the question I was implying previously (when mentioning > adding meta data), as to whether or not there is a "protocol" or if the > two format just coincidentally share a part of a common structure. Here is what I had in mind. With the following patch for elpa-admin.git: --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-elpa-admin.el-elpaa-publish-package-specs-Update-fil.patch >From dd2bbf65ce18cebc28b1118a31ca5d117df1b5c0 Mon Sep 17 00:00:00 2001 From: Philip Kaludercic Date: Fri, 28 Oct 2022 19:19:21 +0200 Subject: [PATCH] * elpa-admin.el (elpaa--publish-package-specs): Update file format --- elpa-admin.el | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/elpa-admin.el b/elpa-admin.el index 81eb0b9f91..f45a596671 100644 --- a/elpa-admin.el +++ b/elpa-admin.el @@ -792,18 +792,25 @@ of the current `process-environment'. Return the modified copy." "Process and publish SPECS in elpa-packages.eld files." (with-temp-buffer ;; Remove :core packages, handle :url nil and and compress the - ;; contents of the "elpa-packages" + ;; contents of the "elpa-packages". Note that elpa-packages.eld + ;; does not use the same format as "elpa-packages" in + ;; {nongnu,elpa}.git. The file is intended to be used by + ;; package-vc.el. (prin1 - (mapcan - (lambda (spec) - (pcase spec - (`(,name :url nil . ,rest) - `((,name :url ,(concat "https://git.sv.gnu.org/git/" elpaa--gitrepo) - :branch ,(concat elpaa--branch-prefix (car spec)) - ,@rest))) - (`(,_ :core ,_ . ,_) nil) ;not supported - (_ (list spec)))) - specs) + (list (mapcan + (lambda (spec) + (let ((rel (ignore-errors (elpaa--get-last-release spec)))) + (when rel + (nconc spec (list :release-rev (cdr rel))))) + (pcase spec + (`(,name :url nil . ,rest) + `((,name :url ,(concat "https://git.sv.gnu.org/git/" elpaa--gitrepo) + :branch ,(concat elpaa--branch-prefix (car spec)) + ,@rest))) + (`(,_ :core ,_ . ,_) nil) ;not supported + (_ (list spec)))) + specs) + :version 1 :default-vc 'Git) (current-buffer)) (write-region nil nil (expand-file-name "elpa-packages.eld" elpaa--release-subdir)) (write-region nil nil (expand-file-name "elpa-packages.eld" elpaa--devel-subdir)))) -- 2.38.0 --=-=-= Content-Type: text/plain and these changes to package-vc.el: --=-=-= Content-Type: text/plain Content-Disposition: inline diff --git a/lisp/emacs-lisp/package-vc.el b/lisp/emacs-lisp/package-vc.el index 8e4f2819db..e995853768 100644 --- a/lisp/emacs-lisp/package-vc.el +++ b/lisp/emacs-lisp/package-vc.el @@ -56,6 +56,9 @@ package-vc :group 'package :version "29.1") +(defconst package-vc-elpa-packages-version 1 + "Version number of the package specification format understood by package-vc.") + (defcustom package-vc-heuristic-alist `((,(rx bos "http" (? "s") "://" (or (: (? "www.") "github.com" @@ -144,6 +147,34 @@ package-vc-archive-spec-alist All other values are ignored.") +(defvar package-vc-archive-data-alist nil + "List of package specification archive metadata. +Each element of the list has the form (ARCHIVE . PLIST), where +PLIST keys are one of: + + `:version' (integer) + +Indicating the version of the file formatting, to be compared +with `package-vc-elpa-packages-version'. + + `:vc-backend' (symbol) + +A symbol indicating what the default VC backend to use if a +package specification does not indicate anything. The value +ought to be a member of `vc-handled-backends'. If missing, +`vc-clone' will fall back onto `package-vc-default-backend'. + +All other values are ignored.") + +(define-inline package-vc-query-archive-data (archive prop) + "Query the property PROP for the package specification for PKG-DESC. +If no package specification can be determined, the function will +return nil." + (inline-letevals (archive prop) + (inline-quote (plist-get + (alist-get ,archive package-vc-archive-data-alist) + ,prop)))) + (defun package-vc-desc->spec (pkg-desc &optional name) "Retrieve the package specification for PKG-DESC. The optional argument NAME can be used to override the default @@ -171,9 +202,23 @@ package-vc--read-archive-data (when (file-exists-p contents-file) (with-temp-buffer (let ((coding-system-for-read 'utf-8)) - (insert-file-contents contents-file)) - (setf (alist-get (intern archive) package-vc-archive-spec-alist) - (read (current-buffer))))))) + (insert-file-contents contents-file) + ;; The response from the server is expected to have the form + ;; + ;; ((("foo" :url "..." ...) ...) + ;; :version 1 + ;; :default-vc Git) + (let ((spec (read (current-buffer)))) + (when (= package-vc-elpa-packages-version + (plist-get (cdr spec) :version)) + (setf (alist-get (intern archive) package-vc-archive-spec-alist) + (car spec))) + (setf (alist-get (intern archive) package-vc-archive-data-alist) + (cdr spec)) + (when-let ((default-vc (plist-get (cdr spec) :default-vc)) + ((not (memq default-vc vc-handled-backends)))) + (warn "Archive `%S' expects missing VC backend %S" + archive (plist-get (cdr spec) :default-vc))))))))) (defun package-vc--download-and-read-archives (&optional async) "Download specifications of all `package-archives' and read them. @@ -374,6 +419,10 @@ package-vc-unpack (unless (file-exists-p repo-dir) (make-directory (file-name-directory repo-dir) t) (let ((backend (or (package-vc-guess-backend url) + (plist-get (alist-get (package-desc-archive pkg-desc) + package-vc-archive-data-alist + nil nil #'string=) + :vc-backend) package-vc-default-backend))) (unless (vc-clone url backend repo-dir (or rev branch)) (error "Failed to clone %s from %s" name url)))) --=-=-= Content-Type: text/plain A more forwards-compatible file format would be defined that would uncouple the format used by elpa-admin.el and package-vc.el the more I think about this, the more I think it is better to take this path instead of sharing code between the two. Sure, this means that some things have to be duplicated, but we are talking about two different scenarios (activating source controlled code and packaging tarballs) that might have a lot in common but still ought to be considered separately. --=-=-=--