mirror of
https://github.com/stornic56/debianito-post-install.git
synced 2026-10-31 13:08:06 +00:00
21e9973c2f
- Verified the repository backup rc in migrate.sh. `_persistent_backup_repos()` now aborts before any destructive step when the tar archive is missing or corrupt, removing the invalid backup itself. - Verified the restore rc in migrate.sh. `_restore_backup()` now reports failure instead of printing a green "Backup restored" message, and its caller distinguishes a restored backup from a failed restore. - Made the upgrade phases fail honestly. `apt upgrade` and `apt full-upgrade` now abort with `apt --fix-broken install` + `dpkg --configure -a` instructions instead of reporting "completed successfully" over a partially-upgraded system. - Made repository source writes atomic. Both writers tee into a `.tmp` file and move into place, and the `/etc/apt/sources.list` removal now happens after the write. - Corrected the SID warning text in migrate.sh to reflect that security fixes arrive via package uploads rather than a nonexistent sid-security suite. - Added exit-path cleanup traps for the temp `.deb` files: `trap 'rm -f "$deb_path"' RETURN` in `heroic.sh`and `tools.sh`. - Tightened Heroic download handling: the API fetch uses `curl -fsS --connect-timeout 10 --max-time 30`, the download uses `curl -fsSL --max-time 300`, and the `.deb` is validated with both `dpkg-deb --info` and `dpkg-deb --contents`; `sudo apt install` is guarded with `if !` before the temporary file is deleted. - Tightened the OpenRGB install path: the Codeberg API fetch uses `curl -fsS --connect-timeout 10 --max-time 30` and the download `curl -fsSL --max-time 300`, with the same dual `dpkg-deb` integrity check as the Heroic fallback. - Guarded the OpenRGB post-install side effects: the script now aborts after removing the failed `.deb` if `sudo apt install` returns non-zero, so `modprobe i2c-dev`, `/etc/modules`, the `i2c` group membership, `udevadm`, and the `setcap` step no longer run when the package is absent.
57 lines
2.3 KiB
Bash
57 lines
2.3 KiB
Bash
#!/usr/bin/env bash
|
|
# Heroic Games Launcher installation from GitHub releases
|
|
|
|
install_heroic() {
|
|
local heroic_deb
|
|
heroic_deb=$(mktemp "${TMPDIR:-/tmp}/heroic-XXXXXX.deb") || return 1
|
|
# Remove the temp file on every exit path (RETURN
|
|
# traps are not inherited by called functions).
|
|
trap 'rm -f "$heroic_deb"' RETURN
|
|
local ua="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
|
|
|
|
_run_cmd "Heroic" "sudo apt install -y curl jq" "Installing dependencies..."
|
|
|
|
local json
|
|
# -f: HTTP >= 400 must fail; --max-time bounds the
|
|
# whole transfer (connect-timeout only covers the
|
|
# connection phase).
|
|
json=$(curl -fsS --connect-timeout 10 --max-time 30 -H "User-Agent: $ua" \
|
|
"https://api.github.com/repos/Heroic-Games-Launcher/HeroicGamesLauncher/releases/latest") || {
|
|
_msg "Heroic Error" "Could not fetch release data from GitHub API." 8 60
|
|
return 1
|
|
}
|
|
|
|
local deb_url
|
|
deb_url=$(echo "$json" | jq -r '
|
|
.assets[] | select(.name | endswith("amd64.deb")) | .browser_download_url
|
|
' 2>/dev/null || true)
|
|
|
|
if [ -z "$deb_url" ]; then
|
|
_msg "Heroic Error" "Could not find amd64.deb asset in latest release." 10 60
|
|
return 1
|
|
fi
|
|
|
|
# Strict URL validation before interpolating into a shell command (_run_cmd uses bash -c)
|
|
[[ "$deb_url" =~ ^https://[A-Za-z0-9./_-]+\.deb$ ]] || { _msg "Error" "Invalid download URL: $deb_url"; return 1; }
|
|
|
|
_run_cmd "Heroic" "curl -fsSL --max-time 300 -H 'User-Agent: $ua' -o '$heroic_deb' '$deb_url'" "Downloading Heroic..."
|
|
|
|
# --info reads only the control archive; --contents
|
|
# also walks the data archive, catching deb files
|
|
# truncated after the control section.
|
|
if ! dpkg-deb --info "$heroic_deb" >/dev/null 2>&1 || \
|
|
! dpkg-deb --contents "$heroic_deb" >/dev/null 2>&1; then
|
|
_msg "Heroic Error" "Downloaded .deb is corrupted or truncated.\n\nRemoving file." 10 60
|
|
rm -f "$heroic_deb"
|
|
return 1
|
|
fi
|
|
|
|
echo -e "${GREEN}Package integrity verified.${NC}"
|
|
if ! _run_cmd "Heroic" "sudo apt install -y '$heroic_deb'" "Installing Heroic..."; then
|
|
rm -f "$heroic_deb"
|
|
return 1
|
|
fi
|
|
rm -f "$heroic_deb"
|
|
echo -e "${GREEN}Heroic Games Launcher installed.${NC}"
|
|
}
|