X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=rust;h=58009fe2664e796e3568efec6c85e18bcd03b7ae;hb=HEAD;hp=38d2a6058405ff713a804682cd313ebb485ec42e;hpb=e9fda13d66976d9d0934a3c21f218cedfde47ac8;p=buildscripts diff --git a/rust b/rust index 38d2a60..58009fe 100755 --- a/rust +++ b/rust @@ -1,30 +1,65 @@ #!/bin/bash -# Copyright (C) 2019 Ian Kelling -# SPDX-License-Identifier: AGPL-3.0-or-later +# I, Ian Kelling, follow the GNU license recommendations at +# https://www.gnu.org/licenses/license-recommendations.en.html. They +# recommend that small programs, < 300 lines, be licensed under the +# Apache License 2.0. This file contains or is part of one or more small +# programs. If a small program grows beyond 300 lines, I plan to switch +# its license to GPL. -if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi +# Copyright 2024 Ian Kelling -shopt -s inherit_errexit 2>/dev/null ||: # ignore fail in bash < 4.4 -set -eE -o pipefail -trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR -# alternatively, using https://iankelling.org/git/?p=errhandle;a=tree -# source /path/errhandle/err -# on my machine -source /a/bin/errhandle/err +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at + +# http://www.apache.org/licenses/LICENSE-2.0 + +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + + +source /a/bin/bash-bear-trap/bash-bear +source /a/bin/distro-functions/src/package-manager-abstractions + +PATH="$PATH:$HOME/.cargo/bin" +hash -r + +# todo: this should happen in some kind of sandbox or vm # install rust. if type -t rustc &>/dev/null; then rustup update else - curl https://sh.rustup.rs -sSf | bash -s -- -y + + # added stable due to this error +# Mar 11 00:13:15 info: no updatable toolchains installed +# Mar 11 00:13:15 info: checking for self-update +# Mar 11 00:13:15 info: cleaning up downloads & tmp directories +# Mar 11 00:13:15 error: rustup could not choose a version of cargo to run, because one wasn't specified explicitly, and no default is configured. +# Mar 11 00:13:15 help: run 'rustup default stable' to download the latest stable release of Rust and set it as your default toolchain. +# Mar 11 00:13:15 /a/bin/buildscripts/rust:31: `cargo install-update -a' returned 1 + + curl https://sh.rustup.rs -sSf | bash -s -- --default-toolchain stable -y fi -# todo: update this. updates in rust are stupidly complicate + if ! which rg &>/dev/null; then cargo install ripgrep fi if ! type -t cargo-install-update &>/dev/null; then + # due to + # error: failed to run custom build command for `openssl-sys v0.9.53` + pi libssl-dev pkg-config cargo install cargo-update fi cargo install-update -a + +# https://github.com/rust-lang/cargo/issues/3289 +# 149 mb on fresh install as of 07-2023 +if du -s -t 500M ~/.cargo/registry | grep . &>/dev/null; then + rm -rf ~/.cargo/registry +fi