-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bootstrap.sh
executable file
·85 lines (70 loc) · 2.73 KB
/
Bootstrap.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
#!/usr/bin/env bash
# ----------------------------------------------------------------------
# |
# | This script downloads and invokes BootstrapImpl.sh from the PythonBootstrapper
# | repository (https://github.com/davidbrownell/PythonBootstrapper).
# |
# | Arguments:
# |
# | --debug Display additional debugging information.
# |
# | --force Ensure that a new python environment is installed, even if it already exists.
# |
# | --python-version <version> Specify the python version to install; the default python version is installed if not specified.
# |
# | --bootstrap-branch <branch> Specify the branch of the PythonBootstrapper repository to use when downloading BootstrapImpl; "main" is used if not specified.
# |
# ----------------------------------------------------------------------
set +v # Continue on errors
this_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
pushd "${this_dir}" > /dev/null || exit
# ----------------------------------------------------------------------
# |
# | Parse and Process Arguments
# |
# ----------------------------------------------------------------------
bootstrap_branch=main
command_line_args=()
while [[ $# -gt 0 ]]; do
if [[ "$1" == "--bootstrap-branch" ]]; then
bootstrap_branch=$2
shift
else
command_line_args+=("$1")
fi
shift
done
# ----------------------------------------------------------------------
# |
# | Download BootstrapImpl.sh
# |
# ----------------------------------------------------------------------
echo "Downloading Bootstrap code..."
bootstrap_url=https://raw.githubusercontent.com/davidbrownell/PythonBootstrapper/${bootstrap_branch}/src/BootstrapImpl.sh
temp_script_name=$(mktemp Bootstrap.XXXXXX)
curl --header "Cache-Control: no-cache, no-store" --header "Pragma: no-cache" --location ${bootstrap_url} --output BootstrapImpl.sh --no-progress-meter --fail-with-body > "${temp_script_name}" 2>&1
error=$?
if [[ ${error} != 0 ]]; then
echo "[1ADownloading Bootstrap code...[31m[1mFAILED[0m (${bootstrap_url})."
echo ""
cat "${temp_script_name}"
rm "${temp_script_name}"
exit ${error}
fi
chmod u+x BootstrapImpl.sh
echo "[1ADownloading Bootstrap code...[32m[1mDONE[0m."
# ----------------------------------------------------------------------
# |
# | Invoke BootstrapImpl.sh
# |
# ----------------------------------------------------------------------
./BootstrapImpl.sh "${command_line_args[@]}"
error=$?
# ----------------------------------------------------------------------
# |
# | Exit
# |
# ----------------------------------------------------------------------
rm "BootstrapImpl.sh"
rm "${temp_script_name}"
exit ${error}