consistent license, various updates
[buildscripts] / rust
diff --git a/rust b/rust
index 5ed2870e32fcf374b4b8c682ee7cfc866ccfa12d..58009fe2664e796e3568efec6c85e18bcd03b7ae 100755 (executable)
--- a/rust
+++ b/rust
@@ -1,11 +1,27 @@
 #!/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.
 
-# alternatively, using https://iankelling.org/git/?p=errhandle;a=tree
-# source /path/errhandle/err
-# on my machine
-source /a/bin/errhandle/err
+# 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"
@@ -17,7 +33,16 @@ hash -r
 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
 
 if ! which rg &>/dev/null; then
@@ -32,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