[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1069210: dh-elpa: Support nested directory in elpa installation



Xiyue Deng <manphiz@gmail.com> writes:

> So it looks like `normal-top-level-add-subdirs-to-load-path' has a
> special handling that ignores directories with a `.nosearch' file.  I
> have added that to both elpa{,-src} and it seems to work as intended.
> So the next question is how/when to add those files.  Continuing to
> experiment.

And my experiment with triggers was successful.  This has the advantage
of not requiring package to be rebuilt compared with do the handling in
helper/install, but may be there are other ways.  Suggestions welcome.

I have update the implementation to the nest-directory-support branch in
my fork[1], and the patches series is attached.  Now inviting
maintainers to review.  Thanks in advance!

[1] https://salsa.debian.org/manphiz/dh-elpa/-/compare/master...nested-directory-support?from_project_id=18920

-- 
Xiyue Deng
From 6794099f62fecfdc19152b50170027fb021abdba Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manphiz@gmail.com>
Date: Mon, 20 May 2024 00:49:52 -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/dh-elpa.postinst | 29 +++++++++++++++++++++++++++++
 debian/dh-elpa.triggers |  2 ++
 2 files changed, 31 insertions(+)
 create mode 100644 debian/dh-elpa.postinst
 create mode 100644 debian/dh-elpa.triggers

diff --git a/debian/dh-elpa.postinst b/debian/dh-elpa.postinst
new file mode 100644
index 0000000..03b65cd
--- /dev/null
+++ b/debian/dh-elpa.postinst
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+set -e
+
+ensure_nosearch_in_elpa_directories() {
+    SITE_LISP_DIR=/usr/share/emacs/site-lisp
+    ELPA_SRC_NOSEARCH=${SITE_LISP_DIR}/elpa-src/.nosearch
+    ELPA_NOSEARCH=${SITE_LISP_DIR}/elpa/.nosearch
+    [ -f ${ELPA_SRC_NOSEARCH} ] || touch ${ELPA_SRC_NOSEARCH}
+    [ -f ${ELPA_NOSEARCH} ] || touch ${ELPA_NOSEARCH}
+}
+
+case "$1" in
+    configure)
+        ;;
+
+    triggered)
+        ensure_nosearch_in_elpa_directories
+        ;;
+
+    *)
+        echo "postinit called with argument \`$1' which is ignored." >&2
+        exit 1
+        ;;
+esac
+
+#DEBHELPER#
+
+exit 0
diff --git a/debian/dh-elpa.triggers b/debian/dh-elpa.triggers
new file mode 100644
index 0000000..ef84cb6
--- /dev/null
+++ b/debian/dh-elpa.triggers
@@ -0,0 +1,2 @@
+interest /usr/share/emacs/site-lisp/elpa-src
+interest /usr/share/emacs/site-lisp/elpa
-- 
2.39.2

From 5243f1f6908093c158840bf0f71cd64d25bbaa18 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manphiz@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 3fa7763ba5ddb5e177095e683ba55bddd341d364 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manphiz@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 1573475d02f9837b859fa6aec6ea01e00c69e751 Mon Sep 17 00:00:00 2001
From: Xiyue Deng <manphiz@gmail.com>
Date: Wed, 17 Apr 2024 14:17:41 -0700
Subject: [PATCH 4/4] Update d/changelog

---
 debian/changelog | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 3c9aa72..467fda1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -6,7 +6,14 @@ dh-elpa (2.1.2) UNRELEASED; urgency=medium
     backtrace info when ERT tests fail (Closes: #973393.)
   * Add support for passing ERT selectors using ert_selectors.
   * Handle git version with date in dhelpa-sanitise-version.
-  * dh_elpa_test: Don't rename files under test/, tests/ (Closes: #1069326).
+  * dh_elpa_test: Don't rename files under test/, tests/ (Closes:
+    #1069326).
+  * 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
@@ -14,7 +21,7 @@ dh-elpa (2.1.2) UNRELEASED; urgency=medium
   * Add transient to the list of packages packaged separately as well as
     provided with emacs.
 
- -- Xiyue Deng <manphiz@gmail.com>  Sat, 06 Apr 2024 16:41:14 -0700
+ -- Xiyue Deng <manphiz@gmail.com>  Wed, 17 Apr 2024 14:16:00 -0700
 
 dh-elpa (2.1.1) experimental; urgency=medium
 
-- 
2.39.2

Attachment: signature.asc
Description: PGP signature


Reply to: