diff --git a/bin/update.sh b/bin/update.sh index 82a8e1c..a522efd 100755 --- a/bin/update.sh +++ b/bin/update.sh @@ -71,8 +71,71 @@ update_python_and_pip() { local MESSAGES=$3 local UPDATE_LANG=$4 - # Cargar biblioteca bootstrap - source $BIN_PATH/$LIBRARY/bootstrap.lib + # No necesitamos cargar bootstrap.lib, ya que tenemos las funciones definidas internamente + + # Definiciones internas para no depender de fuentes externas + function python3_update() { + echo "Actualizando Python..." + + 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 "Sistema operativo no soportado" + return 1 + fi + + echo "Python actualizado correctamente." + return 0 + } + + function pip_update() { + echo "Actualizando pip..." + + # 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 "Sistema operativo no soportado" + return 1 + fi + + echo "Pip actualizado correctamente." + return 0 + } echo -e "\n${head_info}: Actualizando Python y pip..." @@ -107,7 +170,10 @@ PIP_INSTALLED=$? if [ $PYTHON_INSTALLED -eq 0 ] || [ $PIP_INSTALLED -eq 0 ]; then # Ejecutar la actualización de Python y pip con sudo echo -e "\n${head_info}: Se necesitan privilegios de administrador para actualizar Python y pip..." - sudo bash -c "$(declare -f update_python_and_pip); update_python_and_pip $BIN_HOME $BIN_LIBS $BIN_MESG $BIN_LANG" + + # Exportar todas las funciones necesarias para que estén disponibles en el subproceso sudo + # Esto incluye command_installed y otras funciones de base.lib que se necesitan + sudo bash -c "$(declare -f command_installed; declare -f update_python_and_pip); update_python_and_pip $BIN_HOME $BIN_LIBS $BIN_MESG $BIN_LANG" if [ $? -ne 0 ]; then echo -e "\n${head_error}: No se pudo actualizar Python y pip. Verifique sus privilegios." fi