Last active
July 3, 2024 01:22
-
-
Save totszwai/c133295f8d02edde46132f12ae8b91f5 to your computer and use it in GitHub Desktop.
Script that will update system autoconf to the desire version as alternatives
This file contains hidden or 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 | |
set -e | |
WHAT=autoconf | |
VERSION=2.71 | |
FULLNAME=${WHAT}-${VERSION} | |
INSTDIR=/opt/${FULLNAME} | |
function install() { | |
[ $# -eq 0 ] && { run_error "Usage: install <version>"; exit; } | |
local VERSION=${1} | |
local TARBALL=${FULLNAME}.tar.xz | |
local URL=ftp://ftp.gnu.org/gnu/${WHAT}/${TARBALL} | |
local WHERE=/tmp/update-${WHAT} | |
mkdir -p ${WHERE} | |
cd ${WHERE} | |
echo "Downloading ${URL}" | |
curl -L --create-dirs -o ${TARBALL} ${URL} | |
if [ -f "${TARBALL}" ]; then | |
tar -xf ${TARBALL} | |
cd ${FULLNAME} | |
./configure --prefix=${INSTDIR} | |
make | |
echo "Installing..." | |
sudo make install | |
echo -e "${TARBALL} installed \e[1;32mOK\e[39m" | |
else | |
echo -e "Cannot download ${URL}" | |
exit 1 | |
fi | |
} | |
function install_alternatives() { | |
for fullpath in ${INSTDIR}/bin/* ; do | |
local NAME="$(basename ${fullpath})" | |
#echo "sudo update-alternatives --install /usr/local/bin/${NAME} ${NAME} ${fullpath} 50" | |
sudo update-alternatives --install /usr/local/bin/${NAME} ${NAME} ${fullpath} 50 | |
done | |
# https://superuser.com/a/1086506/459389 | |
sudo ln -sf ${INSTDIR}/share/autoconf /usr/share/${FULLNAME} | |
. ~/.profile | |
} | |
function remove_alternatives() { | |
for fullpath in ${INSTDIR}/bin/* ; do | |
local NAME="$(basename ${fullpath})" | |
#echo "sudo update-alternatives --remove ${NAME} ${fullpath}" | |
sudo update-alternatives --remove ${NAME} ${fullpath} | |
done | |
sudo rm /usr/share/${FULLNAME} | |
. ~/.profile | |
} | |
if declare -f "$1" > /dev/null | |
then | |
"$@" | |
else | |
install ${VERSION} | |
install_alternatives | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment