X-Git-Url: https://iankelling.org/git/?p=buildscripts;a=blobdiff_plain;f=rust;h=38d2a6058405ff713a804682cd313ebb485ec42e;hp=08aea33679f53721af1df82b812a22c90ed1d33f;hb=HEAD;hpb=65a0d6984b02937e49093c32c37b5cfbc26e3b79 diff --git a/rust b/rust index 08aea33..58009fe 100755 --- a/rust +++ b/rust @@ -1,28 +1,50 @@ #!/bin/bash -# Copyright (C) 2019 Ian Kelling -# SPDX-License-Identifier: AGPL-3.0-or-later - -if [ -z "$BASH_VERSION" ]; then echo "error: shell is not bash" >&2; exit 1; fi - -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 +# 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. + +# Copyright 2024 Ian Kelling + +# 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 @@ -35,3 +57,9 @@ if ! type -t cargo-install-update &>/dev/null; then 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