diff options
author | tomsmeding <tom.smeding@gmail.com> | 2022-07-16 23:00:09 +0200 |
---|---|---|
committer | tomsmeding <tom.smeding@gmail.com> | 2022-07-16 23:00:09 +0200 |
commit | 35a8d735cf66ac3a8867247b3f1a734af2add2ab (patch) | |
tree | 48750d56028ad39338e5cc69524b5b3deeceefaa |
Initial
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | cbl/.gitignore | 3 | ||||
-rw-r--r-- | cbl/cabal.project | 3 | ||||
-rwxr-xr-x | ghc-pkg-shim.sh | 9 | ||||
-rwxr-xr-x | ghc-shim.sh | 7 | ||||
-rw-r--r-- | notes.txt | 76 |
6 files changed, 99 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5870959 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/ghc-boot-pkgdb/ diff --git a/cbl/.gitignore b/cbl/.gitignore new file mode 100644 index 0000000..2e100ff --- /dev/null +++ b/cbl/.gitignore @@ -0,0 +1,3 @@ +/cabal-install-* +/resolv-* +/dist-newstyle/ diff --git a/cbl/cabal.project b/cbl/cabal.project new file mode 100644 index 0000000..80b51b1 --- /dev/null +++ b/cbl/cabal.project @@ -0,0 +1,3 @@ +packages: + resolv-0.1.2.0/ + cabal-install-3.6.2.0/ diff --git a/ghc-pkg-shim.sh b/ghc-pkg-shim.sh new file mode 100755 index 0000000..92d7607 --- /dev/null +++ b/ghc-pkg-shim.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +#echo >/dev/tty "!! ghc-pkg $*" +args=() +for arg; do + if [[ $arg != --global ]]; then + args[${#args[@]}]="$arg" + fi +done +ghc-pkg --package-db /data/data/com.termux/files/home/ghc-boot-pkgdb "${args[@]}" diff --git a/ghc-shim.sh b/ghc-shim.sh new file mode 100755 index 0000000..6885dc7 --- /dev/null +++ b/ghc-shim.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash +if [[ $# = 1 && $1 = --print-global-package-db ]]; then + echo /data/data/com.termux/files/home/ghc-boot-pkgdb +else + #echo >/dev/tty "!! ghc $*" + ghc "$@" +fi diff --git a/notes.txt b/notes.txt new file mode 100644 index 0000000..02a2bc4 --- /dev/null +++ b/notes.txt @@ -0,0 +1,76 @@ +# Getting a statically-linked cabal-install in termux + +Be sure to have lots of free RAM; building the Cabal library from source takes roughly 4.5GiB at peak. Force stop apps if needed. + +apt install ghc ghc-libs-static +apt install cabal-install + +Check using `dpkg -L ghc-libs-static' which libraries have static libs available +Copy the .conf files for just those libraries from /data/data/com.termux/files/usr/lib/ghc-8.10.7/package.conf.d/ into a new direcrory, ghc-boot-pkgdb + +In ghc-boot-pkgdb, run `ghc-pkg recache` + +cat >ghc-shim.sh <<EOF +#!/usr/bin/env bash +if [[ $# = 1 && $1 = --print-global-package-db ]]; then + echo /data/data/com.termux/files/home/ghc-boot-pkgdb +else + #echo >/dev/tty "!! ghc $*" + ghc "$@" +fi +EOF + +cat >ghc-pkg-shim.sh <<EOF +#!/usr/bin/env bash +#echo >/dev/tty "!! ghc-pkg $*" +args=() +for arg; do + if [[ $arg != --global ]]; then + args[${#args[@]}]="$arg" + fi +done +ghc-pkg --package-db /data/data/com.termux/files/home/ghc-boot-pkgdb "${args[@]}" +EOF + +Make a new directory 'cbl', and in that directory: + +cabal get resolv +cabal get cabal-install +cat >cabal.project <<EOF +packages: + resolv-0.1.2.0/ + cabal-install-3.6.2.0/ +EOF +cd resolv-0.1.2.0 +patch -p1 <<EOF # this is https://raw.githubusercontent.com/termux/termux-packages/master/packages/haskell-resolv/hs_resolv.patch +--- resolv-0.1.2.0/cbits/hs_resolv.h 2001-09-09 07:16:40.000000000 +0530 ++++ resolv-0.1.2.0-patch/cbits/hs_resolv.h 2022-02-03 20:54:49.602546255 +0530 +@@ -84,12 +84,8 @@ + { + assert(!s); + +- if (!(_res.options & RES_INIT)) { + int rc = res_init(); + if (rc) return rc; +- } +- +- _res.options |= RES_USE_DNSSEC | RES_USE_EDNS0; + + return 0; + } +@@ -112,7 +108,7 @@ + { + assert(!s); + +- return res_send(msg, msglen, answer, anslen); ++ return -1; + } + + inline static int +EOF +cd .. +cabal install -w ../ghc-shim.sh --with-hc-pkg=../ghc-pkg-shim.sh cabal-install + +# Remove the extraneous dynamic libs that were installed, so that our system is stable again +apt remove cabal-install +apt autoremove |