Skip to content

Commit b7feec0

Browse files
committed
Enhance package update script with system dependency installation and improved Docker/Podman update handling
- Add system dependency installation for PIP package updates across different package managers - Improve PIP package update logic with better package detection and upgrade process - Add Docker and Podman update checks for user permissions and image availability - Enhance error handling and messaging for container image updates
1 parent 509ad49 commit b7feec0

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

scripts/update_packages.sh

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,15 +104,32 @@ fi
104104
if command -v pip &> /dev/null; then
105105
echo "Updating PIP and all installed Python packages..."
106106

107-
# Upgrade pip first
107+
# Upgrade PIP itself first
108108
python3 -m pip install --upgrade pip
109109

110-
# Upgrade all packages while resolving dependencies properly
111-
pip list --outdated --format=freeze | awk -F '==' '{print $1}' | xargs -r python3 -m pip install --upgrade
110+
# Install system dependencies to prevent errors
111+
if command -v apt &> /dev/null; then
112+
sudo apt install -y cmake pkg-config libvirt-dev libpq-dev gobject-introspection
113+
elif command -v dnf &> /dev/null; then
114+
sudo dnf install -y cmake pkgconf-pkg-config libvirt-devel postgresql-devel gobject-introspection
115+
elif command -v pacman &> /dev/null; then
116+
sudo pacman -S --needed --noconfirm cmake pkg-config libvirt postgresql-libs gobject-introspection
117+
fi
118+
119+
# Get a list of outdated packages and upgrade them
120+
outdated_packages=$(pip list --outdated --format=columns | awk 'NR>2 {print $1}')
121+
122+
if [ -n "$outdated_packages" ]; then
123+
echo "Upgrading: $outdated_packages"
124+
echo "$outdated_packages" | xargs -n1 python3 -m pip install --upgrade
125+
else
126+
echo "All PIP packages are up to date."
127+
fi
112128
fi
113129

114130

115131

132+
116133
if command -v poetry &> /dev/null; then
117134
echo "Updating Poetry packages..."
118135
poetry self update
@@ -160,14 +177,26 @@ fi
160177
# Container and Virtualization
161178
if command -v docker &> /dev/null; then
162179
echo "Updating Docker images..."
163-
docker images --format "{{.Repository}}" | xargs -L1 docker pull
180+
if groups | grep -q '\bdocker\b'; then
181+
docker images --format "{{.Repository}}" | xargs -L1 docker pull
182+
else
183+
echo "Skipping Docker updates: User lacks permissions. Run 'sudo usermod -aG docker $USER' and restart."
184+
fi
164185
fi
165186

187+
166188
if command -v podman &> /dev/null; then
167189
echo "Updating Podman images..."
168-
podman images --format "{{.Repository}}" | xargs -L1 podman pull
190+
podman_images=$(podman images --format "{{.Repository}}")
191+
192+
if [ -n "$podman_images" ]; then
193+
echo "$podman_images" | xargs -L1 podman pull
194+
else
195+
echo "No Podman images found to update."
196+
fi
169197
fi
170198

199+
171200
if command -v minikube &> /dev/null; then
172201
echo "Updating Minikube..."
173202
minikube update-check

0 commit comments

Comments
 (0)