-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathinstall-env.sh
executable file
·90 lines (61 loc) · 1.83 KB
/
install-env.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
#!/bin/sh
# FIXME: Re-organize this, it has gotten too complicated.
#
# The racket package should not have any dependencies and only contain
# the compiler. Next to that there should be a C package that can
# compile the files, probably on top of uc_tools.
# 1. Allow override RACKET_DIR
if [ ! -z "$RACKET_DIR" ]; then
echo "using RACKET_DIR=$RACKET_DIR"
RACKET=$RACKET_DIR/bin/racket
fi
# 2. Otherwise git it from path
[ -z "$RACKET" ] && RACKET=$(which racket)
[ -z "$RACKET" ] && echo "Can't locate racket" && exit 1
echo "racket is $(readlink -f $(which $RACKET))"
$RACKET --version
# 3. Assume raco is next to it
RACO=$(dirname $RACKET)/raco
# 4. Where to put deps?
[ -z "$RACKET_DIR" ] && RACKET_DIR=$(dirname $(dirname $RACKET))
echo "RACKET_DIR=$RACKET_DIR"
HERE_ABS=$(readlink -f $(dirname $0))
PARENT_ABS=$(dirname $HERE_ABS)
PRJ_DIR=$(basename $HERE_ABS)
echo "rai is in $HERE_ABS"
# FIXME: special cased. Find a way to configure this.
if [ "/home/tom/.nix-profile" == $RACKET_DIR ]; then
DEPS_DIR="${PARENT_ABS}/.${PRJ_DIR}.deps"
echo "installing deps in $DEPS_DIR"
mkdir -p ${DEPS_DIR}
cat <<EOF >with-env.sh
#!/bin/sh
# Generated by $0
# Set HOME, so user install goes in ${DEPS_DIR}/.racket
# Note that because of linking, the .racket dir cannot go under the rai/ dir.
HOME=${DEPS_DIR}
export PATH=${RACKET_DIR}/bin:\$PATH
racket --version >&2
exec "\$@"
EOF
else
cat <<EOF >with-env.sh
#!/bin/sh
export PATH=${RACKET_DIR}/bin:\$PATH
racket --version >&2
exec "\$@"
EOF
fi
cd ${HERE_ABS}
chmod +x with-env.sh
echo "generated:"
echo
cat with-env.sh
echo
echo "installing deps"
# if [ ! -z "$SCOPE_DIR" ]; then
# RACO="$RACO --scope-dir $SCOPE_DIR"
# fi
# ( ./with-env.sh $RACO pkg install --deps search-auto rsound )
( cd ${PARENT_ABS} ; ./${PRJ_DIR}/with-env.sh $RACO pkg install --link rai )
exit 0