blob: cec0037abf6250d732dce1bb0f734e4942029cf0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
|
#!/usr/bin/env bash
set -euo pipefail
# Colors for terminal output
RED='\e[31m'
GREEN='\e[32m'
YELLOW='\e[33m'
BLUE='\e[34m'
BOLD='\e[1m'
RESET='\e[0m'
# Track if any errors occurred
ERRORS=0
# Function to print section headers
print_header() {
echo -e "${BOLD}${BLUE}"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "$1"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo -e "${RESET}"
}
print_success() {
echo -e "${GREEN}✓ $1${RESET}"
}
print_error() {
echo -e "${RED}✗ $1${RESET}"
ERRORS=$((ERRORS + 1))
}
print_info() {
echo -e "${YELLOW}ℹ $1${RESET}"
}
# Main update process
print_header "System Package Update"
# Update system packages
echo -e "${GREEN}Updating system packages...${RESET}\n"
if sudo pacman -Syu --noconfirm; then
print_success "System packages updated"
else
print_error "Failed to update system packages"
fi
echo
# Update AUR packages
print_header "AUR Package Update"
if ! command -v {yay,paru} >/dev/null 2>&1; then
print_info "Both yay and paru are not installed, skipping AUR updates"
elif ! pacman -Qem >/dev/null 2>&1; then
print_info "No AUR packages installed, skipping AUR updates"
else
echo -e "${GREEN}Updating AUR packages...${RESET}\n"
if yay -Sua --noconfirm; then
print_success "AUR packages updated"
elif paru -Sua --noconfirm; then
print_success "AUR packages updated"
else
print_error "Failed to update some AUR packages"
fi
fi
echo
# Clean up orphans
print_header "Cleanup Orphaned Packages"
orphans=$(pacman -Qtdq 2>/dev/null || true)
if [[ -z "$orphans" ]]; then
print_info "No orphaned packages found"
else
echo -e "${YELLOW}Found orphaned packages:${RESET}"
echo "$orphans" | sed 's/^/ - /'
echo
echo -e "${GREEN}Removing orphaned packages...${RESET}\n"
if sudo pacman -Rns --noconfirm "$orphans" 2>/dev/null; then
print_success "Orphaned packages removed"
else
print_error "Failed to remove some orphaned packages"
fi
fi
echo
# Final summary
print_header "Update Summary"
if [[ $ERRORS -eq 0 ]]; then
echo -e "${GREEN}${BOLD}✓ All operations completed successfully!${RESET}"
else
echo -e "${YELLOW}${BOLD} Completed with $ERRORS error(s)${RESET}"
fi
echo
# Keep window open until user dismisses
if command -v gum >/dev/null 2>&1; then
gum spin --spinner "globe" --title "Done! Press any key to close..." -- bash -c 'read -n 1 -s'
else
echo -e "${BLUE}Press any key to close this window...${RESET}"
read -n 1 -s
fi
|