Created
July 3, 2024 01:21
-
-
Save totszwai/487158a8e520ffabfa48166b10720980 to your computer and use it in GitHub Desktop.
Script that will update system automake 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=automake | |
VERSION=1.16.5 | |
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 | |
} | |
# Usage: ./update-automake.sh install_alternatives | |
function install_alternatives() { | |
local SHORT=${VERSION%.*} | |
sudo update-alternatives --install /usr/local/bin/automake automake ${INSTDIR}/bin/automake 50 \ | |
--slave /usr/local/bin/aclocal aclocal ${INSTDIR}/bin/aclocal | |
sudo update-alternatives --install /usr/local/bin/automake-${SHORT} automake-${SHORT} ${INSTDIR}/bin/automake-${SHORT} 50 | |
sudo update-alternatives --install /usr/local/bin/aclocal-${SHORT} aclocal-${SHORT} ${INSTDIR}/bin/aclocal-${SHORT} 50 | |
# https://superuser.com/a/1086506/459389 | |
sudo ln -sf ${INSTDIR}/share/automake-${SHORT} /usr/share/automake-${SHORT} | |
sudo ln -sf ${INSTDIR}/share/aclocal-${SHORT} /usr/share/aclocal-${SHORT} | |
. ~/.profile | |
} | |
# Usage: ./update-automake.sh remove_alternatives | |
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 | |
local SHORT=${VERSION%.*} | |
sudo rm /usr/share/automake-${SHORT} | |
sudo rm /usr/share/aclocal-${SHORT} | |
. ~/.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