enable package: emacs-x

Fixes https://github.com/termux/x11-packages/issues/251
This commit is contained in:
Leonid Pliushch 2021-08-25 14:46:27 +03:00 committed by Yaksh Bariya
parent adf80396dd
commit d5a1c06f10
No known key found for this signature in database
GPG Key ID: F7486BA7D3D27581
15 changed files with 395 additions and 0 deletions

View File

@ -0,0 +1,11 @@
--- ../Makefile.in.orig 2020-09-14 22:21:34.172699093 +0200
+++ ./Makefile.in 2020-09-15 21:43:19.212824716 +0200
@@ -365,7 +365,7 @@
sed < ${srcdir}/src/epaths.in > epaths.h.$$$$ \
-e 's;\(#.*PATH_LOADSEARCH\).*$$;\1 "${standardlisppath}";' \
-e 's;\(#.*PATH_SITELOADSEARCH\).*$$;\1 "${locallisppath}";' \
- -e 's;\(#.*PATH_DUMPLOADSEARCH\).*$$;\1 "${buildlisppath}";' \
+ -e 's;\(#.*PATH_DUMPLOADSEARCH\).*$$;\1 "${standardlisppath}";' \
-e '/^#define PATH_[^ ]*SEARCH /s/\([":]\):*/\1/g' \
-e '/^#define PATH_[^ ]*SEARCH /s/:"/"/' \
-e 's;\(#.*PATH_EXEC\).*$$;\1 "${archlibdir}";' \

View File

@ -0,0 +1,137 @@
TERMUX_PKG_HOMEPAGE=https://www.gnu.org/software/emacs/
TERMUX_PKG_DESCRIPTION="Extensible, customizable text editor-and more"
TERMUX_PKG_LICENSE="GPL-3.0"
TERMUX_PKG_MAINTAINER="@termux"
TERMUX_PKG_VERSION=27.2
TERMUX_PKG_SRCURL=https://ftp.gnu.org/gnu/emacs/emacs-${TERMUX_PKG_VERSION}.tar.xz
TERMUX_PKG_SHA256=b4a7cc4e78e63f378624e0919215b910af5bb2a0afc819fad298272e9f40c1b9
TERMUX_PKG_DEPENDS="fontconfig, freetype, gdk-pixbuf, giflib, glib, libgnutls, libice, libjpeg-turbo, libpng, librsvg, libsm, libtiff, libx11, libxaw, libxcb, libxext, libxfixes, libxft, libxinerama, libxml2, libxmu, libxpm, libxrandr, libxrender, libxt, littlecms, ncurses, zlib"
TERMUX_PKG_BREAKS="emacs-dev"
TERMUX_PKG_REPLACES="emacs-dev"
TERMUX_PKG_SERVICE_SCRIPT=("emacsd" 'exec emacs --fg-daemon 2>&1')
TERMUX_PKG_EXTRA_CONFIGURE_ARGS="
--disable-autodepend
--without-cairo
--without-imagemagick
--without-libotf
--without-xaw3d
--without-gpm
--without-dbus
--without-gconf
--without-gsettings
--with-x
--with-x-toolkit=lucid
--without-selinux
--with-modules
--with-pdumper=yes
--with-dumping=none
"
if $TERMUX_DEBUG_BUILD; then
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+="
--enable-checking=yes,glyphs
--enable-check-lisp-object-type
"
CFLAGS+=" -gdwarf-4"
fi
# Ensure use of system malloc:
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" emacs_cv_sanitize_address=yes"
# Prevent configure from adding -nopie:
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" emacs_cv_prog_cc_no_pie=no"
# Prevent linking against libelf:
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_lib_elf_elf_begin=no"
# implemented using dup3(), which fails if oldfd == newfd
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" gl_cv_func_dup2_works=no"
# disable setrlimit function to make termux-am work from within emacs
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" ac_cv_func_setrlimit=no"
if [ "$TERMUX_ARCH" == "arm" ] || [ "$TERMUX_ARCH" == "i686" ]; then
# setjmp does not work properly on 32bit android:
# https://github.com/termux/termux-packages/issues/2599
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" emacs_cv_func__setjmp=no"
TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" emacs_cv_func_sigsetjmp=no"
fi
TERMUX_PKG_HOSTBUILD=true
# Remove some irrelevant files:
TERMUX_PKG_RM_AFTER_INSTALL="
bin/grep-changelog
share/applications/emacs.desktop
share/emacs/${TERMUX_PKG_VERSION}/etc/emacs.desktop
share/emacs/${TERMUX_PKG_VERSION}/etc/emacs.icon
share/emacs/${TERMUX_PKG_VERSION}/etc/images
share/emacs/${TERMUX_PKG_VERSION}/etc/refcards
share/emacs/${TERMUX_PKG_VERSION}/etc/tutorials/TUTORIAL.*
share/icons
share/man/man1/grep-changelog.1.gz
"
# Remove ctags from the emacs package to prevent conflicting with
# the Universal Ctags from the 'ctags' package (the bin/etags
# program still remain in the emacs package):
TERMUX_PKG_RM_AFTER_INSTALL+=" bin/ctags share/man/man1/ctags.1 share/man/man1/ctags.1.gz"
termux_step_post_get_source() {
# 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
# Termux only use info pages for emacs. Remove the info directory
# to get a clean Info directory file dir.
rm -Rf $TERMUX_PREFIX/share/info
}
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
mkdir -p $NATIVE_PREFIX/share/emacs/$TERMUX_PKG_VERSION
ln -s $TERMUX_PKG_SRCDIR/lisp $NATIVE_PREFIX/share/emacs/$TERMUX_PKG_VERSION/lisp
( cd $TERMUX_PKG_SRCDIR; ./autogen.sh )
$TERMUX_PKG_SRCDIR/configure --prefix=$NATIVE_PREFIX --without-all --without-x
make -j $TERMUX_MAKE_PROCESSES
}
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
cp $TERMUX_PKG_HOSTBUILD_DIR/lib-src/make-fingerprint $TERMUX_PKG_BUILDDIR/lib-src/make-fingerprint
# Update timestamps so that the binaries does not get rebuilt:
touch -d "next hour" $TERMUX_PKG_BUILDDIR/src/bootstrap-emacs \
$TERMUX_PKG_BUILDDIR/lib-src/make-docfile \
$TERMUX_PKG_BUILDDIR/lib-src/make-fingerprint
}
termux_step_post_make_install() {
cp $TERMUX_PKG_BUILDER_DIR/site-init.el $TERMUX_PREFIX/share/emacs/${TERMUX_PKG_VERSION}/lisp/emacs-lisp/
}
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
cd $TERMUX_PREFIX/share/emacs/$TERMUX_PKG_VERSION/lisp
LC_ALL=C $TERMUX_PREFIX/bin/emacs -batch -l loadup --temacs=pdump
mv $TERMUX_PREFIX/bin/emacs*.pdmp $TERMUX_PREFIX/libexec/emacs/$TERMUX_PKG_VERSION/${TERMUX_ARCH}-linux-android*/
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
}

View File

@ -0,0 +1,34 @@
diff -uNr emacs-27.2/src/emacs.c emacs-27.2.mod/src/emacs.c
--- emacs-27.2/src/emacs.c 2021-01-28 19:52:38.000000000 +0200
+++ emacs-27.2.mod/src/emacs.c 2021-04-10 17:04:56.744343967 +0300
@@ -120,6 +120,11 @@
#include "pdumper.h"
#include "epaths.h"
+#ifdef __ANDROID__
+#include <android/fdsan.h>
+#include <dlfcn.h>
+#endif
+
static const char emacs_version[] = PACKAGE_VERSION;
static const char emacs_copyright[] = COPYRIGHT;
static const char emacs_bugreport[] = PACKAGE_BUGREPORT;
@@ -954,6 +959,18 @@
/* Record (approximately) where the stack begins. */
stack_bottom = (char *) &stack_bottom_variable;
+#ifdef __ANDROID__
+ // For Android 11+.
+ void *lib_handle = dlopen("libc.so", RTLD_LAZY);
+ if (lib_handle) {
+ void (*set_fdsan_error_level)(enum android_fdsan_error_level newlevel) = dlsym(lib_handle, "android_fdsan_set_error_level");
+ if (set_fdsan_error_level) {
+ set_fdsan_error_level(ANDROID_FDSAN_ERROR_LEVEL_DISABLED);
+ }
+ dlclose(lib_handle);
+ }
+#endif
+
const char *dump_mode = NULL;
int skip_args = 0;
char *temacs = NULL;

View File

@ -0,0 +1,20 @@
--- ./lib-src/emacsclient.c.orig 2020-07-29 23:40:41.000000000 +0200
+++ ./lib-src/emacsclient.c 2020-09-14 21:36:04.883963456 +0200
@@ -1411,7 +1411,7 @@
tmpdirlen = min (n - 1, socknamesize);
# endif
if (tmpdirlen < 0)
- tmpdirlen = snprintf (sockname, socknamesize, "/tmp");
+ tmpdirlen = snprintf (sockname, socknamesize, "@TERMUX_PREFIX@/tmp");
}
socknamelen = local_sockname (sockname, socknamesize, tmpdirlen,
uid, server_name);
@@ -1495,7 +1495,7 @@
uintmax_t id = uid;
char sockdirname[socknamesize];
int sockdirnamelen = snprintf (sockdirname, sizeof sockdirname,
- "/run/user/%"PRIuMAX, id);
+ "@TERMUX_PREFIX@/var/run/user/%"PRIuMAX, id);
if (0 <= sockdirnamelen && sockdirnamelen < sizeof sockdirname
&& faccessat (AT_FDCWD, sockdirname, X_OK, AT_EACCESS) == 0)
message

View File

@ -0,0 +1,11 @@
--- ./lisp/cus-start.el.orig 2020-07-27 23:21:49.000000000 +0200
+++ ./lisp/cus-start.el 2020-09-14 21:34:59.583435440 +0200
@@ -290,7 +290,7 @@
"/tmp"))
(t
(or (getenv "TMPDIR") (getenv "TMP") (getenv "TEMP")
- "/tmp"))))
+ "@TERMUX_PREFIX@/tmp"))))
:initialize custom-initialize-delay)
;; fns.c
(use-dialog-box menu boolean "21.1")

View File

@ -0,0 +1,15 @@
--- ./lisp/loadup.el.orig 2020-07-27 23:21:49.000000000 +0200
+++ ./lisp/loadup.el 2020-09-14 21:34:59.586768800 +0200
@@ -423,7 +423,11 @@
(message "Warning: Change in load-path due to site-init will be \
lost after dumping")))
-(setq current-load-list nil)
+;; On an emacs that runs undumped, i.e. Android, this causes bogus
+;; entries to appear in load-history. Commenting this out causes an entry
+;; for loadup.el with a bogus filename to appear instead, but since it
+;; neither provides nor requires anything, it appears to be safe.
+;;(setq current-load-list nil)
;; Avoid storing references to build directory in the binary.
(setq custom-current-group-alist nil)

View File

@ -0,0 +1,11 @@
--- ./lisp/net/tramp.el.orig 2020-07-29 23:40:41.000000000 +0200
+++ ./lisp/net/tramp.el 2020-09-14 21:34:59.593435521 +0200
@@ -133,7 +133,7 @@
;; Suppress `shell-file-name' for w32 systems.
(defcustom tramp-encoding-shell
(let (shell-file-name)
- (or (tramp-compat-funcall 'w32-shell-name) "/bin/sh"))
+ (or (tramp-compat-funcall 'w32-shell-name) "@TERMUX_PREFIX@/bin/sh"))
"Use this program for encoding and decoding commands on the local host.
This shell is used to execute the encoding and decoding command on the
local host, so if you want to use \"~\" in those commands, you should

View File

@ -0,0 +1,11 @@
--- ./lisp/server.el.orig 2019-11-28 10:49:15.353433913 +0100
+++ ./lisp/server.el 2019-11-28 10:50:18.741175439 +0100
@@ -277,7 +277,7 @@
(let ((xdg_runtime_dir (getenv "XDG_RUNTIME_DIR")))
(if xdg_runtime_dir
(format "%s/emacs" xdg_runtime_dir)
- (format "%s/emacs%d" (or (getenv "TMPDIR") "/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.")

View File

@ -0,0 +1,11 @@
--- ./lisp/term.el.orig 2019-11-28 10:52:45.633666279 +0100
+++ ./lisp/term.el 2019-11-28 10:53:51.234778668 +0100
@@ -1558,7 +1558,7 @@
(push (format "EMACS=%s (term:%s)" emacs-version term-protocol-version)
process-environment))
(apply #'start-process name buffer
- "/bin/sh" "-c"
+ "@TERMUX_PREFIX@/bin/sh" "-c"
(format "stty -nl echo rows %d columns %d sane 2>/dev/null;\
if [ $1 = .. ]; then shift; fi; exec \"$@\""
term-height term-width)

View File

@ -0,0 +1,37 @@
diff -u -r ../emacs-26.2/lisp/textmodes/ispell.el ./lisp/textmodes/ispell.el
--- ../emacs-26.2/lisp/textmodes/ispell.el 2019-02-20 13:44:42.000000000 +0000
+++ ./lisp/textmodes/ispell.el 2019-04-14 18:15:07.894909566 +0000
@@ -215,14 +215,14 @@
:group 'ispell)
(defcustom ispell-alternate-dictionary
- (cond ((file-readable-p "/usr/dict/web2") "/usr/dict/web2")
- ((file-readable-p "/usr/share/dict/web2") "/usr/share/dict/web2")
- ((file-readable-p "/usr/dict/words") "/usr/dict/words")
- ((file-readable-p "/usr/lib/dict/words") "/usr/lib/dict/words")
- ((file-readable-p "/usr/share/dict/words") "/usr/share/dict/words")
- ((file-readable-p "/usr/share/lib/dict/words")
- "/usr/share/lib/dict/words")
- ((file-readable-p "/sys/dict") "/sys/dict"))
+ (cond ((file-readable-p "@TERMUX_PREFIX@/dict/web2") "/usr/dict/web2")
+ ((file-readable-p "@TERMUX_PREFIX@/share/dict/web2") "/usr/share/dict/web2")
+ ((file-readable-p "@TERMUX_PREFIX@/dict/words") "/usr/dict/words")
+ ((file-readable-p "@TERMUX_PREFIX@/lib/dict/words") "/usr/lib/dict/words")
+ ((file-readable-p "@TERMUX_PREFIX@/share/dict/words") "/usr/share/dict/words")
+ ((file-readable-p "@TERMUX_PREFIX@/share/lib/dict/words")
+ "@TERMUX_PREFIX@/share/lib/dict/words")
+ ((file-readable-p "@TERMUX_PREFIX@/sys/dict") "@TERMUX_PREFIX@/sys/dict"))
"Alternate plain word-list dictionary for spelling help."
:type '(choice file (const :tag "None" nil))
:group 'ispell)
@@ -266,9 +266,7 @@
:group 'ispell)
(defcustom ispell-look-command
- (cond ((file-exists-p "/bin/look") "/bin/look")
- ((file-exists-p "/usr/local/bin/look") "/usr/local/bin/look")
- ((file-exists-p "/usr/bin/look") "/usr/bin/look")
+ (cond ((file-exists-p "@TERMUX_PREFIX@/bin/look") "@TERMUX_PREFIX@/bin/look")
(t "look"))
"Name of the look command for search processes.
This must be an absolute file name."

View File

@ -0,0 +1,11 @@
--- ./src/editfns.c.orig 2020-07-29 23:40:42.000000000 +0200
+++ ./src/editfns.c 2020-09-14 21:36:04.890630177 +0200
@@ -1250,7 +1250,7 @@
if (!pw)
return Qnil;
- p = USER_FULL_NAME;
+ p = "unknown";
/* Chop off everything after the first comma. */
q = strchr (p, ',');
full = make_string (p, q ? q - p : strlen (p));

View File

@ -0,0 +1,4 @@
; Enable terminal mouse events:
(xterm-mouse-mode 1)
(global-set-key [mouse-4] 'scroll-down-line)
(global-set-key [mouse-5] 'scroll-up-line)

View File

@ -0,0 +1,11 @@
--- ./src/callproc.c.orig 2020-07-29 23:40:42.000000000 +0200
+++ ./src/callproc.c 2020-09-14 21:36:04.897296897 +0200
@@ -1621,7 +1621,7 @@
dir_warning ("arch-independent data dir", Vdata_directory);
sh = getenv ("SHELL");
- Vshell_file_name = build_string (sh ? sh : "/bin/sh");
+ Vshell_file_name = build_string (sh ? sh : "@TERMUX_PREFIX@/bin/sh");
Lisp_Object gamedir = Qnil;
if (PATH_GAME)

View File

@ -0,0 +1,20 @@
--- ../fileio.c.orig 2020-07-11 20:22:17.937310671 +0200
+++ ./src/fileio.c 2020-07-11 20:22:44.147310684 +0200
@@ -2617,7 +2617,7 @@
encoded_file = ENCODE_FILE (file);
encoded_newname = ENCODE_FILE (newname);
- if (link (SSDATA (encoded_file), SSDATA (encoded_newname)) == 0)
+ if (symlink (SSDATA (encoded_file), SSDATA (encoded_newname)) == 0)
return Qnil;
if (errno == EEXIST)
@@ -2627,7 +2627,7 @@
barf_or_query_if_file_exists (newname, true, "make it a new name",
FIXNUMP (ok_if_already_exists), false);
unlink (SSDATA (newname));
- if (link (SSDATA (encoded_file), SSDATA (encoded_newname)) == 0)
+ if (symlink (SSDATA (encoded_file), SSDATA (encoded_newname)) == 0)
return Qnil;
}

View File

@ -0,0 +1,51 @@
--- ../emacs-27/src/filelock.c 2019-11-28 09:41:28.000000000 +0100
+++ ./src/filelock.c 2019-11-28 15:07:18.792543698 +0100
@@ -63,11 +63,11 @@
/* A file whose last-modified time is just after the most recent boot.
Define this to be NULL to disable checking for this file. */
#ifndef BOOT_TIME_FILE
-#define BOOT_TIME_FILE "/var/run/random-seed"
+#define BOOT_TIME_FILE "@TERMUX_PREFIX@/var/run/random-seed"
#endif
#if !defined WTMP_FILE && !defined WINDOWSNT
-#define WTMP_FILE "/var/log/wtmp"
+#define WTMP_FILE "@TERMUX_PREFIX@/var/log/wtmp"
#endif
/* Normally use a symbolic link to represent a lock.
@@ -127,14 +127,14 @@
static time_t boot_time;
static bool boot_time_initialized;
-#ifdef BOOT_TIME
+#if defined (BOOT_TIME) && !defined(__ANDROID__)
static void get_boot_time_1 (const char *, bool);
#endif
static time_t
get_boot_time (void)
{
-#if defined (BOOT_TIME)
+#if defined (BOOT_TIME) && !defined(__ANDROID__)
int counter;
#endif
@@ -170,7 +170,7 @@
}
}
-#if defined (BOOT_TIME)
+#if defined (BOOT_TIME) && !defined(__ANDROID__)
/* The utmp routines maintain static state. Don't touch that state
if we are going to dump, since it might not survive dumping. */
if (will_dump_p ())
@@ -229,7 +229,7 @@
#endif
}
-#ifdef BOOT_TIME
+#if defined (BOOT_TIME) && !defined(__ANDROID__)
/* Try to get the boot time from wtmp file FILENAME.
This succeeds if that file contains a reboot record.