various 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 # install rust.
20 if type -t rustc &>/dev/null; then
21 rustup update
22 else
23 curl https://sh.rustup.rs -sSf | bash -s -- -y
24 fi
25 # todo: update this. updates in rust are stupidly complicate
26 if ! which rg &>/dev/null; then
27 cargo install ripgrep
28 fi
29
30 if ! type -t cargo-install-update &>/dev/null; then
31 # due to
32 # error: failed to run custom build command for `openssl-sys v0.9.53`
33 pi libssl-dev pkg-config
34 cargo install cargo-update
35 fi
36
37 cargo install-update -a