42deea5be2
Add set -euo pipefail, root checks, safer orphan cleanup, and a help message to fullupgrade. Refresh the README and project notes to match the current scripts and release process.
62 lines
1.1 KiB
Bash
Executable File
62 lines
1.1 KiB
Bash
Executable File
#!/bin/bash
|
|
set -euo pipefail
|
|
|
|
show_help() {
|
|
cat <<'EOF'
|
|
Usage: fullupgrade
|
|
|
|
Met à jour Arch Linux et effectue un nettoyage:
|
|
- mise à jour de archlinux-keyring
|
|
- synchronisation complète du système
|
|
- suppression des paquets orphelins
|
|
- nettoyage du cache pacman
|
|
|
|
Attention: ce script modifie le système et s'exécute sans confirmation.
|
|
EOF
|
|
}
|
|
|
|
|
|
require_root() {
|
|
if [ "${EUID:-$(id -u)}" -ne 0 ]; then
|
|
echo "Erreur: ce script doit être exécuté en root." >&2
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
cleanup_orphans() {
|
|
local orphans=()
|
|
|
|
mapfile -t orphans < <(pacman -Qqtd)
|
|
|
|
if [ "${#orphans[@]}" -gt 0 ]; then
|
|
pacman -Rns --noconfirm "${orphans[@]}"
|
|
else
|
|
echo "Aucun paquet orphelin à supprimer."
|
|
fi
|
|
}
|
|
|
|
main() {
|
|
if [ "${1:-}" = "-h" ] || [ "${1:-}" = "--help" ]; then
|
|
show_help
|
|
exit 0
|
|
fi
|
|
|
|
require_root
|
|
|
|
echo "Mise à jour de archlinux-keyring..."
|
|
pacman -Sy --noconfirm archlinux-keyring
|
|
|
|
echo "Mise à jour complète du système..."
|
|
pacman -Syu --noconfirm
|
|
|
|
echo "Recherche des paquets orphelins..."
|
|
cleanup_orphans
|
|
|
|
echo "Nettoyage du cache pacman..."
|
|
pacman -Sc --noconfirm
|
|
|
|
echo "Mise à jour terminée avec succès."
|
|
}
|
|
|
|
main "$@"
|