@ecmaos-apps/cmatrix-src 0.0.0-stage → 2.0.0-ecmaos.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/README.md +8 -2
  2. package/build/build.sh +62 -0
  3. package/package.json +40 -4
  4. package/share/licenses/cmatrix/COPYING +674 -0
  5. package/share/licenses/cmatrix/SOURCE +27 -0
  6. package/sources/cmatrix-2.0.tar.gz +0 -0
  7. package/sources/ncurses-6.5.tar.gz +0 -0
  8. package/toolchain/emscripten-version +1 -0
  9. package/toolchain/rust-wali-version +3 -0
  10. package/toolchain/wali/asyncify-reach.mjs +107 -0
  11. package/toolchain/wali/asyncify.sh +57 -0
  12. package/toolchain/wali/build-sysroot.sh +158 -0
  13. package/toolchain/wali/patches/compiler-rt/0001-wasm-compare-result.patch +18 -0
  14. package/toolchain/wali/patches/musl/0001-environment-through-imports.patch +143 -0
  15. package/toolchain/wali/patches/musl/0002-setjmp-with-wasm-exceptions.patch +133 -0
  16. package/toolchain/wali/patches/musl/0003-unknown-syscall-is-enosys.patch +31 -0
  17. package/toolchain/wali/patches/musl/0004-return-from-main-is-exit.patch +53 -0
  18. package/toolchain/wali/patches/musl/0005-posix-spawn-through-the-host.patch +278 -0
  19. package/toolchain/wali/patches/musl/0006-detached-thread-frees-its-stack.patch +34 -0
  20. package/toolchain/wali/patches/musl/0007-wordexp-without-fork.patch +62 -0
  21. package/toolchain/wali/patches/musl/0008-progname-from-argv.patch +34 -0
  22. package/toolchain/wali/patches/musl/0009-no-basename-in-string-h.patch +15 -0
  23. package/toolchain/wali/patches/musl/0010-ssize-max-is-pointer-sized.patch +15 -0
  24. package/toolchain/wali/patches/musl/0011-startup-without-malloc.patch +85 -0
  25. package/toolchain/wali/patches/musl/0012-floatscan-fixes-from-musl.patch +39 -0
  26. package/toolchain/wali/patches/musl/0013-strptime-from-musl-with-glibc-s-and-z.patch +169 -0
  27. package/toolchain/wali/patches/musl/0014-wordexp-fixes-from-musl.patch +43 -0
  28. package/toolchain/wali/patches/musl/0015-long-double-is-ieee-quad.patch +202 -0
  29. package/toolchain/wali/patches/musl/0016-wordexp-nocmd-and-undef.patch +285 -0
  30. package/toolchain/wali/rust.sh +116 -0
  31. package/toolchain/wali/signal-checks.mjs +373 -0
  32. package/toolchain/wali-version +13 -0
package/README.md CHANGED
@@ -1,3 +1,9 @@
1
- # Temporary Holding Version
1
+ # @ecmaos-apps/cmatrix-src
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The Corresponding Source of `@ecmaos-apps/cmatrix` 2.0.0-ecmaos.1 (GPL-3.0-or-later AND X11): everything needed to build the `cmatrix.wasm` it ships.
4
+
5
+ - `sources/` - the upstream archives, each checked against the sha256 in `package.json` (`ecmaos.archives`)
6
+ - `build/` - the scripts that turn them into the program (our changes to the source are in them)
7
+ - `toolchain/` - the pins of the compiler and libc the program is built with, and the patches to WALI's musl and compiler-rt (`wali/`)
8
+
9
+ Installed with `apt source cmatrix` or `install @ecmaos-apps/cmatrix-src`.
package/build/build.sh ADDED
@@ -0,0 +1,62 @@
1
+ #!/usr/bin/env bash
2
+ # SPDX-License-Identifier: GPL-3.0-or-later
3
+ # Rebuilds programs/cmatrix.wasm: cmatrix 2.0, the falling characters of The Matrix, for ecmaOS, on WALI's musl
4
+ # (`utils/check-wali.sh`), run by /bin/wali. It draws with ncurses, which is built here as htop's is: a static
5
+ # wide-character library with the xterm, xterm-256color, vt100 and linux descriptions compiled in (there is no terminfo
6
+ # database to read). The result is committed, so only run this to change it. Needs the host's `tic` and `infocmp`.
7
+ #
8
+ # Built without autotools or CMake: one file, with the defines CMake gives it, and none for the Linux console's fonts
9
+ # (setfont and consolechars, which a browser terminal has not got) or TIOCSTI (which -s uses to hand the key that ends
10
+ # the screensaver to the shell; Linux has turned it off by default too).
11
+ # What is changed in cmatrix's source, asserted so a new release that moves the code fails the build:
12
+ # - main() starts by setting TERM: it is `xterm.js`, a name none of those descriptions have, so cmatrix is given
13
+ # xterm-256color for it.
14
+ set -euo pipefail
15
+ source "$(dirname "$0")/../../../../utils/check-wali.sh"
16
+
17
+ HERE=$(cd "$(dirname "$0")" && pwd)
18
+ SOURCES="$HERE/../../scripts/sources.mjs"
19
+ CMATRIX=$(node "$SOURCES" version cmatrix cmatrix)
20
+ NCURSES=$(node "$SOURCES" version cmatrix ncurses)
21
+ CMATRIX_ARCHIVE=$(node "$SOURCES" fetch cmatrix cmatrix)
22
+ NCURSES_ARCHIVE=$(node "$SOURCES" fetch cmatrix ncurses)
23
+ OUT=$HERE/../../programs/cmatrix.wasm
24
+ WORK=$(mktemp -d)
25
+ trap 'rm -rf "$WORK"' EXIT
26
+
27
+ cd "$WORK"
28
+ tar xzf "$NCURSES_ARCHIVE"
29
+ tar xzf "$CMATRIX_ARCHIVE"
30
+
31
+ mkdir prefix
32
+ cd "ncurses-$NCURSES"
33
+ CC="$WALI_CC" CFLAGS=-O2 AR="$WALI_AR" RANLIB="$WALI_RANLIB" ./configure --host=wasm32-unknown-linux-musl \
34
+ --prefix="$WORK/prefix" --without-ada --without-cxx --without-cxx-binding --without-manpages --without-progs \
35
+ --without-tests --without-shared --without-debug --disable-database --with-fallbacks=xterm-256color,xterm,vt100,linux \
36
+ --with-tic-path="$(command -v tic)" --with-infocmp-path="$(command -v infocmp)" --without-gpm \
37
+ --disable-stripping --enable-widec --disable-home-terminfo > configure.log 2>&1 || { tail -30 configure.log >&2; exit 1; }
38
+ # the build-time helpers (make_keys writes the key table: without it curses recognises no arrow or function key) are
39
+ # run here, so they are built with the host compiler
40
+ sed -i 's/^BUILD_CC\t= .*/BUILD_CC\t= cc/; s/^BUILD_CCFLAGS\t= .*/BUILD_CCFLAGS\t=/; s/^BUILD_LDFLAGS\t= .*/BUILD_LDFLAGS\t=/; s/^BUILD_LIBS\t= .*/BUILD_LIBS\t=/' ncurses/Makefile
41
+ make -j"$(nproc)" libs > make.log 2>&1 || true # the last step builds a host-side helper that does not run; the library is what we want
42
+ grep -q "KEY_A1" ncurses/init_keytry.h || { echo "ncurses: init_keytry.h is empty (the host helper make_keys did not run), so arrow keys would not work" >&2; exit 1; }
43
+ [ -f lib/libncursesw.a ] || { tail -30 make.log >&2; exit 1; }
44
+ make install.includes > /dev/null 2>&1
45
+ mkdir -p "$WORK/prefix/lib" && cp lib/libncursesw.a "$WORK/prefix/lib/"
46
+
47
+ cd "$WORK/cmatrix-$CMATRIX"
48
+ python3 - <<'PY'
49
+ p = 'cmatrix.c'
50
+ s = open(p).read()
51
+ old = "int main(int argc, char *argv[]) {\n"
52
+ assert s.count(old) == 1, "cmatrix source changed: main() not found"
53
+ s = s.replace(old, old + ' if (!getenv("TERM") || !strcmp(getenv("TERM"), "xterm.js"))\n setenv("TERM", "xterm-256color", 1);\n', 1)
54
+ open(p, 'w').write(s)
55
+ PY
56
+ "$WALI_CC" -O2 -I"$WORK/prefix/include" -I"$WORK/prefix/include/ncursesw" -DEXCLUDE_CONFIG_H -DVERSION="\"$CMATRIX\"" \
57
+ -DHAVE_NCURSES_H -DHAVE_SYS_IOCTL_H -DHAVE_UNISTD_H -DHAVE_TERMIOS_H -DHAVE_RESIZETERM -DHAVE_WRESIZE \
58
+ -DHAVE_USE_DEFAULT_COLORS -o cmatrix cmatrix.c -L"$WORK/prefix/lib" -lncursesw
59
+ cp cmatrix "$OUT"
60
+ mkdir -p "$HERE/../../licenses/cmatrix" && cp COPYING "$HERE/../../licenses/cmatrix/COPYING"
61
+ ls -l "$OUT"
62
+ echo "built with $WALI_TOOLCHAIN"
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@ecmaos-apps/cmatrix-src",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "2.0.0-ecmaos.1",
4
+ "description": "The source of @ecmaos-apps/cmatrix: cmatrix, the falling characters of The Matrix, with ncurses",
5
+ "license": "GPL-3.0-or-later AND X11",
6
+ "homepage": "https://github.com/abishekvashok/cmatrix",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "https://github.com/ecmaos/ecmaos",
10
+ "directory": "core/utils-copyleft"
11
+ },
12
+ "keywords": [
13
+ "ecmaos",
14
+ "source",
15
+ "cmatrix"
16
+ ],
17
+ "files": [
18
+ "sources",
19
+ "build",
20
+ "toolchain",
21
+ "share",
22
+ "README.md"
23
+ ],
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "ecmaos": {
28
+ "sourceOf": "@ecmaos-apps/cmatrix@2.0.0-ecmaos.1",
29
+ "archives": {
30
+ "cmatrix-2.0.tar.gz": {
31
+ "sha256": "ad93ba39acd383696ab6a9ebbed1259ecf2d3cf9f49d6b97038c66f80749e99a",
32
+ "url": "https://github.com/abishekvashok/cmatrix/archive/refs/tags/v2.0.tar.gz",
33
+ "license": "GPL-3.0-or-later"
34
+ },
35
+ "ncurses-6.5.tar.gz": {
36
+ "sha256": "136d91bc269a9a5785e5f9e980bc76ab57428f604ce3e5a5a90cebc767971cc6",
37
+ "url": "https://ftpmirror.gnu.org/ncurses/ncurses-6.5.tar.gz",
38
+ "license": "X11"
39
+ }
40
+ }
41
+ }
42
+ }