Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new package: gauche #8279

Merged
2 commits merged into from
Dec 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 53 additions & 0 deletions packages/gauche/build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
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"
# 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
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 '!<arch>' > $_LIBPTHREAD_A
fi

autoreconf -fi
}

termux_step_post_make_install() {
if [ $_NEED_DUMMY_LIBPTHREAD_A ]; then
rm -f $_LIBPTHREAD_A
fi
}
10 changes: 10 additions & 0 deletions packages/gauche/configure.ac.patch
Original file line number Diff line number Diff line change
@@ -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"],
11 changes: 11 additions & 0 deletions packages/gauche/ext-Makefile.ext.in.patch
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions packages/gauche/ext-dbm-Makefile.in.patch
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions packages/gauche/ext-text-gettext.scm.patch
Original file line number Diff line number Diff line change
@@ -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
14 changes: 14 additions & 0 deletions packages/gauche/ext-tls-gauche-tls.h.patch
Original file line number Diff line number Diff line change
@@ -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"
xtkoba marked this conversation as resolved.
Show resolved Hide resolved

#if defined(GAUCHE_USE_AXTLS)
#include "axTLS/ssl/ssl.h"
24 changes: 24 additions & 0 deletions packages/gauche/fake-ndbm-makedb.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@

#include <string.h>
#include <fcntl.h>

#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;
}
11 changes: 11 additions & 0 deletions packages/gauche/gc-os_dep.c.patch
Original file line number Diff line number Diff line change
@@ -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",
xtkoba marked this conversation as resolved.
Show resolved Hide resolved
exe_name, (unsigned long)info[i].ci_pc);
cmd_buf[sizeof(cmd_buf) - 1] = '\0';
old_preload = GETENV("LD_PRELOAD");
31 changes: 31 additions & 0 deletions packages/gauche/lib-gauche-configure.scm.patch
Original file line number Diff line number Diff line change
@@ -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}")
11 changes: 11 additions & 0 deletions packages/gauche/lib-gauche-interactive-toplevel.scm.patch
Original file line number Diff line number Diff line change
@@ -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*))

11 changes: 11 additions & 0 deletions packages/gauche/lib-gauche-package-util.scm.patch
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions packages/gauche/libsrc-gauche-process.scm.patch
Original file line number Diff line number Diff line change
@@ -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
11 changes: 11 additions & 0 deletions packages/gauche/src-libsys.c.patch
Original file line number Diff line number Diff line change
@@ -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);
11 changes: 11 additions & 0 deletions packages/gauche/src-libsys.scm.patch
Original file line number Diff line number Diff line change
@@ -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)
11 changes: 11 additions & 0 deletions packages/gauche/src-system.c.patch
Original file line number Diff line number Diff line change
@@ -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*/
}