[IMPROVED] Separar actualización de Python y pip en funciones independientes
- 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 <noreply@anthropic.com>
This commit is contained in:
parent
c98a402b38
commit
6dc5746da1
2 changed files with 108 additions and 0 deletions
|
@ -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
|
# Install pip package
|
||||||
function pip_install() {
|
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
|
# Install mozilla sops package on os system supported
|
||||||
function sops_install() {
|
function sops_install() {
|
||||||
|
|
||||||
|
|
|
@ -58,3 +58,25 @@ else
|
||||||
git pull
|
git pull
|
||||||
fi
|
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."
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue