Repository navigation
Expand file tree
/
Copy path031-development-packages.sh
More file actions
executable file
·221 lines (189 loc) · 7.49 KB
/
Copy path031-development-packages.sh
File metadata and controls
executable file
·221 lines (189 loc) · 7.49 KB
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
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
#!/bin/bash
if prompt_default_no "Install Python development packages?"; then
if prompt_default_no "Install Pip?"; then
if ! command -v pip &>/dev/null; then
info "Pip not installed. Installing..."
curl --fail --show-error https://bootstrap.pypa.io/get-pip.py -o /tmp/get-pip.py
python3 /tmp/get-pip.py --user --break-system-packages
else
info "Pip $(pip --version | grep -o '(.*)') already installed"
fi
fi
if prompt_default_yes "Install/update Python development packages?"; then
pip install --break-system-packages --upgrade --user --requirement "$DOTFILES_SETUP_SCRIPT_DIR/requirements.txt"
info "${YELLOW}Modifying $(which pylint) to use environment python instead of system python..."
sed -i 's|/usr/bin/python3|/usr/bin/env python3|' "$(which pylint)"
fi
fi # Python
download_and_install_shellcheck() {
local version="$1"
local artifact="shellcheck-$version.linux.x86_64.tar.xz"
pushd /tmp || exit 1
debug "downloading $artifact ..."
github_download_release "koalaman/shellcheck" "$version" "$artifact"
debug "unpacking $artifact ..."
tar -xvf "$artifact"
debug "installing..."
cp "shellcheck-$version"*/shellcheck ~/.local/bin/
popd || exit 1
}
download_and_install_shfmt() {
local version="$1"
local artifact="shfmt_${version}_linux_amd64"
pushd /tmp || exit 1
debug "downloading $artifact ..."
github_download_release "mvdan/sh" "$version" "$artifact"
debug "installing..."
cp "/tmp/$artifact" ~/.local/bin/shfmt
chmod +x ~/.local/bin/shfmt
popd || exit 1
}
if prompt_default_yes "Install/update linters and formatters?"; then
latest_version=$(github_latest_release_tag "koalaman/shellcheck")
info "Found latest shellcheck version: $latest_version"
if command -v shellcheck &>/dev/null; then
installed_version="v$(shellcheck --version | sed -En 's/version: ([0-9]+\.[0-9]+\.[0-9]+)/\1/p')"
debug "Found installed shellcheck version: $installed_version"
if [[ "$installed_version" != "$latest_version" ]]; then
info "Updating shellcheck..."
download_and_install_shellcheck "$latest_version"
else
info "Shellcheck $installed_version already installed."
if prompt_default_no "Reinstall shellcheck?"; then
info "Reinstalling shellcheck..."
download_and_install_shellcheck "$installed_version"
fi
fi
else
info "Installing shellcheck for the first time..."
download_and_install_shellcheck "$latest_version"
fi
latest_version=$(github_latest_release_tag "mvdan/sh")
info "Found latest shfmt version: $latest_version"
if command -v shfmt &>/dev/null; then
installed_version="$(shfmt --version | tr -d '\n')"
debug "Found installed shfmt version: $installed_version"
if [[ "$installed_version" != "$latest_version" ]]; then
info "Updating shfmt..."
download_and_install_shfmt "$latest_version"
else
info "shfmt $installed_version already installed."
if prompt_default_no "Reinstall shfmt?"; then
info "Reinstalling shfmt..."
download_and_install_shfmt "$installed_version"
fi
fi
else
info "Installing shfmt for the first time..."
download_and_install_shfmt "$latest_version"
fi
fi # Linters/formatters
if prompt_default_no "Install/update Rust?"; then
# shellcheck disable=SC1090
[ -f ~/.cargo/env ] && source ~/.cargo/env
if command -v rustup &>/dev/null; then
installed_version=$(rustup --version |& sed -En 's/rustup\s+([0-9.]+)\s.*/\1/p')
info "rustup version $installed_version already installed. Updating..."
rustup self update
rustup update
rustup completions bash >"$DOTFILES_SETUP_SCRIPT_DIR/stowdir/.bash_completion.d/rustup"
rustup completions bash cargo >"$DOTFILES_SETUP_SCRIPT_DIR/stowdir/.bash_completion.d/cargo"
else
info "rustup not installed. Installing..."
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# shellcheck disable=SC1090
[ -f ~/.cargo/env ] && source ~/.cargo/env
rustup component add rust-analyzer llvm-tools-preview
rustup completions bash >"$DOTFILES_SETUP_SCRIPT_DIR/stowdir/.bash_completion.d/rustup"
rustup completions bash cargo >"$DOTFILES_SETUP_SCRIPT_DIR/stowdir/.bash_completion.d/cargo"
fi
if prompt_default_no "Install/update Cargo subcommands?"; then
cargo install \
cargo-bloat \
cargo-deadlinks \
cargo-depgraph \
cargo-download \
cargo-duplicates \
cargo-expand \
cargo-llvm-cov \
cargo-modules \
cargo-mutants \
cargo-nextest \
cargo-outdated \
cargo-udeps \
cargo-watch \
dprint \
dump_syms \
minidump-stackwalk \
rustfilt \
tree-sitter-cli \
wild-linker \
;
fi
fi # Rust
download_and_install_mold() {
local version="$1"
local version_no_v
version_no_v=$(echo -n "$version" | sed -En 's/v(.*)/\1/p')
local artifact="mold-$version_no_v-x86_64-linux.tar.gz"
pushd /tmp || exit 1
debug "downloading $artifact ..."
github_download_release "rui314/mold" "$version" "$artifact"
debug "installing ..."
tar -C ~/.local/ --strip-components=1 -xzvf "$artifact"
popd || exit 1
}
if prompt_default_no "Install/update mold?"; then
latest_version="$(github_latest_release_tag "rui314/mold")"
if command mold --version &>/dev/null; then
installed_version="v$(mold --version | cut -d ' ' -f 2)"
debug "Found installed mold version: $installed_version"
if [[ "$installed_version" != "$latest_version" ]]; then
info "Found newer mold version: $latest_version"
download_and_install_mold "$latest_version"
else
info "Mold $latest_version already installed"
if prompt_default_no "Reinstall mold?"; then
download_and_install_mold "$latest_version"
fi
fi
else
info "Mold not installed. Installing mold $latest_version..."
download_and_install_mold "$latest_version"
fi
fi # mold
if prompt_default_no "Install/update hadolint?"; then
docker pull hadolint/hadolint
fi
if prompt_default_no "Install/update GEP GDB plugin?"; then
pushd "$DOTFILES_SETUP_SCRIPT_DIR/thirdparty/GEP" || exit 1
git switch main
git pull
./install.sh
popd || exit 1
fi
if prompt_default_no "Install nvm?"; then
latest_version=$(github_latest_release_tag "nvm-sh/nvm")
info "Found latest nvm version: $latest_version"
if [[ -d "$HOME/.nvm" ]]; then
debug "nvm already installed to ~/.nvm. Updating..."
pushd "$HOME/.nvm" || exit 1
git switch master
git pull
popd || exit 1
else
debug "nvm not found. Installing nvm..."
curl --fail --show-error -o- "https://raw.githubusercontent.com/nvm-sh/nvm/$latest_version/install.sh" | bash
fi
# Source nvm so we can use it in following setup steps
# shellcheck disable=SC1091
\. "$HOME/.nvm/nvm.sh"
fi
if prompt_default_no "Install nodejs?"; then
nvm install 22
node -v
npm -v
fi
if prompt_default_no "Install/update prettier?"; then
npm install --global prettier
fi