Last active
January 16, 2022 19:39
-
-
Save ks7000/a4c1d00480f19aa4b8482b85df66f115 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#**************************************************************************************************** | |
# _ _ ____ _ | |
# Project ___| | | | _ \| | | |
# / __| | | | |_) | | | |
# | (__| |_| | _ <| |___ | |
# \___|\___/|_| \_\_____| | |
# | |
# Copyright (C) 1998 - 2022, Daniel Stenberg, <[email protected]>, et al (et alii, here Jimmy Olano). | |
# | |
# This software is licensed as described in the file COPYING, which you should have received as part of this | |
# distribution. The terms are also available at https://curl.se/docs/copyright.html. | |
# | |
# You may opt to use, copy, modify, merge, publish, distribute and/or sell copies of the Software, and permit | |
# persons to whom the Software is furnished to do so, under the terms of the COPYING file. | |
# | |
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | |
# | |
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | |
# | |
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. | |
# | |
##################################################################################################### | |
tput clear | |
tput init | |
function ejecutar(){ | |
# Función para ejecutar comandos. | |
local comando=$1 | |
mensaje $2 | |
bash -c "${ssuddo}${comando}" | |
} | |
function mensaje(){ | |
msj=$1 | |
tput bold | |
echo "___ "$msj | |
tput dim | |
} | |
# Usuario distinto a 'root' debe usar 'sudo'. | |
set -e | |
if [ "$(whoami)" == "root" ] | |
then | |
ssuddo="" | |
mensaje 'Ejecutando como usuario raíz.' | |
else | |
ssuddo="sudo " | |
mensaje "Usando sudo para compilar." | |
fi | |
# Actualiza repositorios de Ubuntu con el comando 'apt'. | |
ejecutar 'apt update' 'Actualizando repositorios...' | |
# Instala software para descargar e instalar los paquetes necesarios. | |
ejecutar 'apt --assume-yes install jq sed tar wget' "Instalando software básico..." | |
# Instala las librearías necesarias apra curl. | |
ejecutar 'apt --assume-yes install libgsasl7-dev libssl-dev libssh-dev zlib1g-dev libbrotli-dev libidn11-dev librtmp-dev libldap2-dev libnghttp2-dev libzstd-dev libpsl-dev libkrb5-dev' 'Instalando las dependencias de curl...' | |
# Instala el software para el manual integrado. | |
ejecutar 'apt --assume-yes install groff' 'Instalando software base para documentación' | |
# Instala el software necesario para compilar curl. | |
ejecutar 'apt --assume-yes install gcc make git' "Instalando software para control de versionesy para compilación" | |
# Usa la utilería de Wouter van Bommel para https://snapcraft.io/curl | |
set -e | |
mensaje "Revisando versiones liberadas de curl en releases..." | |
wget --quiet https://api.github.com/repos/curl/curl/releases -O releases.json | |
VERSION_RAW=$(grep . releases.json | grep tag_name | cut -d '"' -f4 | head -1) | |
TARBALL_URL=$(grep browser_download releases.json | grep "${VERSION_RAW}\/" | grep ".tar.gz" | cut -d'"' -f4 | grep -v "asc") | |
TARBALL=$(basename "${TARBALL_URL}") | |
mensaje "Descargando curl comprimido, versión ${TARBALL_URL}..." | |
wget --quiet "${TARBALL_URL}" -O "${TARBALL}" | |
mensaje "Descomprimiendo ${TARBALL}..." | |
dir_name="$(echo "${TARBALL}" | cut -d '.' -f1)"".""$(echo "${TARBALL}" | cut -d '.' -f2)"".""$(echo "${TARBALL}" | cut -d '.' -f3)""/include/curl/curlver.h" | |
tar xf "${TARBALL}" --strip-components=1 "${dir_name}" | |
tar xzvf "${TARBALL}" | |
rm releases.json "${TARBALL}" | |
VERSION=$(grep "#define LIBCURL_VERSION " include/curl/curlver.h | cut -d '"' -f2) | |
mensaje "Instalando curl versión ${VERSION}..." | |
ejecutar "apt --assume-yes install gcc make git" "Instalando herramienta gcc, make y git." | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment