mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-10-31 13:08:06 +00:00
89233b0750
- `.github/workflows/ci.yml` added as a new workflow: job `lint-and-test` on `runs-on: ubuntu-latest` with `container: debian:trixie`, checking out via `actions/checkout@v4`, installing `bats` and `shellcheck`, running `shellcheck --severity=error debianito.sh modules/**/*.sh` (with `shopt -s globstar`) and `bats tests/`.
- `debianito.sh` CLI parser: `AUTO_YES=0`, `ALLOW_DESTRUCTIVE=0` declared after `MODULES_DIR` and before `_boot_mark`; `_usage()` prints `Usage: debianito.sh [OPTIONS]` with `--yes`, `--allow-destructive` and `--help`; the `while [ $# -gt 0 ]` / `case` loop consumes `--yes` and `--allow-destructive`, prints `Unknown option: $1 (run with --help for usage)` to stderr and `exit 2` for unknown flags, and `--help|-h` runs `_usage` then `exit 0`.
- `modules/utils.sh`: new global `_SELECTION_CONFIRMED=0` and `_confirm_install_list()` (utils.sh:756-785), which renders items capped at 15 with `... and N more`, computes `height` capped at 24, calls `_confirm "$title" "$list" "$height" 65`, arms `_SELECTION_CONFIRMED=${#items[@]}` on yes, and returns 1 for an empty list or on decline. `_install_pkg()` (utils.sh:789-804) decrements the countdown instead of prompting, and only prompts via `elif ! _confirm "Install: ${pkg}" "Install ${pkg}\nVersion: ${ver}?"; then return 0`.
- Bulk retrofit in `modules/extras/**/*.sh` (18 sites): `_confirm_install_list "Título" "${array[@]}" || return` placed right after the `whiptail` selection is parsed, the install loop left intact, and `_SELECTION_CONFIRMED=0` after the loop. Files: office/office.sh:101, system/software_centers.sh:29, system/system.sh:133, communication/communication.sh:68, design/design.sh:42, download/download.sh:48+55, terminals/terminals.sh:31, security/security.sh:30, players/players.sh:20, themes/fonts/fonts.sh:32, dev/dev.sh:44, programming/programming.sh:57, themes/desktop-themes/desktop-themes.sh:30, fetch/fetch.sh:41, themes/icons/icons.sh:47, themes/cursors/cursors.sh:28, internet/internet.sh:197, java.
- `modules/bullseye/extras.sh` (13 sites) plus `modules/bullseye/legacy.sh` (1 site, `install_gaming_bullseye`, guarded with `if [ ${#_install_pkgs[@]} -gt 0 ]` so a i386-only selection does not blank the summary) plus `modules/desktop_display.sh` (1 site, XFCE Custom — a no-loop `_run_cmd` batch with the reset immediately after it). Special cases: download.sh and bullseye/download each have two checklists merged into one combined summary; legacy.sh gaming skips the reset when the list is empty; XFCE Custom resets before `_xfce_polkit_rules` so the counter cannot leak.
- `modules/desktops/desktop_gnome.sh` (new): `gnome_menu()` runs a `_radiolist` with "1" "GNOME (Full Desktop)", "2" "GNOME Core (Minimal Install)", "3" "Back", then `_install_gnome_full()` and `_install_gnome_core()`. Each arms `_confirm_install_list "GNOME Full Desktop" gnome gdm3 || return` (core: `gnome-core gdm3`), keeps an already-configured display manager via `_existing_display_manager` by setting `target_dm="$keep_dm"`, writes the preseed `echo "${target_dm} shared/default-x-display-manager select ${target_dm}" | sudo debconf-set-selections`, installs `sudo apt install -y gnome gdm3` / `gnome-core gdm3`, enables `gdm3` only when `target_dm = "gdm3"`, resets `_SELECTION_CONFIRMED=0` and calls `_offer_pipewire_after_desktop`.
- `modules/desktops/desktop_kde.sh` (new): `kde_menu()` runs a `_radiolist` with "1" "KDE Plasma (Full Desktop)", "2" "KDE Plasma Desktop (Minimal)", "3" "Back"; `_install_kde_full()` and `_install_kde_minimal()` arm `_confirm_install_list "KDE Plasma Full" kde-standard sddm || return` (minimal: `kde-plasma-desktop sddm`), preseed `sddm shared/default-x-display-manager select sddm`, install `sudo apt install -y kde-standard sddm` / `kde-plasma-desktop sddm`, enable `sddm` only when it is the target DM, reset the counter and offer PipeWire.
- `modules/desktop_display.sh` `desktop_environment_menu()`: `env_items+=("3" "GNOME")`, `env_items+=("4" "KDE Plasma")`, `env_items+=("5" "Back")`; the case adds `3)` loading `gnome` via `_load_module gnome || continue` and calling `gnome_menu`, and `4)` loading `kde` via `_load_module kde || continue` and calling `kde_menu`; the dead TODO comment was removed.
- PipeWire retrofit in `modules/desktop_display.sh` (6 sites): `_install_lxde_full`, `_install_lxde_core`, `_install_xfce_full`, `_install_xfce_minimal`, `_install_xfce_wayland` and `_install_xfce_custom` each call `_offer_pipewire_after_desktop` after their install block.
- `_offer_pipewire_after_desktop()` and `_existing_display_manager()` added at the end of `modules/desktop_display.sh`: `_offer_pipewire_after_desktop` checks `pipewire-audio` (`pipewire` when `DEBIAN_VERSION = 11`), returns 0 via `is_installed`, otherwise `_confirm "PipeWire Audio" "No PipeWire audio server is installed.\n\nInstall the PipeWire audio stack (recommended)?"` calls `_install_pipewire_standard` and returns 0. `_existing_display_manager` reads `${DM_FILE:-/etc/X11/default-display-manager}`, reads the basename as the DM, and otherwise scans `gdm3 lightdm sddm greetd gdm` with `systemctl is-enabled`, printing nothing when none is found.
- `_ensure_apt_updated` added before the GNOME/KDE `apt install` transactions (4 sites, deduplicated per session); `gnome gdm3` and `kde-standard sddm` are installed alongside even when another display manager is kept as the default.
- Extraction to `modules/desktops/`: `desktop_lxde.sh` (38 lines) and `desktop_xfce.sh` (119 lines) created with the `lxde_menu` / `_install_lxde_full` / `_install_lxde_core` and `xfce_menu` / `_install_xfce_full` / `_install_xfce_minimal` / `_install_xfce_wayland` / `_install_xfce_custom` / `_xfce_polkit_rules` blocks moved verbatim; both carry `# License GPL v3` in their headers.
- `modules/desktop_display.sh` reduced from 542 to 394 lines (−154): lines 55-208 removed, the dispatch (desktop_display.sh:39-46) replaced with `_load_module xfce || continue` / `lxde_menu`, and the file left with `manage_desktop_display`, `desktop_environment_menu`, `display_manager_menu`, `lightdm_config_menu`, `configure_greetd`, `configure_gdm3`, `configure_sddm`, the two shared helpers.
- `modules/utils.sh` `_load_module` map: `xfce)` → `${MODULES_DIR}/desktops/desktop_xfce.sh`, `lxde)` → `${MODULES_DIR}/desktops/desktop_lxde.sh`, `gnome)` → `${MODULES_DIR}/desktops/desktop_gnome.sh`, `kde)` → `${MODULES_DIR}/desktops/desktop_kde.sh`; deps for `xfce`, `lxde`, `gnome` and `kde` are `(desktop_display audio)` and `desktop_display` is `(repos audio)`.
- `modules/desktops/desktop_xfce.sh` `_xfce_polkit_rules()` writes `/etc/polkit-1/rules.d/85-suspend.rules` and `89-backlight.rules` via `sudo tee`, adds the `backlight` group with `groupadd --system` fallback, adds the real login user from `/etc/passwd` to `backlight` and restarts `polkit.service`.
- ES→EN user-facing strings: 14 strings across 4 files — `desktop_display.sh` `lxdе_menu` ("LXDE (Full Desktop)", "LXDE Core (Minimal Install)"), `gpu/nvidia.sh` Kepler legacy-driver notice ("Kepler GPU detected (GKxxx)… Install the legacy driver for Kepler?"), `bullseye/legacy.sh` ("Install NVIDIA driver?", "Skipping NVIDIA driver.", "Installing NVIDIA driver ${gpu_gen}...") and `bullseye/extras.sh` ("firmware-linux-nonfree provides drivers for… Install?").
- ES→EN internal comments: ~35 comments across 9 files — section headers in `_install_nvidia_standard`, `gpu/_helpers.sh` (lines 5, 113), `gpu/nvidia.sh` (lines 8-12, 19-22, 68-70, 167-172, 196, 239-253, 262-263, 275, 291, 336-338, 376), `gpu.sh` (lines 15-17), `bullseye/repos.sh` (line 2), `firmware.sh` (line 235, "--- Load verification ---"), `utils.sh` (lines 129, 132, 153 — timezone Paso 1/2/4) and `utils.sh:546,548`.
- set -e abort fix: `debianito.sh:149` now reads `_system_preferences_menu || true`, consistent with the other dispatch chains (14 of the 15 chains already had the guard); a declined pre-apply summary now leaves the TUI alive instead of terminating the script.
- `docs/desktops_display.md`: 4 hunks — intro now lists GNOME/GNOME Core/KDE Plasma/KDE Plasma Desktop/XFCE/XFCE Wayland/XFCE Custom/LXDE, a new "Modular layout" paragraph describing `modules/desktops/` and lazy loading, Block 1 rewritten into four environments, five new bullets (pre-apply summary, existing-DM preservation, PipeWire offer, stale-lists guard) and a Desktop Environment Packages table.
- `docs/quickstart.md` line 284: Desktop Environment entry expanded to pick from XFCE (full / minimal / Wayland `labwc` on Trixie / custom checklist), LXDE (full / core), GNOME (full / core) or KDE Plasma (full / minimal).
- `_existing_display_manager` now takes the config path via `local dm_file="${DM_FILE:-/etc/X11/default-display-manager}"` so the offline test suite never reads the real system file.
- `tests/test_helper.bash`: added `_mock_systemctl()` for `is-enabled` (units in `MOCK_SYSTEMCTL_ENABLED` report `enabled`, everything else `disabled`), `MOCK_SYSTEMCTL_ENABLED=""`, `WHIPTAIL_CALLS`/`MOCK_WHIPTAIL_OUTPUT`/`MOCK_WHIPTAIL_RC`, `MOCK_DPKG_INSTALLED` and the `systemctl` entry in the mock list and in `mock_reset()`.
- `tests/desktops.bats` created with 16 tests: `_existing_display_manager` (file read, file-preferred over an enabled unit, enabled-unit fallback, candidate order, missing file, nothing configured), `_offer_pipewire_after_desktop` (5 tests: skip-installed, accept-installs, decline-returns-0, Bullseye package name, wrong package name on 11), `_load_module` (4 tests for xfce/lxde/gnome/kde) and an unknown-module case; 17→33 tests total.
- `.github/workflows/ci.yml` shellcheck severity raised from `--severity=error` to `--severity=warning`.
- `debianito.sh`: `RED`, `GREEN`, `YELLOW`, `CYAN` and `NC` plus `AUTO_YES`, `ALLOW_DESTRUCTIVE` and `DEBIAN_CODENAME` are now `export`ed as cross-file globals.
- `modules/utils.sh`: `HAS_NVIDIA`, `DESKTOP_ENV`, `AUDIO_SERVER`, `DEBIAN_VERSION` and the other cross-file globals are `export`ed.
- `modules/extras/system/software_centers.sh` gained a `#!/usr/bin/env bash` shebang.
- `shellcheck` triage (v0.11.0, baseline `--severity=warning` 25 findings → 0): removed two dead-code lines (`headless` in `extras/dev/dev.sh`, orphan `dev_id` in `firmware.sh`); `SC2206` in `extras/dev/essential.sh` fixed by expanding `$comp_pkgs` to `"${comp_pkgs[@]}"`; `SC2010`/`SC2046` (3 sites) replaced `ls … | grep` with `compgen -G "…"`; `SC2155` (2 sites, `gpu.sh` and `rescue.sh`) split command substitutions into separate lines; `SC2166` in `repos.sh` replaced `-o` with `{ … || … }`; `SC2221`/`SC2222` (2 sites, `sysinfo.sh` and `utils.sh`) collapsed the `wl*|wlp*|wlo*|wlan*` alternation to `wl*`; `SC1090` in `extras.sh` gained a justification comment on the disable directive.
- Final verification: `bash -n` on all 15 modified `.sh` files and `set -euo pipefail` at `debianito.sh:3` both intact; `bats tests/` reports 33 ok / 0 failed; invariants `offers 11`, `confirm_install_list 39` and `_SELECTION_CONFIRMED=0 40` hold.
228 lines
8.3 KiB
Bash
228 lines
8.3 KiB
Bash
#!/usr/bin/env bash
|
|
# legacy.sh — Bullseye: hardware detection, NVIDIA legacy drivers, lightweight gaming
|
|
# License GPL v3
|
|
|
|
BULLSEYE_USE_ARCHIVE=false
|
|
BULLSEYE_USE_ARCHIVE_CHECKED=false
|
|
|
|
check_bullseye_archive_phase() {
|
|
$BULLSEYE_USE_ARCHIVE_CHECKED && return
|
|
BULLSEYE_USE_ARCHIVE_CHECKED=true
|
|
|
|
local current_year
|
|
local current_month
|
|
current_year=$(date +%Y)
|
|
current_month=$(date +%-m)
|
|
|
|
if [ "$current_year" -gt 2026 ] ||
|
|
{ [ "$current_year" -eq 2026 ] && [ "$current_month" -ge 9 ]; }; then
|
|
BULLSEYE_USE_ARCHIVE=true
|
|
fi
|
|
|
|
if $BULLSEYE_USE_ARCHIVE; then
|
|
# Idempotency guard: skip when sources.list already points to the archive
|
|
grep -q 'archive.debian.org' /etc/apt/sources.list 2>/dev/null && return 0
|
|
|
|
_msg "Debian 11 — Archive Phase" \
|
|
"Bullseye LTS support ended on 31 Aug 2026.\n\n\
|
|
The script can switch APT sources to archive.debian.org.\n\
|
|
No security updates will be available." 12 60
|
|
|
|
if ! _confirm "Debian 11 — Archive Phase" \
|
|
"Rewrite /etc/apt/sources.list to use archive.debian.org?\n\n\
|
|
A timestamped backup will be created before the change." 12 60; then
|
|
echo "Archive phase: keeping the current repository configuration."
|
|
return 0
|
|
fi
|
|
|
|
# Timestamped backup before rewriting (same convention as firmware.sh / gpu.sh)
|
|
if [ -f /etc/apt/sources.list ]; then
|
|
sudo cp /etc/apt/sources.list "/etc/apt/sources.list.backup.$(date +%Y%m%d_%H%M%S)"
|
|
fi
|
|
|
|
echo "Writing archive.debian.org sources..."
|
|
sudo tee /etc/apt/sources.list >/dev/null <<'EOF'
|
|
deb http://archive.debian.org/debian bullseye main contrib non-free
|
|
#deb http://archive.debian.org/debian-security bullseye-security main contrib non-free
|
|
# deb http://archive.debian.org/debian bullseye-updates main contrib non-free
|
|
# deb http://archive.debian.org/debian bullseye-backports main contrib non-free
|
|
EOF
|
|
|
|
# Refresh package lists; may fail on EOL archives (expired Release files)
|
|
echo "Running apt-get update (failures are expected on EOL archives)..."
|
|
sudo apt-get update || true
|
|
fi
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# NVIDIA driver installer for Bullseye (Kepler → 470, Fermi → 390)
|
|
# ---------------------------------------------------------------------------
|
|
install_nvidia_bullseye() {
|
|
echo -e "${YELLOW}NVIDIA GPU detected (Bullseye mode).${NC}"
|
|
|
|
local is_fermi
|
|
is_fermi=$(is_nvidia_fermi)
|
|
|
|
local nv_pkg=""
|
|
local gpu_gen=""
|
|
|
|
if [ "$is_fermi" = "true" ]; then
|
|
nv_pkg="nvidia-legacy-390xx-driver"
|
|
gpu_gen="Fermi"
|
|
else
|
|
# Bullseye: cualquier otra NVIDIA (Kepler incl.) → nvidia-driver (470)
|
|
nv_pkg="nvidia-driver"
|
|
gpu_gen="NVIDIA"
|
|
fi
|
|
|
|
local nv_ver
|
|
nv_ver=$(apt-cache policy "$nv_pkg" 2>/dev/null | awk 'NR==3 {print $2; exit}')
|
|
|
|
local msg="Source: Debian Bullseye Stable\n"
|
|
msg+="Driver: ${gpu_gen} — ${nv_pkg} ${nv_ver:-unknown}\n"
|
|
msg+="[+] firmware-misc-nonfree\n"
|
|
msg+="[+] nvidia-settings\n\n"
|
|
msg+="Install NVIDIA driver?"
|
|
|
|
if ! _confirm "NVIDIA — Bullseye" "$msg" 14 70; then
|
|
echo "Skipping NVIDIA driver."
|
|
NVIDIA_DRIVER_MODE=""
|
|
return 0
|
|
fi
|
|
|
|
_run_cmd "NVIDIA" \
|
|
"sudo apt install -y $nv_pkg firmware-misc-nonfree nvidia-settings" \
|
|
"Installing NVIDIA driver ${gpu_gen}..."
|
|
|
|
local i386_active=false
|
|
dpkg --print-foreign-architectures | grep -q i386 && i386_active=true
|
|
if $i386_active; then
|
|
local nv32_pkg="${nv_pkg}:i386"
|
|
local nv32_ver
|
|
nv32_ver=$(apt-cache policy "$nv32_pkg" 2>/dev/null | awk 'NR==3 {print $2; exit}')
|
|
if [ -n "$nv32_ver" ] && [ "$nv32_ver" != "(none)" ]; then
|
|
echo "Installing 32-bit compatibility for ${nv_pkg}..."
|
|
_run_cmd "NVIDIA 32-bit" "sudo apt install -y $nv32_pkg" \
|
|
"Installing NVIDIA 32-bit libraries..."
|
|
else
|
|
echo "No 32-bit compatibility package available for ${nv_pkg} on Bullseye."
|
|
fi
|
|
fi
|
|
|
|
export NVIDIA_DRIVER_MODE="stable"
|
|
echo -e "${GREEN}NVIDIA driver ${nv_pkg} installed. Reboot required.${NC}"
|
|
|
|
echo ""
|
|
echo "──────────────────────────────────────────────"
|
|
echo "Verifying DKMS module compilation:"
|
|
if command -v dkms &>/dev/null; then
|
|
dkms status 2>/dev/null | grep nvidia || echo "(no nvidia DKMS module found)"
|
|
else
|
|
echo "(dkms not installed)"
|
|
fi
|
|
echo ""
|
|
echo "If the line ends with 'installed' → module is OK."
|
|
echo "Otherwise check: dmesg | grep nvidia"
|
|
echo "──────────────────────────────────────────────"
|
|
}
|
|
|
|
# ---------------------------------------------------------------------------
|
|
# Lightweight Gaming for Bullseye — sin Steam, sin Heroic
|
|
# 32-bit Mesa/NVIDIA + gamemode + mangohud + goverlay + lutris
|
|
# ---------------------------------------------------------------------------
|
|
install_gaming_bullseye() {
|
|
# Hardware state is detected on demand; GPU_TYPE is
|
|
# consulted below for the 32-bit driver choice.
|
|
_ensure_state_detected
|
|
|
|
echo -e "${YELLOW}Gaming setup (Bullseye)...${NC}"
|
|
|
|
local choices
|
|
choices=$(_checklist "Gaming Setup — Bullseye" \
|
|
"Check [*] the packages you want installed/updated on your system.\n" $TUI_ALTO $TUI_ANCHO $TUI_ALTO_LISTA \
|
|
"i386" "Enable 32-bit (i386) architecture" ON \
|
|
"steam" "Steam (requires 32-bit support)" ON \
|
|
"mangohud" "Performance overlay (Vulkan/OpenGL)" ON \
|
|
"gamemode" "Game performance optimization" OFF \
|
|
"goverlay" "MangoHud config GUI" ON \
|
|
"java" "Minecraft Java Runtime" OFF \
|
|
"lutris" "Lutris + Wine (requires 32-bit support)" OFF \
|
|
"retroarch" "RetroArch Emulator Frontend" OFF)
|
|
|
|
if [ -z "$choices" ]; then
|
|
echo "No gaming packages selected."
|
|
_pause
|
|
return
|
|
fi
|
|
|
|
local cleaned
|
|
cleaned=$(echo "$choices" | tr -d '"')
|
|
|
|
local need_32bit=false
|
|
# BH-004: Convert to array to avoid word splitting and injection.
|
|
local -a _pkgs=()
|
|
while IFS= read -r _pkg; do
|
|
[ -n "$_pkg" ] && _pkgs+=("$_pkg")
|
|
done < <(echo "$cleaned" | tr ' ' '\n')
|
|
for p in "${_pkgs[@]}"; do
|
|
case $p in steam | lutris) need_32bit=true ;; esac
|
|
done
|
|
echo "$cleaned" | grep -qw i386 && need_32bit=true
|
|
|
|
local install_list
|
|
install_list=$(echo "$cleaned" | tr ' ' '\n' | grep -v '^i386$' | tr '\n' ' ')
|
|
install_list=${install_list% }
|
|
|
|
if $need_32bit && ! dpkg --print-foreign-architectures 2>/dev/null | grep -q i386; then
|
|
echo -e "${YELLOW}Enabling i386 architecture...${NC}"
|
|
sudo dpkg --add-architecture i386
|
|
_ensure_apt_updated
|
|
fi
|
|
|
|
if $need_32bit; then
|
|
echo "Installing 32-bit graphics drivers..."
|
|
if [ "$GPU_TYPE" = "nvidia" ]; then
|
|
_install_nvidia_32bit
|
|
else
|
|
_install_mesa_32bit
|
|
fi
|
|
fi
|
|
|
|
# BH-004: Convert to array to avoid word splitting and injection.
|
|
local -a _install_pkgs=()
|
|
while IFS= read -r _pkg; do
|
|
[ -n "$_pkg" ] && _install_pkgs+=("$_pkg")
|
|
done < <(echo "$install_list" | tr ' ' '\n')
|
|
|
|
# Pre-apply summary: confirm the selection before the
|
|
# package installation starts. Skipped when only the
|
|
# i386 pseudo-entry was selected.
|
|
if [ ${#_install_pkgs[@]} -gt 0 ]; then
|
|
_confirm_install_list "Gaming Setup — Bullseye" "${_install_pkgs[@]}" || return
|
|
fi
|
|
for pkg in "${_install_pkgs[@]}"; do
|
|
case $pkg in
|
|
steam)
|
|
if ensure_contrib_repo; then
|
|
install_steam
|
|
else
|
|
echo -e "${YELLOW}Skipping Steam installation (contrib repository not enabled).${NC}"
|
|
fi
|
|
;;
|
|
java) install_minecraft_java ;;
|
|
mangohud) install_mangohud ;;
|
|
gamemode) install_gamemode ;;
|
|
goverlay) install_goverlay ;;
|
|
lutris) install_lutris ;;
|
|
retroarch) install_retroarch ;;
|
|
*) _run_install "$pkg" ;;
|
|
esac
|
|
done
|
|
|
|
# Release the per-package prompt suppression.
|
|
_SELECTION_CONFIRMED=0
|
|
|
|
echo -e "${GREEN}Gaming setup complete.${NC}"
|
|
_pause
|
|
}
|