Harden Noble build and configuration lifecycle
This commit is contained in:
+28
-7
@@ -46,7 +46,9 @@ run() {
|
||||
}
|
||||
|
||||
cleanup() {
|
||||
[[ -n "$tmp_dir" && -d "$tmp_dir" ]] && rm -rf "$tmp_dir"
|
||||
if [[ -n "$tmp_dir" && -d "$tmp_dir" ]]; then
|
||||
rm -rf "$tmp_dir"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
@@ -117,7 +119,7 @@ install_packages() {
|
||||
run sudo apt-get update
|
||||
run sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||
build-essential clang git curl ca-certificates pkg-config \
|
||||
meson ninja-build cmake \
|
||||
meson ninja-build cmake hwdata \
|
||||
libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev \
|
||||
libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev \
|
||||
libseat-dev libpipewire-0.3-dev libpango1.0-dev \
|
||||
@@ -142,12 +144,20 @@ install_rust() {
|
||||
printf '+ curl https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain %q\n' "$RUST_TOOLCHAIN"
|
||||
return
|
||||
fi
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |
|
||||
sh -s -- -y --no-modify-path --profile minimal --default-toolchain "$RUST_TOOLCHAIN"
|
||||
else
|
||||
run "$CARGO_HOME/bin/rustup" toolchain install "$RUST_TOOLCHAIN" --profile minimal
|
||||
run "$CARGO_HOME/bin/rustup" default "$RUST_TOOLCHAIN"
|
||||
local rustup_installer
|
||||
rustup_installer="$(mktemp)"
|
||||
curl --proto '=https' --tlsv1.2 -fsSL --retry 5 --retry-all-errors \
|
||||
https://sh.rustup.rs -o "$rustup_installer"
|
||||
RUSTUP_MAX_RETRIES=5 sh "$rustup_installer" -y --no-modify-path \
|
||||
--profile minimal --default-toolchain "$RUST_TOOLCHAIN"
|
||||
rm -f "$rustup_installer"
|
||||
elif ! "$CARGO_HOME/bin/rustup" run "$RUST_TOOLCHAIN" rustc --version >/dev/null 2>&1; then
|
||||
RUSTUP_MAX_RETRIES=5 run "$CARGO_HOME/bin/rustup" toolchain install \
|
||||
"$RUST_TOOLCHAIN" --profile minimal
|
||||
fi
|
||||
|
||||
run "$CARGO_HOME/bin/rustup" set auto-self-update disable
|
||||
run "$CARGO_HOME/bin/rustup" default "$RUST_TOOLCHAIN"
|
||||
}
|
||||
|
||||
version_ge() {
|
||||
@@ -229,6 +239,7 @@ backup_and_install_config() {
|
||||
local stamp
|
||||
stamp="$(date +%Y%m%d-%H%M%S)"
|
||||
local backup="$state_home/$PROJECT/backups/$stamp/config"
|
||||
local original="$state_home/$PROJECT/original"
|
||||
local names=(niri waybar fuzzel mako swaylock niri-beyond-glass)
|
||||
|
||||
log "备份并安装用户配置"
|
||||
@@ -240,6 +251,16 @@ backup_and_install_config() {
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ! -e "$original/.captured" ]]; then
|
||||
run mkdir -p "$original/config"
|
||||
for name in "${names[@]}"; do
|
||||
if [[ -e "$config_home/$name" ]]; then
|
||||
run cp -a "$config_home/$name" "$original/config/$name"
|
||||
fi
|
||||
done
|
||||
run touch "$original/.captured"
|
||||
fi
|
||||
|
||||
run mkdir -p \
|
||||
"$config_home/niri" \
|
||||
"$config_home/waybar" \
|
||||
|
||||
Reference in New Issue
Block a user