clone of my dotfiles.ssp.sh
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add arch checkers orphant packages

sspaeti b407d677 07b5fd7b

+149
+4
.gitignore
··· 57 57 OBS/.config/obs-studio/profiler_data/ 58 58 59 59 w3m/.config/w3m/cookie 60 + 61 + #arch 62 + arch-orphans.txt 63 + arch-package-analysis.txt
+22
Makefile
··· 50 50 pacman -Qqen | grep -v -f <(pacman -Qqm) > pacman.txt 51 51 pacman -Qen | grep -v -f <(pacman -Qqm) > pacman-versions.txt 52 52 53 + 54 + ## how it works: 55 + # make arch-orphans # List orphaned packages → arch-orphans.txt 56 + # make arch-cleanup # Remove orphaned packages (after review) 57 + # make arch-package-check # Analyze all packages → arch-package-analysis.txt 58 + # make arch-check-deps # Check what depends on a package 59 + # make arch-clean-cache # Clean package cache (keeps 3 versions) 60 + arch-orphans: 61 + ./_utils/arch-maintenance.sh orphans 62 + 63 + arch-cleanup: 64 + ./_utils/arch-maintenance.sh cleanup 65 + 66 + arch-package-check: 67 + ./_utils/arch-maintenance.sh package-check 68 + 69 + arch-check-deps: 70 + ./_utils/arch-maintenance.sh check-deps 71 + 72 + arch-clean-cache: 73 + ./_utils/arch-maintenance.sh clean-cache 74 + 53 75 oh-my-zsh: 54 76 sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)" #install oh-my-zsh 55 77 git clone --depth=1 https://github.com/romkatv/powerlevel10k.git "${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/themes/powerlevel10k"
+123
_utils/arch-maintenance.sh
··· 1 + #!/bin/bash 2 + # Arch Linux Package Maintenance Script 3 + # Safe package cleanup and analysis for dotfiles management 4 + 5 + set -e 6 + 7 + SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" 8 + DOTFILES_DIR="$(dirname "$SCRIPT_DIR")" 9 + 10 + # List orphaned packages (dependencies no longer needed) to a file for review 11 + orphans() { 12 + echo "=== Orphaned Packages (safe to remove) ===" | tee "$DOTFILES_DIR/arch-orphans.txt" 13 + pacman -Qdtq 2>/dev/null | tee -a "$DOTFILES_DIR/arch-orphans.txt" || echo "No orphaned packages found!" | tee -a "$DOTFILES_DIR/arch-orphans.txt" 14 + echo "" 15 + echo "Review arch-orphans.txt, then run 'make arch-cleanup' to remove them" 16 + } 17 + 18 + # Remove orphaned packages after review 19 + cleanup() { 20 + if [ ! -f "$DOTFILES_DIR/arch-orphans.txt" ]; then 21 + echo "ERROR: Run 'make arch-orphans' first to generate the list!" 22 + exit 1 23 + fi 24 + 25 + echo "Removing orphaned packages from arch-orphans.txt..." 26 + if [ -s "$DOTFILES_DIR/arch-orphans.txt" ] && [ "$(wc -l < "$DOTFILES_DIR/arch-orphans.txt")" -gt 1 ]; then 27 + tail -n +2 "$DOTFILES_DIR/arch-orphans.txt" | sudo pacman -Rns - 28 + echo "Cleanup complete!" 29 + else 30 + echo "No orphaned packages to remove." 31 + fi 32 + } 33 + 34 + # Check which packages haven't been used recently and might not be needed 35 + package_check() { 36 + OUTPUT="$DOTFILES_DIR/arch-package-analysis.txt" 37 + 38 + echo "=== Package Analysis ===" | tee "$OUTPUT" 39 + echo "" | tee -a "$OUTPUT" 40 + echo "--- Explicitly Installed Packages ($(pacman -Qe | wc -l) total) ---" | tee -a "$OUTPUT" 41 + echo "--- Dependencies ($(pacman -Qd | wc -l) total) ---" | tee -a "$OUTPUT" 42 + echo "--- AUR Packages ($(pacman -Qm | wc -l) total) ---" | tee -a "$OUTPUT" 43 + echo "" | tee -a "$OUTPUT" 44 + 45 + echo "=== 20 Largest Explicitly Installed Packages ===" | tee -a "$OUTPUT" 46 + pacman -Qei | awk '/^Name/{name=$3} /^Installed Size/{size=$4$5; print size"\t"name}' | sort -rh | head -20 | tee -a "$OUTPUT" 47 + echo "" | tee -a "$OUTPUT" 48 + 49 + echo "=== 30 Oldest Explicitly Installed Packages ===" | tee -a "$OUTPUT" 50 + pacman -Qei | awk '/^Name/{name=$3} /^Install Date/{date=$4" "$5" "$6" "$7; print date"\t"name}' | sort | head -30 | tee -a "$OUTPUT" 51 + echo "" | tee -a "$OUTPUT" 52 + 53 + echo "=== Packages with Optional Dependencies Not Installed ===" | tee -a "$OUTPUT" 54 + pacman -Qi | awk '/^Name/{name=$3} /^Optional Deps/{flag=1;next} /^Required By/{flag=0} flag' | grep -v "^\s*$" | head -50 | tee -a "$OUTPUT" 55 + echo "" | tee -a "$OUTPUT" 56 + 57 + echo "Review arch-package-analysis.txt to find packages you might want to remove manually" 58 + echo "To remove a package: sudo pacman -Rns <package-name>" 59 + } 60 + 61 + # Show packages that would be removed if you uninstall a specific package (dry-run) 62 + check_deps() { 63 + if [ -z "$1" ]; then 64 + read -p "Enter package name to check: " pkg 65 + else 66 + pkg="$1" 67 + fi 68 + 69 + echo "=== Packages that depend on $pkg ===" 70 + pactree -r "$pkg" 2>/dev/null || echo "Package not found or no reverse dependencies" 71 + } 72 + 73 + # Clean package cache (keeps only 3 most recent versions) 74 + clean_cache() { 75 + echo "Cleaning package cache (keeping 3 most recent versions)..." 76 + sudo paccache -rk3 77 + echo "Cleaning uninstalled package cache..." 78 + sudo paccache -ruk0 79 + echo "Cache cleaned!" 80 + } 81 + 82 + # Show help 83 + help() { 84 + echo "Arch Linux Package Maintenance Script" 85 + echo "" 86 + echo "Usage: $0 <command>" 87 + echo "" 88 + echo "Commands:" 89 + echo " orphans - List orphaned packages to arch-orphans.txt" 90 + echo " cleanup - Remove orphaned packages (after reviewing arch-orphans.txt)" 91 + echo " package-check - Analyze installed packages and save to arch-package-analysis.txt" 92 + echo " check-deps - Show what depends on a specific package" 93 + echo " clean-cache - Clean package cache (keeps 3 recent versions)" 94 + echo " help - Show this help message" 95 + } 96 + 97 + # Main command handler 98 + case "$1" in 99 + orphans) 100 + orphans 101 + ;; 102 + cleanup) 103 + cleanup 104 + ;; 105 + package-check) 106 + package_check 107 + ;; 108 + check-deps) 109 + check_deps "$2" 110 + ;; 111 + clean-cache) 112 + clean_cache 113 + ;; 114 + help|--help|-h|"") 115 + help 116 + ;; 117 + *) 118 + echo "Unknown command: $1" 119 + echo "" 120 + help 121 + exit 1 122 + ;; 123 + esac