fixes
[buildscripts] / rust
1 #!/bin/bash
2 # Copyright (C) 2019 Ian Kelling
3 # SPDX-License-Identifier: AGPL-3.0-or-later
4
5 if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi
6
7 shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4
8 set -eE -o pipefail
9 trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR
10 # alternatively, using https://iankelling.org/git/?p=errhandle;a=tree
11 # source /path/errhandle/err
12 # on my machine
13 source /a/bin/errhandle/err
14 source /a/bin/distro-functions/src/package-manager-abstractions
15
16 PATH="$PATH:$HOME/.cargo/bin"
17 hash -r
18
19 # todo: this should happen in some kind of sandbox or vm
20
21 # install rust.
22 if type -t rustc &>/dev/null; then
23 rustup update
24 else
25 curl https://sh.rustup.rs -sSf | bash -s -- -y
26 fi
27
28 if ! which rg &>/dev/null; then
29 cargo install ripgrep
30 fi
31
32 if ! type -t cargo-install-update &>/dev/null; then
33 # due to
34 # error: failed to run custom build command for `openssl-sys v0.9.53`
35 pi libssl-dev pkg-config
36 cargo install cargo-update
37 fi
38
39 cargo install-update -a