[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#841533: You could revert to gcc-5



You can use this to revert to gcc-5, which still works.

Use it as:

# gcc-select <old version> <new version>

e.g.
# gcc-select 6 5

   ... will revert to gcc 5 to allow you to compile a kernel.

# gcc-select 5 6

   ... will revert to gcc-6.

   Obviously, you need to be root for this. And while it works fine for
gcc-5 and gcc-6, I have no idea whether it'll work for previous or
future gcc versions. It depends on whether gcc, cc and other executables
are symlinked to gcc-5, cc-6 and so on.

Hope it helps.

 .....Ron
 

-- 
Ron Murray <rjmx@rjmx.net>
PGP Fingerprint: 4D99 70E3 2317 334B 141E  7B63 12F7 E865 B5E2 E761

#! /bin/bash

# Select gcc version
# Assumes "gcc" etc in linked to "gcc-5" etc


BINDIR="/usr/bin"

# Array contining links to be changed
declare LINKS=("cpp" "g++" "gcc" "gcc-ar" "gcc-nm" "gcc-ranlib" \
					 "gcov" "gcov-tool" "gfortran")

# Make sure it's specified
OLDVER=$1
NEWVER=$2

if [ -z "${OLDVER}" ] || [ -z "${NEWVER}" ]
then
	echo "Usage: gcc-select [oldver] [newver]"
	echo "Currently:"
	ls -l ${BINDIR}/${LINKS[0]}
	exit
fi

for LINK in ${LINKS[*]}
do
	echo ${LINK}

	# Check that old and new destinations exist
	TARGET=${BINDIR}/${LINK}
	OLDPOINT=${TARGET}-${OLDVER}
	NEWPOINT=${TARGET}-${NEWVER}

	if [ ! -e ${OLDPOINT} ]
	then
		echo "Current destination ${OLDPOINT} doesn't exist."
		exit
	fi
	
	if [ ! -e ${NEWPOINT} ]
	then
		echo "Intended destination ${NEWPOINT} doesn't exist."
		exit
	fi

	if ! rm -f ${TARGET}
	then
		echo "Error removing link ${TARGET}."
		exit
	fi
	
	if ! ln -sf ${NEWPOINT} ${TARGET}
	then
		echo "Error creating symbolic link ${NEWPOINT} --> ${TARGET}"
		exit
	fi
	
done

echo "Done."

Attachment: signature.asc
Description: OpenPGP digital signature


Reply to: