Last active
July 5, 2023 04:57
-
-
Save lopesivan/6f638631552ed7090e2236cd83358028 to your computer and use it in GitHub Desktop.
update-alternatives
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
#!/usr/bin/env bash | |
test -n "$DEBUG" && set -x | |
# __ __ ___ | |
# /\ \\ \ /'___`\ | |
# \ \ \\ \ /\_\ /\ \ | |
# \ \ \\ \_\/_/// /__ | |
# \ \__ ,__\ // /_\ \ | |
# \/_/\_\_//\______/ | |
# \/_/ \/_____/ | |
# Algoritimos | |
# | |
# | |
# Author: Ivan Lopes | |
# Mail: ivan@42algoritmos.com.br | |
# Site: http://www.42algoritmos.com.br | |
# License: gpl | |
# Phone: +1 561 801 7985 | |
# Language: Shell Script | |
# File: u.sh | |
# Date: Sex 03 Ago 2018 03:39:01 -03 | |
# Description: | |
# ---------------------------------------------------------------------------- | |
# Modo strict | |
set -euo pipefail | |
# ---------------------------------------------------------------------------- | |
############################################################################## | |
############################################################################## | |
############################################################################## | |
# ---------------------------------------------------------------------------- | |
versions=( | |
5 6 7 8 | |
) | |
let i=50 | |
for v in ${versions[*]}; do | |
echo -e '\e[1;49;36m'gcc-${v}'\e[0m' >&2 | |
echo -n sudo update-alternatives | |
echo -n " "--install /usr/bin/gcc gcc /usr/bin/gcc-$v $i | |
dpkg -L gcc-$v g++-$v| | |
awk -F'/bin/' '/.*bin\// {print $2}' | | |
while read line; do | |
[[ "$line" == "gcc-$v" ]] && continue | |
cmd=${line%-*} | |
echo -n " "--slave /usr/bin/$cmd $cmd /usr/bin/$line | |
done | |
echo | |
let i=$((i + 10)) | |
done | |
# ---------------------------------------------------------------------------- | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this, very useful! Helped me fix an issue where I thought I was building python with gcc 10, but because the generated python make file used
x86_64-linux-gnu-gcc
and notgcc
, it was actually building with gcc 9...On Ubuntu 20.04, with gcc9 and gcc10, I refactored this and generated the command to use via:
It generated: