Add step_pkg_cache: apt clean / paccache / pacman -Sc

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2026-07-22 00:17:56 +07:00
co-authored by Claude
parent f4c8f6c9e5
commit 37ce7f6ca8
+41
View File
@@ -227,6 +227,46 @@ step_journal() {
echo ""
}
# -----------------------------
# Bước 4: Package cache — apt clean+autoremove hoặc paccache/pacman -Sc
# -----------------------------
step_pkg_cache() {
echo "${C_TITLE}--- [Package Cache] ---${C_RESET}"
local distro
distro=$(detect_distro)
case "$distro" in
debian)
local d="/var/cache/apt/archives"
[ -d "$d" ] && sudo du -sh "$d"
if confirm_yn "apt clean + autoremove?"; then
sudo apt-get clean
sudo apt-get autoremove -y
echo "${C_OK} ✓ Đã dọn apt cache.${C_RESET}"
fi
;;
arch)
local d="/var/cache/pacman/pkg"
[ -d "$d" ] && sudo du -sh "$d"
if command -v paccache >/dev/null 2>&1; then
sudo paccache -dk2 # dry-run xem trước
if confirm_yn "paccache -rk2 (giữ 2 bản)?"; then
sudo paccache -rk2
echo "${C_OK} ✓ Đã dọn pacman cache.${C_RESET}"
fi
else
if confirm_yn "Không có paccache, chạy pacman -Sc?"; then
sudo pacman -Sc --noconfirm
echo "${C_OK} ✓ Đã dọn pacman cache.${C_RESET}"
fi
fi
;;
*)
echo "${C_WARN} ⚠ Distro không hỗ trợ dọn package cache.${C_RESET}"
;;
esac
echo ""
}
# -----------------------------
# Chạy tuần tự 6 bước (stub — các bước thêm ở Task 4-9)
# -----------------------------
@@ -234,6 +274,7 @@ run_all_steps() {
step_upgrade
step_docker
step_journal
step_pkg_cache
}
# -----------------------------