Sean Whitton <spwhit...@spwhitton.name> writes:

> Hello,
>
> On Tue 15 Jul 2025 at 11:46am -07, Xiyue Deng wrote:
>
>> Xiyue Deng <manp...@gmail.com> writes:
>>
>>> [...]
>>>> But I think we can do the following:
>>>>
>>>> - Let's start preparing the versioned Provides generation in
>>>>   experimental.  Assume I'l backport your patch in #78844 to Emacs 30.
>>>>   Can you prepare a patch implementing the Provides generation?
>>>>
>>>
>>> The patches I attached to [3] implemented this (as well as in my
>>> branch[4] which could be newer).  It didn't backport bug#78844 in the
>>> Emacs source, but host identify copies of the new functions in the
>>> provides/breaks/replaces generation code (which are guarded by fboundp
>>> so that the Emacs implementations will be used when available in Emacs
>>> 31).  I think this has the advantage that we won't hit any conflicts
>>> when upgrading.
>>>
>>
>> I just realized that you have already done the backporting of #78844.
>> The patches still work (as it's guarded by fboundp), but do you want me
>> to remove the vendored functions?
>
> Yes, please prepare a patch against current debian/d/sid/master.
>

Updated my branch by dropping the vendored functions[1].  Also attached
the updated patches.

> -- 
> Sean Whitton

[1] 
https://salsa.debian.org/manphiz/deb-emacs/-/compare/deb%2Femacs%2Fd%2Fsid%2Fmaster...generate-provide-package-list?from_project_id=83361

-- 
Regards,
Xiyue Deng
From 7f3836bd966039343ddba9e620830de0236eae08 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manp...@gmail.com>
Date: Mon, 16 Jun 2025 17:09:48 -0700
Subject: [PATCH 1/4] Add script to generate substvars for Emacs builtin
 packages

---
 .../generate-bundled-package-provide-list.el  | 81 +++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 debian/generate-bundled-package-provide-list.el

diff --git a/debian/generate-bundled-package-provide-list.el b/debian/generate-bundled-package-provide-list.el
new file mode 100644
index 00000000000..12e8a7e9c5a
--- /dev/null
+++ b/debian/generate-bundled-package-provide-list.el
@@ -0,0 +1,81 @@
+;; Emacs script to generate a package provide list -*- lexical-binding:t -*-
+
+(defvar package-skip-list
+  '("elpa-emacs")
+  "A list of package that should be skipped in the provide list")
+
+(defvar emacs-provided-package-versions nil
+  "An alist of Debian package name to version.
+You should call the function version to get the values instead.")
+
+(defun package-version-list-to-string (package-version-list)
+  "Convert a package version list to version string acceptable in Debian."
+  (when package-version-list
+    (let ((count 0)
+          version-list)
+      (dolist (item package-version-list)
+        (progn
+          (if (< item 0)
+              (progn
+                ;; This roughly matches the mapping in
+                ;; version-regexp-alist.
+                (cl-case item
+                  (-1 (push "~rc" version-list))
+                  (-2 (push "~beta" version-list))
+                  (-3 (push "~alpha" version-list))
+                  (-4 (push "~snapshot" version-list))
+                  (t (error "Unknown version: %d" item)))
+                ;; no "." between prerelease name and number
+                (setq count 0))
+            (when (> count 0)
+              (push "." version-list))
+            (push (number-to-string item) version-list)
+            (cl-incf count))))
+      (string-join (nreverse version-list)))))
+
+(defun emacs-provided-package-versions ()
+  "Returns the calculated EMACS-PROVIDED-PACKAGE-VERSIONS."
+  (if emacs-provided-package-versions
+      emacs-provided-package-versions
+    (mapc (lambda (package-name)
+            (let* ((debian-package-name (concat "elpa-"
+                                                (symbol-name package-name)))
+                   (debian-package-version (package-version-list-to-string
+                                            (package-builtin-package-version
+                                             package-name))))
+              (when (not (member debian-package-name package-skip-list))
+                (push `(,debian-package-name . ,debian-package-version)
+                      emacs-provided-package-versions))))
+          (package-versioned-builtin-packages))
+    (sort emacs-provided-package-versions)))
+
+(princ "# Package name and version on each line in comments for tracking.\n#\n")
+(let (provides-substvars-list
+      replaces-substvars-list
+      (count 0))
+  (mapc (lambda (package-version)
+          (let* ((name (car package-version))
+                 (version (cdr package-version))
+                 (provides-entry-string (concat name
+                                                (when version
+                                                  (format " (= %s)" version))
+                                                ","))
+                 (replaces-entry-string (concat name
+                                                (when version
+                                                  (format " (<< %s)" version))
+                                                ",")))
+            (princ (format "# %s\n" provides-entry-string))
+            (when (> count 0)
+              (push " " provides-substvars-list)
+              (push " " replaces-substvars-list))
+            (push provides-entry-string provides-substvars-list)
+            (push replaces-entry-string replaces-substvars-list)
+            (cl-incf count)))
+        (emacs-provided-package-versions))
+  (let ((debian-provides-substvars-string
+         (string-join (nreverse provides-substvars-list)))
+        (debian-replaces-substvars-string
+         (string-join (nreverse replaces-substvars-list))))
+    (princ (format "emacs:Provides=%s\n" debian-provides-substvars-string))
+    (princ (format "emacs:Breaks=%s\n" debian-replaces-substvars-string))
+    (princ (format "emacs:Replaces=%s\n" debian-replaces-substvars-string))))
-- 
2.50.0

From 6df9729c2615f8fc1ae645f141244c7143847f94 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manp...@gmail.com>
Date: Wed, 18 Jun 2025 13:28:04 -0700
Subject: [PATCH 2/4] Add rule to generate debian/emacs-common-substvars in
 debian/rules

---
 debian/rules | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/debian/rules b/debian/rules
index 18de17ac996..084b0a5dd0e 100755
--- a/debian/rules
+++ b/debian/rules
@@ -221,7 +221,11 @@ check-vars:
 .PHONY: check-autogen
 check-autogen: $(persistent_autogen_files) $(nonpersistent_autogen_files)
 
-debian-sync: $(persistent_autogen_files)
+.PHONY: debian/emacs-common-substvars
+debian/emacs-common-substvars:
+	/usr/bin/emacs -Q --script debian/generate-bundled-package-provide-list.el > debian/emacs-common-substvars
+
+debian-sync: $(persistent_autogen_files) debian/emacs-common-substvars
         # so dh pattern rule doesn't try to handle this target
 	true
 
@@ -613,6 +617,10 @@ override_dh_auto_install: $(autogen_install_files)
 	rm -rf $(install_dir_nox)
 	rm -rf $(install_dir_lucid)
 
+# Add generated emacs:Provides to substvars
+execute_before_dh_gencontrol:
+	cat debian/emacs-common-substvars >> debian/emacs-common.substvars
+
 # Install the per-user systemd unit in a disabled state by default.
 override_dh_installsystemduser:
 	dh_installsystemduser --no-enable
-- 
2.50.0

From 4caa3244cbf3d3e1f28e415b77c196aa3080d802 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manp...@gmail.com>
Date: Wed, 25 Jun 2025 10:55:48 -0700
Subject: [PATCH 3/4] Generate debian/emacs-common-substvars

---
 debian/emacs-common-substvars | 81 +++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
 create mode 100644 debian/emacs-common-substvars

diff --git a/debian/emacs-common-substvars b/debian/emacs-common-substvars
new file mode 100644
index 00000000000..d8bc408d80c
--- /dev/null
+++ b/debian/emacs-common-substvars
@@ -0,0 +1,81 @@
+# Package name and version on each line in comments for tracking.
+#
+# elpa-allout (= 2.3),
+# elpa-allout-widgets (= 1.0),
+# elpa-ansi-color (= 3.4.2),
+# elpa-antlr-mode (= 2.2.3),
+# elpa-auth-source-pass (= 5.0.0),
+# elpa-backtrace (= 1.0),
+# elpa-bind-key (= 2.4.1),
+# elpa-cc-mode (= 5.33.1),
+# elpa-cedet (= 2.0),
+# elpa-cfengine (= 1.4),
+# elpa-cl-generic (= 1.0),
+# elpa-cl-lib (= 1.0),
+# elpa-cl-print (= 1.0),
+# elpa-compat (= 30.1.9999),
+# elpa-ede (= 2.0),
+# elpa-ediff (= 2.81.6),
+# elpa-editorconfig (= 0.11.0),
+# elpa-eglot (= 1.17.30),
+# elpa-eieio (= 1.4),
+# elpa-eieio-core (= 1.4),
+# elpa-eldoc (= 1.15.0),
+# elpa-epg (= 1.0.0),
+# elpa-erc (= 5.6.0.30.1),
+# elpa-eshell (= 2.4.2),
+# elpa-external-completion (= 0.1),
+# elpa-faceup (= 0.0.6),
+# elpa-feedmail (= 11),
+# elpa-find-cmd (= 0.6),
+# elpa-flymake (= 1.3.7),
+# elpa-flymake-proc (= 1.0),
+# elpa-foldout (= 1.10),
+# elpa-gnus (= 5.13),
+# elpa-idlwave (= 6.1.22),
+# elpa-image-dired (= 0.5),
+# elpa-info-xref (= 3),
+# elpa-isearchb (= 1.5),
+# elpa-js (= 9),
+# elpa-json (= 1.5),
+# elpa-jsonrpc (= 1.0.25),
+# elpa-let-alist (= 1.0.6),
+# elpa-map (= 3.3.1),
+# elpa-meta-mode (= 1.0),
+# elpa-mh-e (= 8.6~snapshot),
+# elpa-mixal-mode (= 0.4),
+# elpa-nadvice (= 1.0),
+# elpa-ntlm (= 2.1.0),
+# elpa-org (= 9.7.11),
+# elpa-package (= 1.1.0),
+# elpa-peg (= 1.0.1),
+# elpa-project (= 0.11.1),
+# elpa-ps-mode (= 1.1.9),
+# elpa-pulse (= 1.0),
+# elpa-python (= 0.28),
+# elpa-ruby-mode (= 1.2),
+# elpa-ruby-ts-mode (= 0.2),
+# elpa-semantic (= 2.2),
+# elpa-seq (= 2.24),
+# elpa-so-long (= 1.1.2),
+# elpa-soap-client (= 3.2.3),
+# elpa-sql (= 3.6),
+# elpa-srecode (= 1.2),
+# elpa-svg (= 1.1),
+# elpa-tabulated-list (= 1.0),
+# elpa-thunk (= 1.0),
+# elpa-tildify (= 4.6.1),
+# elpa-track-changes (= 1.2),
+# elpa-tramp (= 2.7.1.30.1),
+# elpa-transient (= 0.7.2.2),
+# elpa-use-package (= 2.4.6),
+# elpa-vera-mode (= 2.28),
+# elpa-verilog-mode (= 2024.3.1.121933719),
+# elpa-viper (= 3.14.2),
+# elpa-which-key (= 3.6.0),
+# elpa-whitespace (= 13.2.2),
+# elpa-window-tool-bar (= 0.2.1),
+# elpa-xref (= 1.7.0),
+emacs:Provides=elpa-allout (= 2.3), elpa-allout-widgets (= 1.0), elpa-ansi-color (= 3.4.2), elpa-antlr-mode (= 2.2.3), elpa-auth-source-pass (= 5.0.0), elpa-backtrace (= 1.0), elpa-bind-key (= 2.4.1), elpa-cc-mode (= 5.33.1), elpa-cedet (= 2.0), elpa-cfengine (= 1.4), elpa-cl-generic (= 1.0), elpa-cl-lib (= 1.0), elpa-cl-print (= 1.0), elpa-compat (= 30.1.9999), elpa-ede (= 2.0), elpa-ediff (= 2.81.6), elpa-editorconfig (= 0.11.0), elpa-eglot (= 1.17.30), elpa-eieio (= 1.4), elpa-eieio-core (= 1.4), elpa-eldoc (= 1.15.0), elpa-epg (= 1.0.0), elpa-erc (= 5.6.0.30.1), elpa-eshell (= 2.4.2), elpa-external-completion (= 0.1), elpa-faceup (= 0.0.6), elpa-feedmail (= 11), elpa-find-cmd (= 0.6), elpa-flymake (= 1.3.7), elpa-flymake-proc (= 1.0), elpa-foldout (= 1.10), elpa-gnus (= 5.13), elpa-idlwave (= 6.1.22), elpa-image-dired (= 0.5), elpa-info-xref (= 3), elpa-isearchb (= 1.5), elpa-js (= 9), elpa-json (= 1.5), elpa-jsonrpc (= 1.0.25), elpa-let-alist (= 1.0.6), elpa-map (= 3.3.1), elpa-meta-mode (= 1.0), elpa-mh-e (= 8.6~snapshot), elpa-mixal-mode (= 0.4), elpa-nadvice (= 1.0), elpa-ntlm (= 2.1.0), elpa-org (= 9.7.11), elpa-package (= 1.1.0), elpa-peg (= 1.0.1), elpa-project (= 0.11.1), elpa-ps-mode (= 1.1.9), elpa-pulse (= 1.0), elpa-python (= 0.28), elpa-ruby-mode (= 1.2), elpa-ruby-ts-mode (= 0.2), elpa-semantic (= 2.2), elpa-seq (= 2.24), elpa-so-long (= 1.1.2), elpa-soap-client (= 3.2.3), elpa-sql (= 3.6), elpa-srecode (= 1.2), elpa-svg (= 1.1), elpa-tabulated-list (= 1.0), elpa-thunk (= 1.0), elpa-tildify (= 4.6.1), elpa-track-changes (= 1.2), elpa-tramp (= 2.7.1.30.1), elpa-transient (= 0.7.2.2), elpa-use-package (= 2.4.6), elpa-vera-mode (= 2.28), elpa-verilog-mode (= 2024.3.1.121933719), elpa-viper (= 3.14.2), elpa-which-key (= 3.6.0), elpa-whitespace (= 13.2.2), elpa-window-tool-bar (= 0.2.1), elpa-xref (= 1.7.0),
+emacs:Breaks=elpa-allout (<< 2.3), elpa-allout-widgets (<< 1.0), elpa-ansi-color (<< 3.4.2), elpa-antlr-mode (<< 2.2.3), elpa-auth-source-pass (<< 5.0.0), elpa-backtrace (<< 1.0), elpa-bind-key (<< 2.4.1), elpa-cc-mode (<< 5.33.1), elpa-cedet (<< 2.0), elpa-cfengine (<< 1.4), elpa-cl-generic (<< 1.0), elpa-cl-lib (<< 1.0), elpa-cl-print (<< 1.0), elpa-compat (<< 30.1.9999), elpa-ede (<< 2.0), elpa-ediff (<< 2.81.6), elpa-editorconfig (<< 0.11.0), elpa-eglot (<< 1.17.30), elpa-eieio (<< 1.4), elpa-eieio-core (<< 1.4), elpa-eldoc (<< 1.15.0), elpa-epg (<< 1.0.0), elpa-erc (<< 5.6.0.30.1), elpa-eshell (<< 2.4.2), elpa-external-completion (<< 0.1), elpa-faceup (<< 0.0.6), elpa-feedmail (<< 11), elpa-find-cmd (<< 0.6), elpa-flymake (<< 1.3.7), elpa-flymake-proc (<< 1.0), elpa-foldout (<< 1.10), elpa-gnus (<< 5.13), elpa-idlwave (<< 6.1.22), elpa-image-dired (<< 0.5), elpa-info-xref (<< 3), elpa-isearchb (<< 1.5), elpa-js (<< 9), elpa-json (<< 1.5), elpa-jsonrpc (<< 1.0.25), elpa-let-alist (<< 1.0.6), elpa-map (<< 3.3.1), elpa-meta-mode (<< 1.0), elpa-mh-e (<< 8.6~snapshot), elpa-mixal-mode (<< 0.4), elpa-nadvice (<< 1.0), elpa-ntlm (<< 2.1.0), elpa-org (<< 9.7.11), elpa-package (<< 1.1.0), elpa-peg (<< 1.0.1), elpa-project (<< 0.11.1), elpa-ps-mode (<< 1.1.9), elpa-pulse (<< 1.0), elpa-python (<< 0.28), elpa-ruby-mode (<< 1.2), elpa-ruby-ts-mode (<< 0.2), elpa-semantic (<< 2.2), elpa-seq (<< 2.24), elpa-so-long (<< 1.1.2), elpa-soap-client (<< 3.2.3), elpa-sql (<< 3.6), elpa-srecode (<< 1.2), elpa-svg (<< 1.1), elpa-tabulated-list (<< 1.0), elpa-thunk (<< 1.0), elpa-tildify (<< 4.6.1), elpa-track-changes (<< 1.2), elpa-tramp (<< 2.7.1.30.1), elpa-transient (<< 0.7.2.2), elpa-use-package (<< 2.4.6), elpa-vera-mode (<< 2.28), elpa-verilog-mode (<< 2024.3.1.121933719), elpa-viper (<< 3.14.2), elpa-which-key (<< 3.6.0), elpa-whitespace (<< 13.2.2), elpa-window-tool-bar (<< 0.2.1), elpa-xref (<< 1.7.0),
+emacs:Replaces=elpa-allout (<< 2.3), elpa-allout-widgets (<< 1.0), elpa-ansi-color (<< 3.4.2), elpa-antlr-mode (<< 2.2.3), elpa-auth-source-pass (<< 5.0.0), elpa-backtrace (<< 1.0), elpa-bind-key (<< 2.4.1), elpa-cc-mode (<< 5.33.1), elpa-cedet (<< 2.0), elpa-cfengine (<< 1.4), elpa-cl-generic (<< 1.0), elpa-cl-lib (<< 1.0), elpa-cl-print (<< 1.0), elpa-compat (<< 30.1.9999), elpa-ede (<< 2.0), elpa-ediff (<< 2.81.6), elpa-editorconfig (<< 0.11.0), elpa-eglot (<< 1.17.30), elpa-eieio (<< 1.4), elpa-eieio-core (<< 1.4), elpa-eldoc (<< 1.15.0), elpa-epg (<< 1.0.0), elpa-erc (<< 5.6.0.30.1), elpa-eshell (<< 2.4.2), elpa-external-completion (<< 0.1), elpa-faceup (<< 0.0.6), elpa-feedmail (<< 11), elpa-find-cmd (<< 0.6), elpa-flymake (<< 1.3.7), elpa-flymake-proc (<< 1.0), elpa-foldout (<< 1.10), elpa-gnus (<< 5.13), elpa-idlwave (<< 6.1.22), elpa-image-dired (<< 0.5), elpa-info-xref (<< 3), elpa-isearchb (<< 1.5), elpa-js (<< 9), elpa-json (<< 1.5), elpa-jsonrpc (<< 1.0.25), elpa-let-alist (<< 1.0.6), elpa-map (<< 3.3.1), elpa-meta-mode (<< 1.0), elpa-mh-e (<< 8.6~snapshot), elpa-mixal-mode (<< 0.4), elpa-nadvice (<< 1.0), elpa-ntlm (<< 2.1.0), elpa-org (<< 9.7.11), elpa-package (<< 1.1.0), elpa-peg (<< 1.0.1), elpa-project (<< 0.11.1), elpa-ps-mode (<< 1.1.9), elpa-pulse (<< 1.0), elpa-python (<< 0.28), elpa-ruby-mode (<< 1.2), elpa-ruby-ts-mode (<< 0.2), elpa-semantic (<< 2.2), elpa-seq (<< 2.24), elpa-so-long (<< 1.1.2), elpa-soap-client (<< 3.2.3), elpa-sql (<< 3.6), elpa-srecode (<< 1.2), elpa-svg (<< 1.1), elpa-tabulated-list (<< 1.0), elpa-thunk (<< 1.0), elpa-tildify (<< 4.6.1), elpa-track-changes (<< 1.2), elpa-tramp (<< 2.7.1.30.1), elpa-transient (<< 0.7.2.2), elpa-use-package (<< 2.4.6), elpa-vera-mode (<< 2.28), elpa-verilog-mode (<< 2024.3.1.121933719), elpa-viper (<< 3.14.2), elpa-which-key (<< 3.6.0), elpa-whitespace (<< 13.2.2), elpa-window-tool-bar (<< 0.2.1), elpa-xref (<< 1.7.0),
-- 
2.50.0

From 145c96445dbf80eaf4b4f9495114815f878630ee Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manp...@gmail.com>
Date: Tue, 15 Jul 2025 15:50:22 -0700
Subject: [PATCH 4/4] Add substvars to emacs-common in debian/control

---
 debian/control | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/debian/control b/debian/control
index 86cd8976b46..2a1364ffd54 100644
--- a/debian/control
+++ b/debian/control
@@ -191,8 +191,12 @@ Breaks:
  emacs-gtk (<< 1:25),
  emacs-lucid (<< 1:25),
  emacs-nox (<< 1:25),
+ ${emacs:Breaks}
 Replaces:
- emacs-bin-common (<< 1:28)
+ emacs-bin-common (<< 1:28),
+ ${emacs:Replaces}
+Provides:
+ ${emacs:Provides}
 Description: GNU Emacs editor's shared, architecture independent infrastructure
  GNU Emacs is the extensible self-documenting text editor.
  This package contains the architecture independent infrastructure
-- 
2.50.0

Attachment: signature.asc
Description: PGP signature

Reply via email to