Control: forwarded -1 https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71817

(CCing Nicholas who also provided feedbacks on IRC.)

I have opened an upstream bug[1] asking for opinions on the ELPA path
handling and they confirmed that the current status is expected:
byte-compiling recursively, and only add source root path to
`load-path'.  I believe this confirms that this wishlist is going in the
right direction.

I have also updated the implementation so that adding `.nosearch' files
is done directly in d/rules instead of relying on triggers which adds
unnecessary overload when installing each elpa package[2].  The full
diff can be found on salsa[3] and also attached.

[1] https://debbugs.gnu.org/cgi/bugreport.cgi?bug=71817
[2] 
https://salsa.debian.org/manphiz/dh-elpa/-/commit/1e59035004fd6d6ad12412ce0239ed6ef4abe93f
[3] 
https://salsa.debian.org/manphiz/dh-elpa/-/compare/master...nested-directory-support?from_project_id=18920

-- 
Xiyue Deng

From 1e59035004fd6d6ad12412ce0239ed6ef4abe93f Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manp...@gmail.com>
Date: Wed, 26 Jun 2024 17:37:41 -0700
Subject: [PATCH 1/4] Don't recursively add elpa path to match package.el
 behavior

* Add .nosearch to `/usr/share/emacs/site-lisp/elpa{,-src}' using
triggers in dh-elpa, which will disable subdirs.el from processing
those directories.
---
 debian/install | 1 +
 debian/rules   | 5 +++++
 2 files changed, 6 insertions(+)

diff --git a/debian/install b/debian/install
index d6e2470..fc4ef32 100644
--- a/debian/install
+++ b/debian/install
@@ -2,3 +2,4 @@ elpa.pm usr/share/perl5/Debian/Debhelper/Sequence
 emacsen-common usr/share/debhelper/dh_elpa
 autoscripts/prerm-elpa usr/share/debhelper/autoscripts
 usr/bin
+usr/share/emacs/site-lisp
diff --git a/debian/rules b/debian/rules
index c93d80f..474b500 100755
--- a/debian/rules
+++ b/debian/rules
@@ -6,6 +6,9 @@ DESTDIR=$(CURDIR)/debian/tmp
 # this is not needed, and only included as a test of the feature.
 ELPA_NAME_dh-elpa=dh-elpa
 
+# Sentinels to disable recursively adding to `load-path'.
+SITE_LISP_PATH=$(DESTDIR)/usr/share/emacs/site-lisp
+
 %:
 	dh $@
 
@@ -21,3 +24,5 @@ override_dh_install:
 override_dh_auto_install:
 	install -m 755 -D dh_elpa $(DESTDIR)/usr/bin/dh_elpa
 	install -m 755 -D dh_elpa_test $(DESTDIR)/usr/bin/dh_elpa_test
+	mkdir -p $(SITE_LISP_PATH)/elpa && touch $(SITE_LISP_PATH)/elpa/.nosearch
+	mkdir -p $(SITE_LISP_PATH)/elpa-src && touch $(SITE_LISP_PATH)/elpa-src/.nosearch
-- 
2.39.2

From 0ea18b198d06b11b854dfa7347e39e4e71001093 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manp...@gmail.com>
Date: Mon, 15 Apr 2024 13:03:16 -0700
Subject: [PATCH 2/4] Byte compile recursively during install to handle nested
 directories

* This handles addons that have source files under nested directories
in ELPA install directories.
---
 helper/install | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/helper/install b/helper/install
index 39db695..eb68ef5 100755
--- a/helper/install
+++ b/helper/install
@@ -58,7 +58,8 @@ echo "install/${ELPA_DIR}: byte-compiling for ${FLAVOR}"
  ${FLAVOR} --quick --batch -l package \
            --eval "(setq package-user-dir \"/nonexistent\")" \
            --eval "(add-to-list 'package-directory-list \"$src_dir\")" \
-           -f package-initialize -f batch-byte-compile ./*.el > Install.log 2>&1
+           -f package-initialize \
+           --eval "(byte-recompile-directory \".\" 0)" > Install.log 2>&1
  if test $? -ne 0
  then
    cat Install.log
-- 
2.39.2

From 71417bf830c76a21dfe84bb4b7d6be7fd7d04148 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manp...@gmail.com>
Date: Wed, 17 Apr 2024 14:06:42 -0700
Subject: [PATCH 3/4] Create symlink from elpa-src to elpa recursively

* Instead of using `ln -s', use `cp -rs' so that directories are
handled recursively.
* In remove we use `rmdir --ignore-fail-on-non-empty' so this was
handled automatically as well.
---
 helper/install | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/helper/install b/helper/install
index eb68ef5..8d748c8 100755
--- a/helper/install
+++ b/helper/install
@@ -50,7 +50,7 @@ echo "install/${ELPA_DIR}: byte-compiling for ${FLAVOR}"
 # policy).  This makes complation easy, and also allows find-function
 # and find-library to work properly.  Also link all other top level
 # files and directories into the flavor directory
-(cd "${elc_dir}" && ln -sf "${el_dir}"* .)
+(cd "${elc_dir}" && cp -rsf "${el_dir}"* .)
 
 # Byte compile them
 (cd "${elc_dir}"
-- 
2.39.2

From 427efab8b6a4f8ca950353066126c44ab57cad83 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manp...@gmail.com>
Date: Wed, 17 Apr 2024 14:17:41 -0700
Subject: [PATCH 4/4] Update d/changelog

---
 debian/changelog | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index c6211de..4b91ec7 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,12 @@ dh-elpa (2.1.2) UNRELEASED; urgency=medium
   * dh_elpa_test: Don't rename files under test/, tests/ (Closes:
     #1069326).
   * Use `pretty' stack frame style in buttercup for full back trace.
+  * Add support for nested directory in elpa installation (Closes:
+    #1069210).
+    - Don't recursively add elpa path to match package.el behavior.
+    - Byte compile recursively during install to handle nested
+      directories.
+    - Create symlink from elpa-src to elpa recursively.
 
   [ Aymeric Agon-Rambosson ]
   * Get Package-Requires with lm-header-multiline (some upstream
-- 
2.39.2

Attachment: signature.asc
Description: PGP signature

Reply via email to