From 35a8d735cf66ac3a8867247b3f1a734af2add2ab Mon Sep 17 00:00:00 2001 From: tomsmeding Date: Sat, 16 Jul 2022 23:00:09 +0200 Subject: Initial --- .gitignore | 1 + cbl/.gitignore | 3 +++ cbl/cabal.project | 3 +++ ghc-pkg-shim.sh | 9 +++++++ ghc-shim.sh | 7 +++++ notes.txt | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 99 insertions(+) create mode 100644 .gitignore create mode 100644 cbl/.gitignore create mode 100644 cbl/cabal.project create mode 100755 ghc-pkg-shim.sh create mode 100755 ghc-shim.sh create mode 100644 notes.txt 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 </dev/tty "!! ghc $*" + ghc "$@" +fi +EOF + +cat >ghc-pkg-shim.sh </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 <