-
Notifications
You must be signed in to change notification settings - Fork 0
/
boot-bin.sh
executable file
·118 lines (87 loc) · 3.08 KB
/
boot-bin.sh
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#!/bin/bash
set -e
# Versions
VER=8.6.0.1
GHCVER=8.6.5
CABALVER=3.4
BOOTCABALVER=3.2
# Installation prefix
INSTPREFIX="$1"
if [ -z "$INSTPREFIX" ]; then
echo "Usage: ./boot-bin.sh"
exit 1
fi
############################################################################
## Configuring
if [ -x /usr/bin/nodejs ]; then
NODE=/usr/bin/nodejs
elif [ -x /usr/bin/node ]; then
NODE=/usr/bin/node
else
echo "WARNING: node not found"
fi
echo "NodeJS: $NODE"
$NODE --version
WORKDIR=${PWD}
TOPDIR0=/opt/ghcjs/$VER/lib/ghcjs
BINDIR=${INSTPREFIX}/opt/ghcjs/$VER/bin
TOPDIR=${INSTPREFIX}${TOPDIR0}
GHCJSDEPREPO="${WORKDIR}/dependencies"
# Unset cabal directories
unset CABAL_DIR
unset CABAL_CONFIG
# Make cabal.rc (global cabal config)
sed "s|@GHCJSDEPREPO@|$GHCJSDEPREPO|g" "${WORKDIR}/cabal.rc.in" > "${WORKDIR}/cabal.rc"
if [ ! -f "${WORKDIR}/cabal.rc.in" ]; then
echo "cabal.rc not found in pwd ($WORKDIR)"
exit 1
fi
# Make "CABAL_DIR"
mkdir -p /tmp/cabal
# Remove installation prefix
rm -rf "$INSTPREFIX"
# Update repository cache
PATH=/opt/ghc/$GHCVER/bin:$PATH HOME=/tmp/home CABAL_CONFIG="${WORKDIR}/cabal.rc" \
/opt/cabal/$CABALVER/bin/cabal v2-update ghcjs-dependencies
############################################################################
## Building
PATH=/opt/ghc/$GHCVER/bin:$PATH HOME=/tmp/home CABAL_CONFIG="${WORKDIR}/cabal.rc" \
/opt/cabal/$CABALVER/bin/cabal --project-file=./cabal.ghcjs.project v2-build :pkg:ghcjs
rm -fv .ghc.environment.x86_64-linux-$GHCVER
mkdir -p "$TOPDIR/bin"
for N in ghcjs ghcjs-pkg haddock-ghcjs hsc2hs-ghcjs; do
cp -v "$WORKDIR/dist-newstyle/build/x86_64-linux/ghc-$GHCVER/ghcjs-$VER/build/$N/$N" "$TOPDIR/bin/$N"
done
GHCJSBOOT=$WORKDIR/dist-newstyle/build/x86_64-linux/ghc-$GHCVER/ghcjs-$VER/build/ghcjs-boot/ghcjs-boot
GHCJSRUN=$WORKDIR/dist-newstyle/build/x86_64-linux/ghc-$GHCVER/ghcjs-$VER/build/ghcjs-run/ghcjs-run
BOOTTAR=$WORKDIR/ghcjs-$VER/data/boot.tar
############################################################################
## building core binaries phase done; here starts boot library bootstrap phase
mkdir -p "${BINDIR}"
# temporary inplace wrappers
for N in ghcjs ghcjs-pkg haddock-ghcjs hsc2hs-ghcjs; do
sed "s|@TOPDIR@|$TOPDIR|g" "./wrappers/$N.in" > "$BINDIR/$N"
chmod +x "$BINDIR/$N"
done
HOME=/tmp/cabal CABAL_CONFIG="${WORKDIR}/cabal.rc" PATH="${BINDIR}:/opt/ghc/$GHCVER/bin:$PATH" \
$GHCJSBOOT -s "$BOOTTAR" \
--no-prof --no-haddock \
--with-node $NODE \
--with-ghcjs-run "$GHCJSRUN" \
--with-cabal /opt/cabal/$BOOTCABALVER/bin/cabal
############################################################################
## fixup installation
# fixup database
sed -i "s|$TOPDIR|\${pkgroot}|g" "${TOPDIR}/package.conf.d"/*.conf
"$BINDIR/ghcjs-pkg" recache -v
# remove redundant stuff
rm -rf "$TOPDIR/boot"
# create proper wrappers
for N in ghcjs ghcjs-pkg haddock-ghcjs hsc2hs-ghcjs; do
rm -fv "$BINDIR/$N"
sed "s|@TOPDIR@|$TOPDIR0|g" "./wrappers/$N.in" > "$BINDIR/$N-$VER"
chmod +x "$BINDIR/$N-$VER"
done
############################################################################
## Done
exit 0