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

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



I made another change to dh-elpa enabling better back trace for
buttercup tests, so here is the refreshed patchset.  TIA!

-- 
Xiyue Deng

From cc40a88155029834673a944e1a822ff3b97613ca 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 | 35 +++++++++++++++++++++++++++++++++++
 debian/dh-elpa.triggers |  2 ++
 2 files changed, 37 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..7f2e52d
--- /dev/null
+++ b/debian/dh-elpa.postinst
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+set -e
+
+ensure_nosearch_in_elpa_directories() {
+    # Currently there is subdirs.el in `/usr/share/emacs/site-lisp' which causes
+    # all subdirectories to be added to `load-path' including elpa installation
+    # directories.  This differs from how package.el handles ELPA packages which
+    # only adds the installation root directory.  Here we add `.nosearch' to
+    # elpa directories to let subdirs.el skip them to follow the package.el
+    # behavior.
+    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 111a07a86a3aa163d6e4da51c3e6389516f2b985 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 795c82f5c80fc5665905d3763163bef03e8854ca 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 374983204ec273c557306821bfce0cbfb0950722 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 | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/debian/changelog b/debian/changelog
index be10246..e385f81 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 to: