Sean Whitton <spwhit...@spwhitton.name> writes: > Hello, > > On Wed 16 Jul 2025 at 10:30am -07, Xiyue Deng wrote: > >> Sean Whitton <spwhit...@spwhitton.name> writes: >> >>> Hello Xiyue, >>> >>> This is great work. Thank you for the respin. I'd just like to ask a >>> few questions about it. >>> >>> - What is the emacs-provided-package-versions variable for? I don't >>> think it gets set anywhere? >>> >> >> It's used later in the `emacs-provided-package-versions` function, which >> will populate it with a mapping of package name to version. This will >> then be used later to actually generate the substvars values. > > I don't think it needs to be a defvar. It can be a lexical variable > inside that function. >
Ah, it was an optimization so that when we need the mapping multiple times it doesn't need to be regenerated everything. It looks like now we only need to get this mapping once, so I have made it a lexical variable now. My branch is now updated (patch also attached). >> It also gets regenerated with `debian/rules debian-sync': notice that >> the build rule is marked `.PHONY'. I think this should be run on each >> update according to d/README.source. Maybe this could be added to >> dh_auto_clean in case someone (like me) forgets to run it by hand? > > Why not generate it during the build? That's how other substvars work. > This makes the development easier so that I don't have to sbuild it every time to test (which takes ~20min for me). Also, running the script needs a working emacs executable (I'm using `/usr/bin/emacs') which is not available yet during build (or it can some built emacs executable in some build-path, but I think it's a bit too fragile). And I realize that because I removed the vendored lisp functions to get the built-in package information, the script currently cannot work until Emacs with the backported package.el is released. So probably we should upload -6 first (in experimental)? > -- > Sean Whitton -- Regards, Xiyue Deng
From 3565f21ada2bd9915af43f211d32d2b77b7d7ad0 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 | 76 +++++++++++++++++++ 1 file changed, 76 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..1c0c164d46e --- /dev/null +++ b/debian/generate-bundled-package-provide-list.el @@ -0,0 +1,76 @@ +;; 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") + +(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 () + "Return an alist of Debian package name to version mapping." + (let (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
signature.asc
Description: PGP signature