--- /usr/portage/eclass/kernel-2.eclass 2005-07-21 10:05:35.000000000 -0400 +++ /usr/local/src/kernel-2.eclass 2005-07-27 16:06:44.000000000 -0400 @@ -533,24 +533,45 @@ preinst_headers() { #============================================================== postinst_sources() { local MAKELINK=0 + local MAKE_OLDLINK=0 - # if we have USE=symlink, then force K_SYMLINK=1 - use symlink && K_SYMLINK=1 + # current and working Kernel tree. + local K_DIR - # if we are to forcably symlink, delete it if it already exists first. - if [[ -n ${K_SYMLINK} ]]; then - [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux - MAKELINK=1 - fi + # if we have USE=symlink, then force K_SYMLINK=1 + use symlink && K_SYMLINK=1 - # if the link doesnt exist, lets create it - [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1 + # if we are to forcably create the symlink for the new kernel tree, + # then first we need to delete the symlinks for the current andd backup + # kernel trees if they exsist. + if [[ -n ${K_SYMLINK} ]]; then + + if [[ -h ${ROOT}usr/src/linux ]]; then + # remove the backup kernel symlink, only when upgrading kernel + # emerging the same kernel version only removes the symlink + # for current kernel tree. + K_DIR=$(readlink ${ROOT}usr/src/linux) + [[ "${K_DIR}" != "linux-${KV_FULL}" ]] && MAKE_OLDLINK=1 + [[ -h ${ROOT}usr/src/linux-old ]] && [[ ${MAKE_OLDLINK} == 1 ]] && + rm ${ROOT}usr/src/linux-old + + # remove the link for current kernel tree + rm ${ROOT}usr/src/linux + fi + MAKELINK=1 + fi + + # enabling making a new current link if it doesn't already exsist. + [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1 + + # create the symlinks for the current and backup kernel trees. + if [[ ${MAKELINK} == 1 ]]; then + cd ${ROOT}usr/src + ln -sf linux-${KV_FULL} linux + [[ ${MAKE_OLDLINK} == 1 ]] && ln -sf ${K_DIR} linux.old + cd ${OLDPWD} + fi - if [[ ${MAKELINK} == 1 ]]; then - cd ${ROOT}usr/src - ln -sf linux-${KV_FULL} linux - cd ${OLDPWD} - fi # Don't forget to make directory for sysfs [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys