Skip to content

Commit ff6c20d

Browse files
committed
Merge branch 'update-zsh-script'
2 parents cfc95c5 + e0f0727 commit ff6c20d

11 files changed

+993
-419
lines changed

scripts/update_packages.bbsh

Lines changed: 95 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,67 @@ handle_error() {
2020

2121
echo "Starting package updates..."
2222

23+
# System Package Managers (requiring sudo)
24+
if which apt >/dev/null 2>&1; then
25+
echo "Updating APT packages..."
26+
if ! { busybox su -c "apt update && apt upgrade -y && apt autoremove -y"; }; then
27+
handle_error "APT" "update failed"
28+
fi
29+
elif which dpkg >/dev/null 2>&1; then
30+
echo "Updating DPKG packages..."
31+
if ! busybox su -c "dpkg --configure -a"; then
32+
handle_error "DPKG" "configuration failed"
33+
fi
34+
elif which dnf >/dev/null 2>&1; then
35+
echo "Updating DNF packages..."
36+
if ! busybox su -c "dnf upgrade --refresh -y"; then
37+
handle_error "DNF" "update failed"
38+
fi
39+
elif which yum >/dev/null 2>&1; then
40+
echo "Updating YUM packages..."
41+
if ! busybox su -c "yum update -y"; then
42+
handle_error "YUM" "update failed"
43+
fi
44+
elif which pacman >/dev/null 2>&1; then
45+
echo "Updating Pacman packages..."
46+
if ! busybox su -c "pacman -Syu --noconfirm"; then
47+
handle_error "Pacman" "update failed"
48+
fi
49+
elif which zypper >/dev/null 2>&1; then
50+
echo "Updating Zypper packages..."
51+
if ! busybox su -c "zypper refresh && zypper update -y"; then
52+
handle_error "Zypper" "update failed"
53+
fi
54+
elif which emerge >/dev/null 2>&1; then
55+
echo "Updating Portage packages..."
56+
if ! busybox su -c "emerge --sync && emerge -uDN @world"; then
57+
handle_error "Portage" "update failed"
58+
fi
59+
elif which xbps-install >/dev/null 2>&1; then
60+
echo "Updating XBPS packages..."
61+
if ! busybox su -c "xbps-install -Su"; then
62+
handle_error "XBPS" "update failed"
63+
fi
64+
elif which apk >/dev/null 2>&1; then
65+
echo "Updating APK packages..."
66+
if ! busybox su -c "apk update && apk upgrade"; then
67+
handle_error "APK" "update failed"
68+
fi
69+
elif which pkgtool >/dev/null 2>&1; then
70+
echo "Updating Slackware packages..."
71+
if ! busybox su -c "slackpkg update && slackpkg upgrade-all"; then
72+
handle_error "Slackware" "update failed"
73+
fi
74+
fi
75+
76+
# Update Snap packages (requires sudo)
77+
if which snap >/dev/null 2>&1; then
78+
echo "Updating Snap packages..."
79+
if ! busybox su -c "snap refresh"; then
80+
handle_error "Snap" "update failed"
81+
fi
82+
fi
83+
2384
# Update and upgrade Homebrew
2485
if which brew >/dev/null 2>&1; then
2586
echo "Updating Homebrew..."
@@ -36,33 +97,22 @@ if which flatpak >/dev/null 2>&1; then
3697
fi
3798
fi
3899

39-
# Update Snap packages
40-
if which snap >/dev/null 2>&1; then
41-
echo "Updating Snap packages..."
42-
if ! busybox su -c "snap refresh"; then
43-
handle_error "Snap" "update failed"
100+
# Update Nix packages
101+
if which nix-env >/dev/null 2>&1; then
102+
echo "Updating Nix..."
103+
if ! { nix-channel --update && nix-env -u && nix-collect-garbage -d; }; then
104+
handle_error "Nix" "update failed"
44105
fi
45106
fi
46107

47-
# System Package Managers
48-
if which apt >/dev/null 2>&1; then
49-
echo "Updating APT packages..."
50-
if ! { busybox su -c "apt update && apt upgrade -y && apt autoremove -y"; }; then
51-
handle_error "APT" "update failed"
52-
fi
53-
elif which dpkg >/dev/null 2>&1; then
54-
echo "Updating DPKG packages..."
55-
if ! busybox su -c "dpkg --configure -a"; then
56-
handle_error "DPKG" "configuration failed"
57-
fi
58-
elif which dnf >/dev/null 2>&1; then
59-
echo "Updating DNF packages..."
60-
if ! busybox su -c "dnf upgrade --refresh -y"; then
61-
handle_error "DNF" "update failed"
108+
# Programming Language Package Managers
109+
if which npm >/dev/null 2>&1; then
110+
echo "Updating NPM packages..."
111+
if ! npm update -g; then
112+
handle_error "NPM" "update failed"
62113
fi
63114
fi
64115

65-
# Programming Language Package Managers
66116
if which pip >/dev/null 2>&1; then
67117
echo "Updating PIP packages..."
68118
if ! pip list --outdated --format=freeze | busybox grep -v '^\-e' | busybox cut -d = -f 1 | while read pkg; do
@@ -72,6 +122,20 @@ if which pip >/dev/null 2>&1; then
72122
fi
73123
fi
74124

125+
if which gem >/dev/null 2>&1; then
126+
echo "Updating Ruby gems..."
127+
if ! gem update; then
128+
handle_error "Ruby Gems" "update failed"
129+
fi
130+
fi
131+
132+
if which cargo >/dev/null 2>&1; then
133+
echo "Updating Cargo packages..."
134+
if ! cargo install-update -a; then
135+
handle_error "Cargo" "update failed"
136+
fi
137+
fi
138+
75139
# Container and Virtualization
76140
if which docker >/dev/null 2>&1; then
77141
echo "Updating Docker images..."
@@ -83,4 +147,14 @@ if which docker >/dev/null 2>&1; then
83147
done
84148
fi
85149

150+
if which podman >/dev/null 2>&1; then
151+
echo "Updating Podman images..."
152+
podman images | busybox grep -v REPOSITORY | while read line; do
153+
image=$(echo "$line" | busybox awk '{print $1}')
154+
if ! podman pull "$image"; then
155+
handle_error "Podman" "failed to update $image"
156+
fi
157+
done
158+
fi
159+
86160
echo "All package updates completed!"

scripts/update_packages.csh

Lines changed: 101 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,107 @@ alias handle_error 'echo "Error updating $1: $2" > /dev/stderr'
2121

2222
echo "Starting package updates..."
2323

24+
# System Package Managers (requiring sudo)
25+
which apt > /dev/null
26+
if ($status == 0) then
27+
echo "Updating APT packages..."
28+
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
29+
if ($status) then
30+
handle_error "APT" "update failed"
31+
endif
32+
else
33+
which dpkg > /dev/null
34+
if ($status == 0) then
35+
echo "Updating DPKG packages..."
36+
sudo dpkg --configure -a
37+
if ($status) then
38+
handle_error "DPKG" "configuration failed"
39+
endif
40+
else
41+
which dnf > /dev/null
42+
if ($status == 0) then
43+
echo "Updating DNF packages..."
44+
sudo dnf upgrade --refresh -y
45+
if ($status) then
46+
handle_error "DNF" "update failed"
47+
endif
48+
else
49+
which yum > /dev/null
50+
if ($status == 0) then
51+
echo "Updating YUM packages..."
52+
sudo yum update -y
53+
if ($status) then
54+
handle_error "YUM" "update failed"
55+
endif
56+
else
57+
which pacman > /dev/null
58+
if ($status == 0) then
59+
echo "Updating Pacman packages..."
60+
sudo pacman -Syu --noconfirm
61+
if ($status) then
62+
handle_error "Pacman" "update failed"
63+
endif
64+
else
65+
which zypper > /dev/null
66+
if ($status == 0) then
67+
echo "Updating Zypper packages..."
68+
sudo zypper refresh && sudo zypper update -y
69+
if ($status) then
70+
handle_error "Zypper" "update failed"
71+
endif
72+
else
73+
which emerge > /dev/null
74+
if ($status == 0) then
75+
echo "Updating Portage packages..."
76+
sudo emerge --sync && sudo emerge -uDN @world
77+
if ($status) then
78+
handle_error "Portage" "update failed"
79+
endif
80+
else
81+
which xbps-install > /dev/null
82+
if ($status == 0) then
83+
echo "Updating XBPS packages..."
84+
sudo xbps-install -Su
85+
if ($status) then
86+
handle_error "XBPS" "update failed"
87+
endif
88+
else
89+
which apk > /dev/null
90+
if ($status == 0) then
91+
echo "Updating APK packages..."
92+
sudo apk update && sudo apk upgrade
93+
if ($status) then
94+
handle_error "APK" "update failed"
95+
endif
96+
else
97+
which pkgtool > /dev/null
98+
if ($status == 0) then
99+
echo "Updating Slackware packages..."
100+
sudo slackpkg update && sudo slackpkg upgrade-all
101+
if ($status) then
102+
handle_error "Slackware" "update failed"
103+
endif
104+
endif
105+
endif
106+
endif
107+
endif
108+
endif
109+
endif
110+
endif
111+
endif
112+
endif
113+
endif
114+
115+
# Update Snap packages (requires sudo)
116+
which snap > /dev/null
117+
if ($status == 0) then
118+
echo "Updating Snap packages..."
119+
sudo snap refresh
120+
if ($status) then
121+
handle_error "Snap" "update failed"
122+
endif
123+
endif
124+
24125
# Update and upgrade Homebrew
25126
which brew > /dev/null
26127
if ($status == 0) then
@@ -41,16 +142,6 @@ if ($status == 0) then
41142
endif
42143
endif
43144

44-
# Update Snap packages
45-
which snap > /dev/null
46-
if ($status == 0) then
47-
echo "Updating Snap packages..."
48-
sudo snap refresh
49-
if ($status) then
50-
handle_error "Snap" "update failed"
51-
endif
52-
endif
53-
54145
# Update Nix packages
55146
which nix-env > /dev/null
56147
if ($status == 0) then
@@ -61,34 +152,6 @@ if ($status == 0) then
61152
endif
62153
endif
63154

64-
# System Package Managers
65-
which apt > /dev/null
66-
if ($status == 0) then
67-
echo "Updating APT packages..."
68-
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
69-
if ($status) then
70-
handle_error "APT" "update failed"
71-
endif
72-
else
73-
which dpkg > /dev/null
74-
if ($status == 0) then
75-
echo "Updating DPKG packages..."
76-
sudo dpkg --configure -a
77-
if ($status) then
78-
handle_error "DPKG" "configuration failed"
79-
endif
80-
else
81-
which dnf > /dev/null
82-
if ($status == 0) then
83-
echo "Updating DNF packages..."
84-
sudo dnf upgrade --refresh -y
85-
if ($status) then
86-
handle_error "DNF" "update failed"
87-
endif
88-
endif
89-
endif
90-
endif
91-
92155
# Programming Language Package Managers
93156
which npm > /dev/null
94157
if ($status == 0) then

0 commit comments

Comments
 (0)