From eb197dcf1c93a9c6dfe241f126473bde64d38f10 Mon Sep 17 00:00:00 2001 From: Tee KOBAYASHI Date: Sun, 19 Dec 2021 09:03:55 +0900 Subject: [PATCH 1/2] new package: gauche --- packages/gauche/build.sh | 47 +++++++++++++++++++ packages/gauche/configure.ac.patch | 10 ++++ packages/gauche/ext-Makefile.ext.in.patch | 11 +++++ packages/gauche/ext-dbm-Makefile.in.patch | 14 ++++++ packages/gauche/ext-text-gettext.scm.patch | 11 +++++ packages/gauche/ext-tls-gauche-tls.h.patch | 14 ++++++ packages/gauche/fake-ndbm-makedb.c | 24 ++++++++++ packages/gauche/gc-os_dep.c.patch | 11 +++++ .../gauche/lib-gauche-configure.scm.patch | 31 ++++++++++++ .../lib-gauche-interactive-toplevel.scm.patch | 11 +++++ .../gauche/lib-gauche-package-util.scm.patch | 11 +++++ .../gauche/libsrc-gauche-process.scm.patch | 11 +++++ packages/gauche/src-libsys.c.patch | 11 +++++ packages/gauche/src-libsys.scm.patch | 11 +++++ packages/gauche/src-system.c.patch | 11 +++++ 15 files changed, 239 insertions(+) create mode 100644 packages/gauche/build.sh create mode 100644 packages/gauche/configure.ac.patch create mode 100644 packages/gauche/ext-Makefile.ext.in.patch create mode 100644 packages/gauche/ext-dbm-Makefile.in.patch create mode 100644 packages/gauche/ext-text-gettext.scm.patch create mode 100644 packages/gauche/ext-tls-gauche-tls.h.patch create mode 100644 packages/gauche/fake-ndbm-makedb.c create mode 100644 packages/gauche/gc-os_dep.c.patch create mode 100644 packages/gauche/lib-gauche-configure.scm.patch create mode 100644 packages/gauche/lib-gauche-interactive-toplevel.scm.patch create mode 100644 packages/gauche/lib-gauche-package-util.scm.patch create mode 100644 packages/gauche/libsrc-gauche-process.scm.patch create mode 100644 packages/gauche/src-libsys.c.patch create mode 100644 packages/gauche/src-libsys.scm.patch create mode 100644 packages/gauche/src-system.c.patch diff --git a/packages/gauche/build.sh b/packages/gauche/build.sh new file mode 100644 index 00000000000000..d1d75c48760513 --- /dev/null +++ b/packages/gauche/build.sh @@ -0,0 +1,47 @@ +TERMUX_PKG_HOMEPAGE=https://practical-scheme.net/gauche/ +TERMUX_PKG_DESCRIPTION="An R7RS Scheme implementation developed to be a handy script interpreter" +TERMUX_PKG_LICENSE="BSD 3-Clause" +TERMUX_PKG_MAINTAINER="@termux" +TERMUX_PKG_VERSION=0.9.10 +TERMUX_PKG_SRCURL=https://github.com/shirok/Gauche/releases/download/release${TERMUX_PKG_VERSION//./_}/Gauche-${TERMUX_PKG_VERSION}.tgz +TERMUX_PKG_SHA256=0f39df1daec56680b542211b085179cb22e8220405dae15d9d745c56a63a2532 +TERMUX_PKG_DEPENDS="binutils, ca-certificates, gdbm, libcrypt, libiconv, mbedtls, zlib" +TERMUX_PKG_HOSTBUILD=true + +TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" +--with-ca-bundle=$TERMUX_PREFIX/etc/tls/cert.pem +--with-libatomic-ops=no +--with-slib=$TERMUX_PREFIX/share/slib +" +# 0.9.10 does not support MbedTLS 3.0: remove --with-tls=... when updating +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-tls=axtls" + +termux_step_host_build() { + _PREFIX_FOR_BUILD=$TERMUX_PKG_HOSTBUILD_DIR/prefix + mkdir -p $_PREFIX_FOR_BUILD + "$TERMUX_PKG_SRCDIR"/configure --prefix=$_PREFIX_FOR_BUILD + make -j $TERMUX_MAKE_PROCESSES + make install +} + +termux_step_pre_configure() { + cp $TERMUX_PKG_BUILDER_DIR/fake-ndbm-makedb.c "$TERMUX_PKG_SRCDIR"/ext/dbm/ + + export BUILD_GOSH=$_PREFIX_FOR_BUILD/bin/gosh + export PATH=$PATH:$_PREFIX_FOR_BUILD/bin + + _NEED_DUMMY_LIBPTHREAD_A= + _LIBPTHREAD_A=$TERMUX_PREFIX/lib/libpthread.a + if [ ! -e $_LIBPTHREAD_A ]; then + _NEED_DUMMY_LIBPTHREAD_A=true + echo '!' > $_LIBPTHREAD_A + fi + + autoreconf -fi +} + +termux_step_post_make_install() { + if [ $_NEED_DUMMY_LIBPTHREAD_A ]; then + rm -f $_LIBPTHREAD_A + fi +} diff --git a/packages/gauche/configure.ac.patch b/packages/gauche/configure.ac.patch new file mode 100644 index 00000000000000..50549ed776600e --- /dev/null +++ b/packages/gauche/configure.ac.patch @@ -0,0 +1,10 @@ +--- a/configure.ac ++++ b/configure.ac +@@ -770,6 +770,7 @@ + SHLIB_MAIN_LDFLAGS="" + SHLIB_OK=unknown + ]) ++AS_CASE([$host], [*-android*], [ext_use_libgauche=yes]) + AS_IF([test -z "$SHLIB_DYLIB_LDFLAGS"], + [SHLIB_DYLIB_LDFLAGS=$SHLIB_SO_LDFLAGS]) + AS_IF([test -z "$SHLIB_DYLIB_SUFFIX"], diff --git a/packages/gauche/ext-Makefile.ext.in.patch b/packages/gauche/ext-Makefile.ext.in.patch new file mode 100644 index 00000000000000..a5a21532d1eedd --- /dev/null +++ b/packages/gauche/ext-Makefile.ext.in.patch @@ -0,0 +1,11 @@ +--- a/ext/Makefile.ext.in ++++ b/ext/Makefile.ext.in +@@ -22,7 +22,7 @@ + LIBS = $(XLIBS) @LIBS@ + CFLAGS = @CFLAGS@ @SHLIB_SO_CFLAGS@ $(XCFLAGS) + CPPFLAGS = @CPPFLAGS@ $(XCPPFLAGS) +-LDFLAGS = $(LOCAL_LFLAGS) $(XLDFLAGS) @SHLIB_SO_LDFLAGS@ ++LDFLAGS = $(LOCAL_LFLAGS) $(XLDFLAGS) @LDFLAGS@ @SHLIB_SO_LDFLAGS@ + BUILD_GOSH_FLAGS = + + # These are set by configure diff --git a/packages/gauche/ext-dbm-Makefile.in.patch b/packages/gauche/ext-dbm-Makefile.in.patch new file mode 100644 index 00000000000000..5fc2bb2f7625cf --- /dev/null +++ b/packages/gauche/ext-dbm-Makefile.in.patch @@ -0,0 +1,14 @@ +--- a/ext/dbm/Makefile.in ++++ b/ext/dbm/Makefile.in +@@ -46,9 +46,8 @@ + + + # auxiliary stuff to find out the extension of ndbm file(s). +-ndbm-makedb : ndbm-makedb.c +- $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -o ndbm-makedb \ +- $(srcdir)/ndbm-makedb.c $(LOCAL_LFLAGS) $(XLDFLAGS) @NDBMLIB@ $(LIBS) ++ndbm-makedb : fake-ndbm-makedb.c ++ $(CC_FOR_BUILD) -o ndbm-makedb $(srcdir)/fake-ndbm-makedb.c + + ndbm-suffixes.h : ndbm-makedb ndbm-suffixes.scm + $(GOSH) $(srcdir)/ndbm-suffixes.scm ndbm-suffixes.h diff --git a/packages/gauche/ext-text-gettext.scm.patch b/packages/gauche/ext-text-gettext.scm.patch new file mode 100644 index 00000000000000..e31b877291cdd2 --- /dev/null +++ b/packages/gauche/ext-text-gettext.scm.patch @@ -0,0 +1,11 @@ +--- a/ext/text/gettext.scm ++++ b/ext/text/gettext.scm +@@ -88,7 +88,7 @@ + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; Customize this to the appropriate value for your system: + +-(define message-path '("/usr/share/locale")) ++(define message-path '("@TERMUX_PREFIX@/share/locale")) + + ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + ;; store meta info for gettext files diff --git a/packages/gauche/ext-tls-gauche-tls.h.patch b/packages/gauche/ext-tls-gauche-tls.h.patch new file mode 100644 index 00000000000000..61e50f42b3befe --- /dev/null +++ b/packages/gauche/ext-tls-gauche-tls.h.patch @@ -0,0 +1,14 @@ +--- a/ext/tls/gauche-tls.h ++++ b/ext/tls/gauche-tls.h +@@ -47,10 +47,7 @@ + + /* We try these paths to find ca certs on Unix-like platforms */ + #define SYSTEM_CA_CERT_PATHS \ +- "/etc/ssl/certs/ca-certificates.crt", /* ubnutu */ \ +- "/usr/share/pki/ca-trust-source/ca-bundle.trust.crt", /* fedora */ \ +- "/etc/pki/tls/certs/ca-budle.crt", /* fedora (compat) */ \ +- "/usr/local/etc/openssl/cert.pem" /* osx homebrew openssl */ ++ "@TERMUX_PREFIX@/etc/tls/cert.pem" + + #if defined(GAUCHE_USE_AXTLS) + #include "axTLS/ssl/ssl.h" diff --git a/packages/gauche/fake-ndbm-makedb.c b/packages/gauche/fake-ndbm-makedb.c new file mode 100644 index 00000000000000..f1e1d25a6e71d0 --- /dev/null +++ b/packages/gauche/fake-ndbm-makedb.c @@ -0,0 +1,24 @@ + +#include +#include + +#define PATHMAX 1023 + +int +main(int argc, char **argv) +{ + char pathname[PATHMAX+1]; + char *suffixes[] = { ".dir", ".peg" }; + + if (argc != 2 || strlen(argv[1]) + strlen(suffixes[0]) > sizeof(pathname)-1) + return 1; + + for (size_t i = 0; i < sizeof(suffixes) / sizeof(char *); i++) { + strncpy(pathname, argv[1], sizeof(pathname)-1); + strncat(pathname, suffixes[i], sizeof(pathname)-1); + if (creat(pathname, 0777) < 0) + return 1; + } + + return 0; +} diff --git a/packages/gauche/gc-os_dep.c.patch b/packages/gauche/gc-os_dep.c.patch new file mode 100644 index 00000000000000..891ef7fd1850b9 --- /dev/null +++ b/packages/gauche/gc-os_dep.c.patch @@ -0,0 +1,11 @@ +--- a/gc/os_dep.c ++++ b/gc/os_dep.c +@@ -4737,7 +4737,7 @@ + /* There are faster ways to do this, but hopefully this */ + /* isn't time critical. */ + (void)snprintf(cmd_buf, sizeof(cmd_buf), +- "/usr/bin/addr2line -f -e %s 0x%lx", ++ "@TERMUX_PREFIX@/bin/addr2line -f -e %s 0x%lx", + exe_name, (unsigned long)info[i].ci_pc); + cmd_buf[sizeof(cmd_buf) - 1] = '\0'; + old_preload = GETENV("LD_PRELOAD"); diff --git a/packages/gauche/lib-gauche-configure.scm.patch b/packages/gauche/lib-gauche-configure.scm.patch new file mode 100644 index 00000000000000..19b0ae0c432c18 --- /dev/null +++ b/packages/gauche/lib-gauche-configure.scm.patch @@ -0,0 +1,31 @@ +--- a/lib/gauche/configure.scm ++++ b/lib/gauche/configure.scm +@@ -305,16 +305,16 @@ + (cf-define 'PACKAGE_BUGREPORT (S (~ p'bug-report))) + (cf-define 'PACKAGE_URL (S (~ p'url))) + +- (cf-subst 'SHELL (or (sys-getenv "CONFIG_SHELL") "/bin/sh")) ++ (cf-subst 'SHELL (or (sys-getenv "CONFIG_SHELL") "@TERMUX_PREFIX@/bin/sh")) + (cf-subst 'LIBOBJS "") + (cf-subst 'MFLAGS "") + (cf-subst 'MAKEFLAGS "") + +- (cf-subst 'default_prefix "/usr/local") ++ (cf-subst 'default_prefix "@TERMUX_PREFIX@") + (cf-subst 'prefix "NONE") ;will be replaced by cf-output + (cf-subst 'exec_prefix "NONE") ;will be replaced by cf-output + (cf-subst 'bindir "${exec_prefix}/bin") +- (cf-subst 'sbindir "${exec_prefix}/sbin") ++ (cf-subst 'sbindir "${exec_prefix}/bin") + (cf-subst 'libexecdir "${exec_prefix}/libexec") + (cf-subst 'datarootdir "${prefix}/share") + (cf-subst 'datadir "${datarootdir}") +@@ -322,7 +322,7 @@ + (cf-subst 'sharedstatedir "${prefix}/com") + (cf-subst 'localstatedir "${prefix}/var") + (cf-subst 'includedir "${prefix}/include") +- (cf-subst 'oldincludedir "/usr/include") ++ (cf-subst 'oldincludedir "@TERMUX_PREFIX@/include") + (cf-subst 'docdir "${datarootdir}/doc/${PACKAGE_TARNAME}") + (cf-subst 'infodir "${datarootdir}/info") + (cf-subst 'htmldir "${docdir}") diff --git a/packages/gauche/lib-gauche-interactive-toplevel.scm.patch b/packages/gauche/lib-gauche-interactive-toplevel.scm.patch new file mode 100644 index 00000000000000..0084d63107940e --- /dev/null +++ b/packages/gauche/lib-gauche-interactive-toplevel.scm.patch @@ -0,0 +1,11 @@ +--- a/lib/gauche/interactive/toplevel.scm ++++ b/lib/gauche/interactive/toplevel.scm +@@ -331,7 +331,7 @@ + (run-process `("cmd.exe" "/c" ,sh "-c" ,line) :wait #t) + (run-process `("cmd.exe" "/c" ,line) :wait #t))] + [else +- (let1 sh (or (sys-getenv "SHELL") "/bin/sh") ++ (let1 sh (or (sys-getenv "SHELL") "@TERMUX_PREFIX@/bin/sh") + (run-process `(,sh "-c" ,line) :wait #t))]) + *no-value*)) + diff --git a/packages/gauche/lib-gauche-package-util.scm.patch b/packages/gauche/lib-gauche-package-util.scm.patch new file mode 100644 index 00000000000000..2371f58708ec16 --- /dev/null +++ b/packages/gauche/lib-gauche-package-util.scm.patch @@ -0,0 +1,11 @@ +--- a/lib/gauche/package/util.scm ++++ b/lib/gauche/package/util.scm +@@ -57,7 +57,7 @@ + (unless (dry-run) + (let1 p (run-process (cond-expand + [gauche.os.windows (shell-tokenize-string cmdline 'posix)] +- [else `("/bin/sh" "-c" ,cmdline)]) ++ [else `("@TERMUX_PREFIX@/bin/sh" "-c" ,cmdline)]) + :input (if stdin-string :pipe :null) + :wait #f) + (when stdin-string diff --git a/packages/gauche/libsrc-gauche-process.scm.patch b/packages/gauche/libsrc-gauche-process.scm.patch new file mode 100644 index 00000000000000..b81f2270a01399 --- /dev/null +++ b/packages/gauche/libsrc-gauche-process.scm.patch @@ -0,0 +1,11 @@ +--- a/libsrc/gauche/process.scm ++++ b/libsrc/gauche/process.scm +@@ -880,7 +880,7 @@ + [else (error "Invalid :error argument:" stderr)]))) + (cond [(string? command) + (rc (cond-expand [gauche.os.windows `("cmd.exe" "/c" ,command)] +- [else `("/bin/sh" "-c" ,command)]))] ++ [else `("@TERMUX_PREFIX@/bin/sh" "-c" ,command)]))] + [(and (list? command) (every list? command)) + (apply run-pipeline command + :input stdin :output stdout diff --git a/packages/gauche/src-libsys.c.patch b/packages/gauche/src-libsys.c.patch new file mode 100644 index 00000000000000..462c3f48ce1c62 --- /dev/null +++ b/packages/gauche/src-libsys.c.patch @@ -0,0 +1,11 @@ +--- a/src/libsys.c ++++ b/src/libsys.c +@@ -5628,7 +5628,7 @@ + #if HAVE_MKSTEMP + + #line 450 "libsys.scm" +-{char nam[]="/tmp/fileXXXXXX";int fd; ++{char nam[]="@TERMUX_PREFIX@/tmp/fileXXXXXX";int fd; + SCM_SYSCALL(fd,mkstemp(nam)); + if ((fd)<(0)){{Scm_SysError("mkstemp failed");}} + close(fd); diff --git a/packages/gauche/src-libsys.scm.patch b/packages/gauche/src-libsys.scm.patch new file mode 100644 index 00000000000000..7e706837fcaae7 --- /dev/null +++ b/packages/gauche/src-libsys.scm.patch @@ -0,0 +1,11 @@ +--- a/src/libsys.scm ++++ b/src/libsys.scm +@@ -447,7 +447,7 @@ + ;; potential security risk. We mimic it's behavior by mkstemp() if possible. + (define-cproc sys-tmpnam () + (.if "HAVE_MKSTEMP" +- (let* ([nam::(.array char [*]) "/tmp/fileXXXXXX"] [fd::int]) ++ (let* ([nam::(.array char [*]) "@TERMUX_PREFIX@/tmp/fileXXXXXX"] [fd::int]) + (SCM_SYSCALL fd (mkstemp nam)) + (when (< fd 0) (Scm_SysError "mkstemp failed")) + (close fd) diff --git a/packages/gauche/src-system.c.patch b/packages/gauche/src-system.c.patch new file mode 100644 index 00000000000000..5322ec8bc2178f --- /dev/null +++ b/packages/gauche/src-system.c.patch @@ -0,0 +1,11 @@ +--- a/src/system.c ++++ b/src/system.c +@@ -419,7 +419,7 @@ + const char *s; + if ((s = Scm_GetEnv("TMPDIR")) != NULL) return SCM_MAKE_STR_COPYING(s); + if ((s = Scm_GetEnv("TMP")) != NULL) return SCM_MAKE_STR_COPYING(s); +- else return SCM_MAKE_STR("/tmp"); /* fallback */ ++ else return SCM_MAKE_STR("@TERMUX_PREFIX@/tmp"); /* fallback */ + #endif /*!GAUCHE_WINDOWS*/ + } + From eff47696a67a4a7d107881592f54c03703f2a60e Mon Sep 17 00:00:00 2001 From: Tee KOBAYASHI Date: Tue, 21 Dec 2021 09:08:00 +0900 Subject: [PATCH 2/2] gauche: Disable threads with which the following code hangs: ``` (use rfc.uri) (uri-decode-string "") ``` --- packages/gauche/build.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/packages/gauche/build.sh b/packages/gauche/build.sh index d1d75c48760513..03aad0289bad1d 100644 --- a/packages/gauche/build.sh +++ b/packages/gauche/build.sh @@ -15,6 +15,12 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" " # 0.9.10 does not support MbedTLS 3.0: remove --with-tls=... when updating TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --with-tls=axtls" +# As of 0.9.10 some code hangs with threads enabled, e.g. +# ``` +# (use rfc.uri) +# (uri-decode-string "") +# ``` +TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" --enable-threads=none" termux_step_host_build() { _PREFIX_FOR_BUILD=$TERMUX_PKG_HOSTBUILD_DIR/prefix