summaryrefslogtreecommitdiff
path: root/notes.txt
blob: 7c14f19f09becd03d76554f5a841aa68ea7e6d33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# 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

I assume you're currently in $HOME/ghc-cabal-build.

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 directory, 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-cabal-build/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-cabal-build/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