consistent license, various updates
[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
15 # install rust.
16 if type -t rustc &>/dev/null; then
17 rustup update
18 else
19 curl https://sh.rustup.rs -sSf | bash -s -- -y
20 fi
21 # todo: update this. updates in rust are stupidly complicate
22 if ! which rg &>/dev/null; then
23 cargo install ripgrep
24 fi
25
26 if ! type -t cargo-install-update &>/dev/null; then
27 cargo install cargo-update
28 fi
29
30 cargo install-update -a