From 6dc5746da1cd9a20d17a4c1c62f85648753ebea0 Mon Sep 17 00:00:00 2001 From: "Mauro Rosero P." Date: Wed, 12 Mar 2025 09:16:58 -0500 Subject: [PATCH] =?UTF-8?q?[IMPROVED]=20Separar=20actualizaci=C3=B3n=20de?= =?UTF-8?q?=20Python=20y=20pip=20en=20funciones=20independientes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Crear función pip_update específica para actualizar pip - Crear función python3_update específica para actualizar Python - Modificar update.sh para actualizar Python y pip por separado - Mejorar manejo de errores y verificación de instalación previa 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude --- bin/lib/bootstrap.lib | 86 +++++++++++++++++++++++++++++++++++++++++++ bin/update.sh | 22 +++++++++++ 2 files changed, 108 insertions(+) diff --git a/bin/lib/bootstrap.lib b/bin/lib/bootstrap.lib index 257ffd5..9f4dd0e 100755 --- a/bin/lib/bootstrap.lib +++ b/bin/lib/bootstrap.lib @@ -122,6 +122,46 @@ function python3_install() { } +# Update python3 package +function python3_update() { + + echo "Actualizando Python..." + + # Verificar si Python está instalado + command_installed python3 + if [ $? -ne 0 ]; then + # Si Python no está instalado, llamamos a la función de instalación + python3_install + return $? + fi + + # Actualizar Python según el sistema operativo + if [ "$(uname)" == "Darwin" ]; then + # En macOS, actualizamos Python a través de Homebrew + brew upgrade python + elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then + # En sistemas Debian y derivados + apt update + apt install --only-upgrade -y python3 + elif [ -f /etc/redhat-release ]; then + # En sistemas Red Hat + dnf upgrade -y python3 + elif [ -f /etc/arch-release ]; then + # En Arch Linux + pacman -Syu --noconfirm python + elif [ -f /etc/rc.conf ]; then + # En BSD + pkg upgrade -y python3 + else + echo "${os_nofound}" + return 1 + fi + + echo "Python actualizado correctamente." + return 0 + +} + # Install pip package function pip_install() { @@ -150,6 +190,52 @@ function pip_install() { } +# Update pip package +function pip_update() { + + echo "Actualizando pip..." + + # Verificar si pip está instalado + command_installed pip3 + if [ $? -ne 0 ]; then + # Si pip no está instalado, llamamos a la función de instalación + pip_install + return $? + fi + + # Actualizar pip usando el método adecuado según el sistema operativo + if [ "$(uname)" == "Darwin" ]; then + # En macOS, actualizamos pip a través de Homebrew + brew upgrade python-pip + elif [ -f /etc/debian_version ] || [ -f /etc/os-release ]; then + # En sistemas Debian y derivados + apt update + apt install --only-upgrade -y python3-pip + # También actualizar usando el propio pip + python3 -m pip install --upgrade pip + elif [ -f /etc/redhat-release ]; then + # En sistemas Red Hat + dnf upgrade -y python3-pip + # También actualizar usando el propio pip + python3 -m pip install --upgrade pip + elif [ -f /etc/arch-release ]; then + # En Arch Linux + pacman -Syu --noconfirm python-pip + elif [ -f /etc/rc.conf ]; then + # En BSD + pkg upgrade -y python3-pip + # También actualizar usando el propio pip + python3 -m pip install --upgrade pip + else + echo "${os_nofound}" + return 1 + fi + + echo "Pip actualizado correctamente." + return 0 + +} + # Install mozilla sops package on os system supported function sops_install() { diff --git a/bin/update.sh b/bin/update.sh index f25f8f4..ecb006e 100755 --- a/bin/update.sh +++ b/bin/update.sh @@ -58,3 +58,25 @@ else git pull fi +# Load bootstrap library for update functions +source $BIN_HOME/$BIN_LIBS/bootstrap.lib + +# Update Python and pip separately +echo -e "\n${head_info}: Verificando actualizaciones de Python y pip..." + +# Update Python +command_installed python3 +if [ $? -eq 0 ] +then + python3_update +fi + +# Update pip separately +command_installed pip3 +if [ $? -eq 0 ] +then + pip_update +fi + +echo -e "\n${head_info}: Actualizaciones completadas." +