Skip to content

Commit e0f0727

Browse files
committed
Enhance package update scripts with comprehensive support for multiple package managers and language ecosystems
- Expanded system package manager support to include Portage, XBPS, APK, and Slackware - Added support for additional programming language package managers like Yarn, PNPM, Cargo, and Ruby Gems - Improved container and virtualization tool updates with Podman, Singularity, and Minikube support - Standardized script structure across different shell environments - Implemented consistent error handling and logging mechanisms - Reorganized package update logic to improve readability and maintainability
1 parent f91ccc8 commit e0f0727

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
@@ -13,6 +13,67 @@ handle_error() {
1313

1414
echo "Starting package updates..."
1515

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

32-
# Update Snap packages
33-
if which snap >/dev/null 2>&1; then
34-
echo "Updating Snap packages..."
35-
if ! busybox su -c "snap refresh"; then
36-
handle_error "Snap" "update failed"
93+
# Update Nix packages
94+
if which nix-env >/dev/null 2>&1; then
95+
echo "Updating Nix..."
96+
if ! { nix-channel --update && nix-env -u && nix-collect-garbage -d; }; then
97+
handle_error "Nix" "update failed"
3798
fi
3899
fi
39100

40-
# System Package Managers
41-
if which apt >/dev/null 2>&1; then
42-
echo "Updating APT packages..."
43-
if ! { busybox su -c "apt update && apt upgrade -y && apt autoremove -y"; }; then
44-
handle_error "APT" "update failed"
45-
fi
46-
elif which dpkg >/dev/null 2>&1; then
47-
echo "Updating DPKG packages..."
48-
if ! busybox su -c "dpkg --configure -a"; then
49-
handle_error "DPKG" "configuration failed"
50-
fi
51-
elif which dnf >/dev/null 2>&1; then
52-
echo "Updating DNF packages..."
53-
if ! busybox su -c "dnf upgrade --refresh -y"; then
54-
handle_error "DNF" "update failed"
101+
# Programming Language Package Managers
102+
if which npm >/dev/null 2>&1; then
103+
echo "Updating NPM packages..."
104+
if ! npm update -g; then
105+
handle_error "NPM" "update failed"
55106
fi
56107
fi
57108

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

118+
if which gem >/dev/null 2>&1; then
119+
echo "Updating Ruby gems..."
120+
if ! gem update; then
121+
handle_error "Ruby Gems" "update failed"
122+
fi
123+
fi
124+
125+
if which cargo >/dev/null 2>&1; then
126+
echo "Updating Cargo packages..."
127+
if ! cargo install-update -a; then
128+
handle_error "Cargo" "update failed"
129+
fi
130+
fi
131+
68132
# Container and Virtualization
69133
if which docker >/dev/null 2>&1; then
70134
echo "Updating Docker images..."
@@ -76,4 +140,14 @@ if which docker >/dev/null 2>&1; then
76140
done
77141
fi
78142

143+
if which podman >/dev/null 2>&1; then
144+
echo "Updating Podman images..."
145+
podman images | busybox grep -v REPOSITORY | while read line; do
146+
image=$(echo "$line" | busybox awk '{print $1}')
147+
if ! podman pull "$image"; then
148+
handle_error "Podman" "failed to update $image"
149+
fi
150+
done
151+
fi
152+
79153
echo "All package updates completed!"

scripts/update_packages.csh

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

66
echo "Starting package updates..."
77

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

28-
# Update Snap packages
29-
which snap > /dev/null
30-
if ($status == 0) then
31-
echo "Updating Snap packages..."
32-
sudo snap refresh
33-
if ($status) then
34-
handle_error "Snap" "update failed"
35-
endif
36-
endif
37-
38129
# Update Nix packages
39130
which nix-env > /dev/null
40131
if ($status == 0) then
@@ -45,34 +136,6 @@ if ($status == 0) then
45136
endif
46137
endif
47138

48-
# System Package Managers
49-
which apt > /dev/null
50-
if ($status == 0) then
51-
echo "Updating APT packages..."
52-
sudo apt update && sudo apt upgrade -y && sudo apt autoremove -y
53-
if ($status) then
54-
handle_error "APT" "update failed"
55-
endif
56-
else
57-
which dpkg > /dev/null
58-
if ($status == 0) then
59-
echo "Updating DPKG packages..."
60-
sudo dpkg --configure -a
61-
if ($status) then
62-
handle_error "DPKG" "configuration failed"
63-
endif
64-
else
65-
which dnf > /dev/null
66-
if ($status == 0) then
67-
echo "Updating DNF packages..."
68-
sudo dnf upgrade --refresh -y
69-
if ($status) then
70-
handle_error "DNF" "update failed"
71-
endif
72-
endif
73-
endif
74-
endif
75-
76139
# Programming Language Package Managers
77140
which npm > /dev/null
78141
if ($status == 0) then

0 commit comments

Comments
 (0)