[repo] update gcc profile setup function, make it able to detect the latest installed version

This commit is contained in:
Fabio Erculiani 2011-11-15 21:34:52 +01:00
parent 86a553010f
commit 88da5e0285
2 changed files with 28 additions and 20 deletions

View File

@ -31,7 +31,6 @@ echo -e "
### CUT HERE ### ### CUT HERE ###
fix_lib64_symlinks() { fix_lib64_symlinks() {
if [ -L ${ROOT}/lib64 ] ; then if [ -L ${ROOT}/lib64 ] ; then
echo "removing /lib64 symlink and moving lib to lib64..." echo "removing /lib64 symlink and moving lib to lib64..."
echo "dont hit ctrl-c until this is done" echo "dont hit ctrl-c until this is done"
@ -57,10 +56,15 @@ fix_lib64_symlinks() {
ln -s lib64 ${ROOT}/usr/X11R6/lib ln -s lib64 ${ROOT}/usr/X11R6/lib
echo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6" echo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6"
fi fi
} }
function three_four_to_five() { latest_gcc_profile() {
local gcc_dir="/etc/env.d/gcc"
local latest=$(ls -1 ${gcc_dir}/$(uname -m)* | sort | tail -n 1 2> /dev/null)
[[ -n "${latest}" ]] && echo $(basename "${latest}")
}
three_four_to_five() {
local rc=0 local rc=0
@ -82,16 +86,15 @@ function three_four_to_five() {
rc=1 rc=1
fi fi
## sys-devel/gcc:4.5 must be forced using ## sys-devel/base-gcc:LATEST must be forced using
## packages.db.system_mask inside repository db dir ## packages.db.system_mask inside repository db dir
c_profile=$(gcc-config -l | grep "\-4.5" | cut -d"[" -f 2 | cut -d"]" -f 1) c_profile=$(latest_gcc_profile)
[[ "${?}" != "0" ]] && echo "gcc-config script error" && exit 1 if [ -n "${c_profile}" ]; then
if [[ ${c_profile} =~ ^[0-9]+$ ]]; then gcc-config "${c_profile}"
gcc-config ${c_profile}
# update env # update env
env-update env-update
else else
echo "gcc-config unable to set new profile:" ${c_profile} echo "gcc-config unable to set new profile: not detected"
rc=1 rc=1
fi fi

View File

@ -10,7 +10,7 @@ NEW_BRANCH=$4
echo -e " echo -e "
>> requirements for this branch: >> requirements for this branch:
app-admin/eselect-python app-admin/eselect-python
sys-devel/gcc:4.5 sys-devel/base-gcc:4.6
>> Entropy post-upgrade migration script >> Entropy post-upgrade migration script
>> Repository: "${REPO_ID}" >> Repository: "${REPO_ID}"
>> Root: "${ROOT}" >> Root: "${ROOT}"
@ -31,7 +31,6 @@ echo -e "
### CUT HERE ### ### CUT HERE ###
fix_lib64_symlinks() { fix_lib64_symlinks() {
if [ -L ${ROOT}/lib64 ] ; then if [ -L ${ROOT}/lib64 ] ; then
echo "removing /lib64 symlink and moving lib to lib64..." echo "removing /lib64 symlink and moving lib to lib64..."
echo "dont hit ctrl-c until this is done" echo "dont hit ctrl-c until this is done"
@ -57,10 +56,15 @@ fix_lib64_symlinks() {
ln -s lib64 ${ROOT}/usr/X11R6/lib ln -s lib64 ${ROOT}/usr/X11R6/lib
echo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6" echo "fixed broken lib64/lib symlink in ${ROOT}/usr/X11R6"
fi fi
} }
function three_four_to_five() { latest_gcc_profile() {
local gcc_dir="/etc/env.d/gcc"
local latest=$(ls -1 ${gcc_dir}/$(uname -m)* | sort | tail -n 1 2> /dev/null)
[[ -n "${latest}" ]] && echo $(basename "${latest}")
}
three_four_to_five() {
local rc=0 local rc=0
@ -82,16 +86,15 @@ function three_four_to_five() {
rc=1 rc=1
fi fi
## sys-devel/gcc:4.5 must be forced using ## sys-devel/base-gcc:LATEST must be forced using
## packages.db.system_mask inside repository db dir ## packages.db.system_mask inside repository db dir
c_profile=$(gcc-config -l | grep "\-4.5" | cut -d"[" -f 2 | cut -d"]" -f 1) c_profile=$(latest_gcc_profile)
[[ "${?}" != "0" ]] && echo "gcc-config script error" && exit 1 if [ -n "${c_profile}" ]; then
if [[ ${c_profile} =~ ^[0-9]+$ ]]; then gcc-config "${c_profile}"
gcc-config ${c_profile}
# update env # update env
env-update env-update
else else
echo "gcc-config unable to set new profile:" ${c_profile} echo "gcc-config unable to set new profile: not detected"
rc=1 rc=1
fi fi
@ -133,7 +136,9 @@ function three_four_to_five() {
} }
# run this in any case, it will fix symlinks setup # run this in any case, it will fix symlinks setup
fix_lib64_symlinks if [ "$(uname -m)" = "x86_64" ]; then
fix_lib64_symlinks
fi
# migration script from branch 4 to 5 # migration script from branch 4 to 5
[[ "${OLD_BRANCH}" = "4" ]] && [[ "${NEW_BRANCH}" = "5" ]] && three_four_to_five [[ "${OLD_BRANCH}" = "4" ]] && [[ "${NEW_BRANCH}" = "5" ]] && three_four_to_five