mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-09-14 06:02:35 +00:00
zram menu refactor, mesa fix & sysinfo ui
- Refactored `install_zram` into a dedicated submenu (`zram_menu`) within `modules/zram.sh`. Split monolithic logic into three distinct operations: `_zram_view`, `_zram_create`, and `_zram_remove`. Enables status verification before installation and safe cleanup. Updated main menu entry in `debianito.sh` to call the new sub-menu. - Resolved Trixie backports dependency conflicts between `mesa-libgallium` and `mesa-va-drivers` (Mesa 26+). Modified package lists in `_helpers.sh` and `gpu.sh` to exclude `mesa-va-drivers` during backports installs, prioritizing `mesa-vulkan-drivers` for stable Gallium integration. - Implemented dynamic dimensioning in `_show_sysinfo()`. Calculates optimal width/height based on terminal size (`tput cols`) and content length. Truncates long lines to prevent UI overflow in small terminals, capped at 22-line height.
This commit is contained in:
+5
-1
@@ -27,7 +27,11 @@ _install_amd_intel_stack() {
|
||||
header+="${comp_line}\n\n"
|
||||
header+="Choose version:"
|
||||
if _confirm_custom "No GPU Detected" "$header" "Backports" "Stable" 14 70; then
|
||||
_run_cmd "Mesa" "sudo apt install -y -t ${DEBIAN_CODENAME}-backports ${mesa_pkgs[*]}" \
|
||||
local _bpo_list=()
|
||||
for _p in "${mesa_pkgs[@]}"; do
|
||||
[ "$_p" != "mesa-va-drivers" ] && _bpo_list+=("$_p")
|
||||
done
|
||||
_run_cmd "Mesa" "sudo apt install -y -t ${DEBIAN_CODENAME}-backports ${_bpo_list[*]}" \
|
||||
"Installing Mesa from backports..."
|
||||
else
|
||||
_run_cmd "Mesa" "sudo apt install -y ${mesa_pkgs[*]}" \
|
||||
|
||||
@@ -133,6 +133,14 @@ _install_mesa_backports() {
|
||||
fi
|
||||
done
|
||||
|
||||
# Mesa >= 25.3.3 unificó VA-API dentro de mesa-libgallium.
|
||||
# mesa-va-drivers desde backports rompe con la nueva mesa-libgallium.
|
||||
local _bpo_filtered=()
|
||||
for _p in "${bpo_pkgs[@]}"; do
|
||||
[ "$_p" != "mesa-va-drivers" ] && _bpo_filtered+=("$_p")
|
||||
done
|
||||
bpo_pkgs=("${_bpo_filtered[@]}")
|
||||
|
||||
local ref_ver
|
||||
ref_ver=$(apt-cache policy mesa-vulkan-drivers 2>/dev/null | awk 'NR==3 {print $2; exit}')
|
||||
local ref_bpo_ver
|
||||
|
||||
+37
-1
@@ -200,5 +200,41 @@ _show_sysinfo() {
|
||||
fi
|
||||
fi
|
||||
|
||||
_msg "System Information" "$msg" 22 76
|
||||
# ════════════════════════════════════════════════════════════
|
||||
# Dynamic dimension calculation
|
||||
# ════════════════════════════════════════════════════════════
|
||||
|
||||
local term_cols
|
||||
term_cols=$(tput cols 2>/dev/null || echo 80)
|
||||
[ "$term_cols" -lt 50 ] && term_cols=50
|
||||
|
||||
local max_pct=$(( term_cols * 95 / 100 ))
|
||||
[ "$max_pct" -lt 50 ] && max_pct=50
|
||||
|
||||
local longest=0
|
||||
while IFS= read -r line; do
|
||||
local len=${#line}
|
||||
[ "$len" -gt "$longest" ] && longest=$len
|
||||
done < <(echo -e "$msg")
|
||||
|
||||
local width=$(( longest + 6 ))
|
||||
[ "$width" -lt 80 ] && width=80
|
||||
[ "$width" -gt "$max_pct" ] && width=$max_pct
|
||||
|
||||
local truncated=""
|
||||
while IFS= read -r line; do
|
||||
if [ ${#line} -gt "$width" ]; then
|
||||
truncated+="${line:0:$((width - 4))}...\\n"
|
||||
else
|
||||
truncated+="${line}\\n"
|
||||
fi
|
||||
done < <(echo -e "$msg")
|
||||
|
||||
local lines
|
||||
lines=$(echo -e "$truncated" | wc -l)
|
||||
local height=$(( lines + 6 ))
|
||||
[ "$height" -gt 22 ] && height=22
|
||||
[ "$height" -lt 10 ] && height=10
|
||||
|
||||
_msg "System Information" "$truncated" "$height" "$width"
|
||||
}
|
||||
|
||||
+105
-6
@@ -1,14 +1,90 @@
|
||||
#!/usr/bin/env bash
|
||||
# zram.sh - Configure compressed swap in RAM
|
||||
# zram.sh — ZRAM submenu: view, create/reconfigure, remove
|
||||
|
||||
install_zram() {
|
||||
echo -e "${YELLOW}ZRAM Configuration${NC}"
|
||||
zram_menu() {
|
||||
while true; do
|
||||
local choice
|
||||
choice=$(_menu "ZRAM Configuration" \
|
||||
"Select an operation:" $TUI_ALTO $TUI_ANCHO 4 \
|
||||
"1" "View ZRAM status" \
|
||||
"2" "Create / Reconfigure ZRAM" \
|
||||
"3" "Remove ZRAM" \
|
||||
"4" "Back to main menu")
|
||||
|
||||
[ -z "$choice" ] && break
|
||||
clear
|
||||
|
||||
case "$choice" in
|
||||
1) _zram_view ;;
|
||||
2) _zram_create ;;
|
||||
3) _zram_remove ;;
|
||||
4) break ;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
_zram_view() {
|
||||
if ! is_installed "zram-tools"; then
|
||||
_msg "ZRAM Status" "ZRAM is not installed.\n\nUse option 2 (Create / Reconfigure ZRAM)\nto set it up." 10 55
|
||||
return
|
||||
fi
|
||||
|
||||
local algo="" size="" priority=""
|
||||
if [ -f /etc/default/zramswap ]; then
|
||||
while IFS='=' read -r key val; do
|
||||
case "$key" in
|
||||
ALGO) algo=$val ;;
|
||||
SIZE) size=$val ;;
|
||||
PRIORITY) priority=$val ;;
|
||||
esac
|
||||
done < /etc/default/zramswap
|
||||
fi
|
||||
|
||||
local info="ZRAM Configuration:\n"
|
||||
info+=" Algorithm: ${algo:-not set}\n"
|
||||
info+=" Size: ${size:-not set} MB\n"
|
||||
info+=" Priority: ${priority:-not set}\n\n"
|
||||
info+="Active ZRAM devices:\n"
|
||||
|
||||
local zram_out
|
||||
zram_out=$(sudo zramctl 2>/dev/null || true)
|
||||
if [ -n "$zram_out" ]; then
|
||||
info+="$zram_out"
|
||||
else
|
||||
info+=" (none — service may be stopped)"
|
||||
fi
|
||||
|
||||
_msg "ZRAM Status" "$info" 16 70
|
||||
}
|
||||
|
||||
_zram_create() {
|
||||
if [ -z "$RAM_KB" ] || [ "$RAM_KB" -eq 0 ]; then
|
||||
echo -e "${RED}Could not determine RAM size. Aborting.${NC}"
|
||||
return 1
|
||||
fi
|
||||
|
||||
if is_installed "zram-tools"; then
|
||||
local cur_algo="" cur_size="" cur_prio=""
|
||||
if [ -f /etc/default/zramswap ]; then
|
||||
while IFS='=' read -r key val; do
|
||||
case "$key" in
|
||||
ALGO) cur_algo=$val ;;
|
||||
SIZE) cur_size=$val ;;
|
||||
PRIORITY) cur_prio=$val ;;
|
||||
esac
|
||||
done < /etc/default/zramswap
|
||||
fi
|
||||
local cur="ZRAM is already configured:\n"
|
||||
cur+=" Algorithm: ${cur_algo:-not set}\n"
|
||||
cur+=" Size: ${cur_size:-not set} MB\n"
|
||||
cur+=" Priority: ${cur_prio:-not set}\n\n"
|
||||
cur+="Continuing will overwrite this configuration."
|
||||
if ! _confirm "ZRAM — Reconfigure" "$cur"; then
|
||||
echo "ZRAM reconfiguration cancelled."
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
local half_ram_mb=$(( ((RAM_KB / 1024 / 1024 + 1) / 2) * 1024 ))
|
||||
|
||||
local algo
|
||||
@@ -20,7 +96,7 @@ install_zram() {
|
||||
|
||||
if [ -z "$algo" ]; then
|
||||
echo "ZRAM configuration cancelled."
|
||||
return 0
|
||||
return
|
||||
fi
|
||||
|
||||
local zram_size
|
||||
@@ -30,13 +106,13 @@ install_zram() {
|
||||
zram_size=$(_inputbox "ZRAM Size" "Enter ZRAM size in MB:" 8 60 "$half_ram_mb")
|
||||
if [ -z "$zram_size" ] || ! [[ "$zram_size" =~ ^[0-9]+$ ]] || [ "$zram_size" -eq 0 ]; then
|
||||
echo "ZRAM configuration cancelled."
|
||||
return 0
|
||||
return
|
||||
fi
|
||||
fi
|
||||
|
||||
if ! _confirm "ZRAM Summary" "Algorithm: ${algo}\nSize: ${zram_size} MB\nPriority: 100\n\nApply?"; then
|
||||
echo "ZRAM configuration cancelled."
|
||||
return 0
|
||||
return
|
||||
fi
|
||||
|
||||
_run_cmd "ZRAM" "sudo apt install -y zram-tools" "Installing zram-tools..."
|
||||
@@ -59,3 +135,26 @@ EOF
|
||||
echo -e "${GREEN}You can verify with: sudo zramctl${NC}"
|
||||
_pause
|
||||
}
|
||||
|
||||
_zram_remove() {
|
||||
if ! is_installed "zram-tools"; then
|
||||
_msg "ZRAM Remove" "ZRAM is not installed.\n\nNothing to remove." 10 50
|
||||
return
|
||||
fi
|
||||
|
||||
if ! _confirm "Remove ZRAM" \
|
||||
"This will:\n - Stop the zramswap service\n - Purge zram-tools\n - Remove /etc/default/zramswap\n\nProceed?"; then
|
||||
echo "ZRAM removal cancelled."
|
||||
return
|
||||
fi
|
||||
|
||||
echo "Stopping zramswap service..."
|
||||
sudo systemctl stop zramswap || true
|
||||
|
||||
_run_cmd "ZRAM" "sudo apt purge -y zram-tools" "Purging zram-tools..."
|
||||
|
||||
echo "Removing configuration..."
|
||||
sudo rm -f /etc/default/zramswap
|
||||
|
||||
_msg "ZRAM Removed" "ZRAM has been removed successfully.\n\nThe zramswap service is stopped and disabled." 10 55
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user