diff --git a/x11-packages/emacs-x/build.sh b/x11-packages/emacs-x/build.sh index ee44f2f2c..f12d1a79b 100644 --- a/x11-packages/emacs-x/build.sh +++ b/x11-packages/emacs-x/build.sh @@ -2,14 +2,14 @@ TERMUX_PKG_HOMEPAGE=https://www.gnu.org/software/emacs/ TERMUX_PKG_DESCRIPTION="Extensible, customizable text editor-and more (with X11 support)" TERMUX_PKG_LICENSE="GPL-3.0" TERMUX_PKG_MAINTAINER="Leonid Plyushch " -TERMUX_PKG_VERSION=26.2 -TERMUX_PKG_REVISION=7 +TERMUX_PKG_VERSION=26.3 TERMUX_PKG_SRCURL=https://mirrors.kernel.org/gnu/emacs/emacs-${TERMUX_PKG_VERSION}.tar.xz -TERMUX_PKG_SHA256=151ce69dbe5b809d4492ffae4a4b153b2778459de6deb26f35691e1281a9c58e +TERMUX_PKG_SHA256=4d90e6751ad8967822c6e092db07466b9d383ef1653feb2f95c93e7de66d3485 TERMUX_PKG_DEPENDS="atk, fontconfig, freetype, gdk-pixbuf, giflib, glib, gtk3, libandroid-shmem, libcairo-x, libgnutls, libice, libjpeg-turbo, libpng, librsvg, libsm, libtiff, libx11, libxcb, libxext, libxfixes, libxft, libxinerama, libxml2, libxpm, libxrandr, libxrender, littlecms, ncurses, pango-x, zlib" TERMUX_PKG_CONFLICTS="emacs" TERMUX_PKG_REPLACES="emacs" TERMUX_PKG_PROVIDES="emacs" +TERMUX_PKG_CONFFILES="var/service/emacsd/run var/service/emacsd/log/run" TERMUX_PKG_HOSTBUILD=true # Remove some irrelevant files: @@ -51,6 +51,12 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" gl_cv_func_dup2_works=no" TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_setrlimit=no" termux_step_post_extract_package() { + # Certain packages are not safe to build on device because their + # build.sh script deletes specific files in $TERMUX_PREFIX. + if $TERMUX_ON_DEVICE_BUILD; then + termux_error_exit "Package '$TERMUX_PKG_NAME' is not safe for on-device builds." + fi + # XXX: We have to start with new host build each time # to avoid build error when cross compiling. rm -Rf $TERMUX_PKG_HOSTBUILD_DIR @@ -65,10 +71,6 @@ termux_step_post_extract_package() { export CANNOT_DUMP=yes } -termux_step_pre_configure() { - export LIBS="-landroid-shmem" -} - termux_step_host_build() { # Build a bootstrap-emacs binary to be used in termux_step_post_configure. local NATIVE_PREFIX=$TERMUX_PKG_TMPDIR/emacs-native @@ -79,6 +81,10 @@ termux_step_host_build() { make -j $TERMUX_MAKE_PROCESSES } +ermux_step_pre_configure() { + export LIBS="-landroid-shmem" +} + termux_step_post_configure() { cp $TERMUX_PKG_HOSTBUILD_DIR/src/bootstrap-emacs $TERMUX_PKG_BUILDDIR/src/bootstrap-emacs cp $TERMUX_PKG_HOSTBUILD_DIR/lib-src/make-docfile $TERMUX_PKG_BUILDDIR/lib-src/make-docfile @@ -88,4 +94,36 @@ termux_step_post_configure() { termux_step_post_make_install() { cp $TERMUX_PKG_BUILDER_DIR/site-init.el $TERMUX_PREFIX/share/emacs/${TERMUX_PKG_VERSION}/lisp/emacs-lisp/ + + # Setup emacs --daemon service script + mkdir -p $TERMUX_PREFIX/var/service + cd $TERMUX_PREFIX/var/service + mkdir -p emacsd/log + echo "#!$TERMUX_PREFIX/bin/sh" > emacsd/run + echo 'exec emacs --fg-daemon 2>&1' >> emacsd/run + chmod +x emacsd/run + touch emacsd/down + + ln -sf $TERMUX_PREFIX/share/termux-services/svlogger emacsd/log/run +} + +termux_step_create_debscripts() { + cat <<- EOF > ./postinst + #!$TERMUX_PREFIX/bin/sh + if [ "\$1" = "configure" ] || [ "\$1" = "abort-upgrade" ]; then + if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then + update-alternatives --install \ + $TERMUX_PREFIX/bin/editor editor $TERMUX_PREFIX/bin/emacs 40 + fi + fi + EOF + + cat <<- EOF > ./prerm + #!$TERMUX_PREFIX/bin/sh + if [ "\$1" != "upgrade" ]; then + if [ -x "$TERMUX_PREFIX/bin/update-alternatives" ]; then + update-alternatives --remove editor $TERMUX_PREFIX/bin/emacs + fi + fi + EOF } diff --git a/x11-packages/emacs-x/lib-src-emacsclient.c.patch b/x11-packages/emacs-x/lib-src-emacsclient.c.patch index c5b1acd83..c779f18b7 100644 --- a/x11-packages/emacs-x/lib-src-emacsclient.c.patch +++ b/x11-packages/emacs-x/lib-src-emacsclient.c.patch @@ -1,12 +1,18 @@ -diff -u -r ../emacs-25.0.92/lib-src/emacsclient.c ./lib-src/emacsclient.c ---- ../emacs-25.0.92/lib-src/emacsclient.c 2016-03-02 05:21:42.000000000 -0500 -+++ ./lib-src/emacsclient.c 2016-04-09 01:28:10.881760020 -0400 -@@ -1210,7 +1210,7 @@ +--- ../emacsclient.c.orig 2019-08-29 20:08:48.840624090 +0200 ++++ ./lib-src/emacsclient.c 2019-08-29 20:13:37.425382182 +0200 +@@ -1289,11 +1289,12 @@ } else #endif - tmpdir = "/tmp"; + tmpdir = "@TERMUX_PREFIX@/tmp"; } ++ /* Use $PREFIX/var/run instead of $TMPDIR in termux. */ socket_name_storage = - xmalloc (strlen (tmpdir) + strlen (server_name) + EXTRA_SPACE); +- xmalloc (strlen (tmpdir) + strlen (server_name) + EXTRA_SPACE); +- char *z = stpcpy (socket_name_storage, tmpdir); ++ xmalloc (strlen ("@TERMUX_PREFIX@/var/run") + strlen (server_name) + EXTRA_SPACE); ++ char *z = stpcpy (socket_name_storage, "@TERMUX_PREFIX@/var/run"); + z += sprintf (z, "/emacs%ld/", uid); + strcpy (z, server_name); + local_socket_name = socket_name_storage; diff --git a/x11-packages/emacs-x/lisp-server.el.patch.beforehostbuild b/x11-packages/emacs-x/lisp-server.el.patch.beforehostbuild index b57f6d608..162852a16 100644 --- a/x11-packages/emacs-x/lisp-server.el.patch.beforehostbuild +++ b/x11-packages/emacs-x/lisp-server.el.patch.beforehostbuild @@ -6,7 +6,7 @@ diff -u -r ../emacs-25.0.92/lisp/server.el ./lisp/server.el (defvar server-socket-dir (and (featurep 'make-network-process '(:family local)) - (format "%s/emacs%d" (or (getenv "TMPDIR") "/tmp") (user-uid))) -+ (format "%s/emacs%d" (or (getenv "TMPDIR") "@TERMUX_PREFIX@/tmp") (user-uid))) ++ (format "%s/emacs%d" "@TERMUX_PREFIX@/var/run" (user-uid))) "The directory in which to place the server socket. If local sockets are not supported, this is nil.")