Harden Noble build and configuration lifecycle
This commit is contained in:
@@ -68,9 +68,10 @@ bash /tmp/install-niri.sh --config-only
|
|||||||
- Rust 工具链隔离在 `~/.local/share/niri-beyond-glass`
|
- Rust 工具链隔离在 `~/.local/share/niri-beyond-glass`
|
||||||
- 配置安装后使用 `niri validate` 校验
|
- 配置安装后使用 `niri validate` 校验
|
||||||
|
|
||||||
备份位于:
|
首次安装前的原配置和更新快照位于:
|
||||||
|
|
||||||
```text
|
```text
|
||||||
|
~/.local/state/niri-beyond-glass/original/
|
||||||
~/.local/state/niri-beyond-glass/backups/
|
~/.local/state/niri-beyond-glass/backups/
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,6 @@ environment {
|
|||||||
|
|
||||||
spawn-at-startup "xwayland-satellite"
|
spawn-at-startup "xwayland-satellite"
|
||||||
spawn-at-startup "sh" "-lc" "$HOME/.local/bin/niri-beyond-wallpaper"
|
spawn-at-startup "sh" "-lc" "$HOME/.local/bin/niri-beyond-wallpaper"
|
||||||
spawn-at-startup "waybar"
|
|
||||||
spawn-at-startup "mako"
|
|
||||||
spawn-at-startup "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1"
|
spawn-at-startup "/usr/lib/policykit-1-gnome/polkit-gnome-authentication-agent-1"
|
||||||
spawn-at-startup "swayidle" "-w" "timeout" "600" "swaylock -f" "timeout" "660" "niri msg action power-off-monitors" "resume" "niri msg action power-on-monitors" "before-sleep" "swaylock -f"
|
spawn-at-startup "swayidle" "-w" "timeout" "600" "swaylock -f" "timeout" "660" "niri msg action power-off-monitors" "resume" "niri msg action power-on-monitors" "before-sleep" "swaylock -f"
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
"margin-right": 8,
|
"margin-right": 8,
|
||||||
"modules-left": ["custom/launcher"],
|
"modules-left": ["custom/launcher"],
|
||||||
"modules-center": [],
|
"modules-center": [],
|
||||||
"modules-right": ["tray", "network", "pulseaudio", "battery", "clock", "custom/lock", "custom/power"],
|
"modules-right": ["tray", "network", "pulseaudio", "battery", "custom/lock", "custom/power", "clock"],
|
||||||
"custom/launcher": {
|
"custom/launcher": {
|
||||||
"format": " \uf141 ",
|
"format": " \uf141 ",
|
||||||
"tooltip": false,
|
"tooltip": false,
|
||||||
|
|||||||
+28
-7
@@ -46,7 +46,9 @@ run() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cleanup() {
|
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
|
trap cleanup EXIT
|
||||||
|
|
||||||
@@ -117,7 +119,7 @@ install_packages() {
|
|||||||
run sudo apt-get update
|
run sudo apt-get update
|
||||||
run sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
run sudo env DEBIAN_FRONTEND=noninteractive apt-get install -y \
|
||||||
build-essential clang git curl ca-certificates pkg-config \
|
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 \
|
libudev-dev libgbm-dev libxkbcommon-dev libegl1-mesa-dev \
|
||||||
libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev \
|
libwayland-dev libinput-dev libdbus-1-dev libsystemd-dev \
|
||||||
libseat-dev libpipewire-0.3-dev libpango1.0-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"
|
printf '+ curl https://sh.rustup.rs | sh -s -- -y --no-modify-path --profile minimal --default-toolchain %q\n' "$RUST_TOOLCHAIN"
|
||||||
return
|
return
|
||||||
fi
|
fi
|
||||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs |
|
local rustup_installer
|
||||||
sh -s -- -y --no-modify-path --profile minimal --default-toolchain "$RUST_TOOLCHAIN"
|
rustup_installer="$(mktemp)"
|
||||||
else
|
curl --proto '=https' --tlsv1.2 -fsSL --retry 5 --retry-all-errors \
|
||||||
run "$CARGO_HOME/bin/rustup" toolchain install "$RUST_TOOLCHAIN" --profile minimal
|
https://sh.rustup.rs -o "$rustup_installer"
|
||||||
run "$CARGO_HOME/bin/rustup" default "$RUST_TOOLCHAIN"
|
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
|
fi
|
||||||
|
|
||||||
|
run "$CARGO_HOME/bin/rustup" set auto-self-update disable
|
||||||
|
run "$CARGO_HOME/bin/rustup" default "$RUST_TOOLCHAIN"
|
||||||
}
|
}
|
||||||
|
|
||||||
version_ge() {
|
version_ge() {
|
||||||
@@ -229,6 +239,7 @@ backup_and_install_config() {
|
|||||||
local stamp
|
local stamp
|
||||||
stamp="$(date +%Y%m%d-%H%M%S)"
|
stamp="$(date +%Y%m%d-%H%M%S)"
|
||||||
local backup="$state_home/$PROJECT/backups/$stamp/config"
|
local backup="$state_home/$PROJECT/backups/$stamp/config"
|
||||||
|
local original="$state_home/$PROJECT/original"
|
||||||
local names=(niri waybar fuzzel mako swaylock niri-beyond-glass)
|
local names=(niri waybar fuzzel mako swaylock niri-beyond-glass)
|
||||||
|
|
||||||
log "备份并安装用户配置"
|
log "备份并安装用户配置"
|
||||||
@@ -240,6 +251,16 @@ backup_and_install_config() {
|
|||||||
fi
|
fi
|
||||||
done
|
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 \
|
run mkdir -p \
|
||||||
"$config_home/niri" \
|
"$config_home/niri" \
|
||||||
"$config_home/waybar" \
|
"$config_home/waybar" \
|
||||||
|
|||||||
+4
-1
@@ -4,9 +4,12 @@ set -euo pipefail
|
|||||||
config_home="${XDG_CONFIG_HOME:-$HOME/.config}"
|
config_home="${XDG_CONFIG_HOME:-$HOME/.config}"
|
||||||
state_home="${XDG_STATE_HOME:-$HOME/.local/state}"
|
state_home="${XDG_STATE_HOME:-$HOME/.local/state}"
|
||||||
backup_root="$state_home/niri-beyond-glass/backups"
|
backup_root="$state_home/niri-beyond-glass/backups"
|
||||||
|
original_root="$state_home/niri-beyond-glass/original"
|
||||||
latest=""
|
latest=""
|
||||||
|
|
||||||
if [[ -d "$backup_root" ]]; then
|
if [[ -e "$original_root/.captured" ]]; then
|
||||||
|
latest="$original_root"
|
||||||
|
elif [[ -d "$backup_root" ]]; then
|
||||||
latest="$(find "$backup_root" -mindepth 1 -maxdepth 1 -type d -printf '%p\n' | sort | tail -n 1)"
|
latest="$(find "$backup_root" -mindepth 1 -maxdepth 1 -type d -printf '%p\n' | sort | tail -n 1)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user