-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_vscode.sh
116 lines (101 loc) · 3.82 KB
/
install_vscode.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
#!/bin/bash
echo "+----------------------+"
echo "| AE5 VSCode Installer |"
echo "+----------------------+"
TOOL_HOME=$(dirname "${BASH_SOURCE[0]}")
echorun() {
echo "> $@"
"$@" | sed 's@^@| @'
}
CURRENT_DIR=$PWD
SOURCE_DIR=$(dirname "${BASH_SOURCE[0]}")
missing=
for sfile in MANIFEST activate.sh admin_settings.json merge_settings.py patch_python_extension.py start_vscode.sh; do
spath=$CURRENT_DIR/$sfile
[ -f $spath ] || spath=$SOURCE_DIR/$sfile
[ -f $spath ] || missing="$missing $sfile"
done
if [ ! -z "$missing" ]; then
echo "ERROR: missing support files:$missing"
exit -1
fi
missing=
vscode_fname=$(sed -nE 's@(.*/)?(code-server-.*)@\2@p' MANIFEST)
if [ -z "$vscode_fname" ]; then
echo "ERROR: could not find the code-server binary in the MANIFEST"
exit -1
fi
[ -f "downloads/$vscode_fname" ] || missing="$missing $vscode_fname"
for fname in $(sed -nE 's@(.*/)?([^/]*.vsix)@\2@p' MANIFEST); do
[ -f "downloads/$fname" ] || missing="$missing $fname"
done
if [ ! -z "$missing" ]; then
echo "ERROR: missing files:$missing"
echo "(Have you run download_vscode.sh?)"
exit -1
fi
# PREFIX: where the *final* install will live
# STAGING_PREFIX: where we are building it for now
# Allowing these to be different simplifies our ability
# to create VSCode tarballs in one location and install
# them in another.
[ $PREFIX ] || PREFIX=/tools/vscode
[ $STAGING_PREFIX ] || STAGING_PREFIX=$PREFIX
if [ $(basename "$PREFIX") != $(basename "$STAGING_PREFIX") ]; then
echo "ERROR: in order to facilitate proper distribution, the"
echo "basename of PREFIX and STAGING_PREFIX must be identical."
echo "- PREFIX: $PREFIX"
echo "- STAGING_PREFIX: $STAGING_PREFIX"
echo "Please choose a different STAGING_PREFIX value and retry."
exit -1
fi
echo "| Install prefix: ${PREFIX}"
echo "| Staging prefix: ${STAGING_PREFIX}"
if [ ! -d $STAGING_PREFIX ]; then
parent=$(dirname $STAGING_PREFIX)
if [[ $PREFIX == $STAGING_PREFIX && ! -d $parent ]]; then
echo "ERROR: install parent $parent does not exist"
exit -1
elif ! mkdir -p $STAGING_PREFIX; then
echo "ERROR: could not create install directory"
exit -1
fi
elif [ ! -w $STAGING_PREFIX ]; then
echo "ERROR: install location is not writable"
ls -ald $STAGING_PREFIX
id
exit -1
elif [ ! -z "$(ls -A $STAGING_PREFIX)" ]; then
echo "ERROR: install location is not empty"
ls -al $STAGING_PREFIX
exit -1
fi
PYTHON_EXE=/opt/continuum/anaconda/bin/python
if [ ! -f $PYTHON_EXE ]; then
PYTHON_EXE=$CONDA_PREFIX/bin/python
fi
echo "- Installing code-server"
echorun tar xfz downloads/$vscode_fname --strip-components 1 -C $STAGING_PREFIX
echo "- Installing extensions"
mkdir -p $STAGING_PREFIX/extensions
for ext in $(sed -nE 's@(.*/)?([^/]*.vsix)@\2@p' MANIFEST); do
echorun $STAGING_PREFIX/bin/code-server \
--extensions-dir=$STAGING_PREFIX/extensions --install-extension=downloads/$ext
done
echo "- Run the Python extension patcher"
echorun $PYTHON_EXE patch_python_extension.py $STAGING_PREFIX
echo "- Installing support scripts"
cp admin_settings.json activate.sh start_vscode.sh merge_settings.py \
patch_python_extension.py default_env.py $STAGING_PREFIX
if [ "$PREFIX" != "/tools/vscode" ]; then
sed -i.bak "s@/tools/vscode/@$PREFIX/@" $STAGING_PREFIX/{admin_settings.json,activate.sh}
fi
chmod +x $STAGING_PREFIX/{activate.sh,start_vscode.sh}
echo "Installed. You can shut down this session, and/or remove downloaded files."
if [ "$PREFIX" != "$STAGING_PREFIX" ]; then
echo "To build as tarball for delivery; run this command:"
echo " tar cfz ae5-vscode.tar.gz -C $(dirname $STAGING_PREFIX) $(basename $STAGING_PREFIX)"
echo "To install the tarball at the destination, run:"
echo " mkdir -p $(dirname $PREFIX)"
echo " tar xfz ae5-vscode.tar.gz -C $(dirname $PREFIX)"
fi