Hello!
I have done a bit more testing now. To do so I have isolated the eselect-python-update behavior into testing ebuilds (package "virtual/debug-eselect-python") reduced to just that problem (no compilation and the like, see attachment, also in sping overlay). The test scenario is made of two halves: one half is an ebuild running eselect python update on pkg_postrm (the 2.7 one, to emulate what users may have still installed), the other is an ebuild with the work-in-progress patch I plan to apply to dev-lang/python instrumented with debugging output (the 2.7.1 one). To recall, the goal is: 1) Having valid symlinks for /usr/bin/python 2) Keeping active Python versions untouched, i.e. reverting a change by an ebuild calling eselect-python-update during pkg_postrm. The test scenario is these three commands on a root shell: # EMERGE_DEFAULT_OPTS= emerge -1av =virtual/debug-eselect-python-2.7 # eselect python set python2.6 # EMERGE_DEFAULT_OPTS= emerge -1av =virtual/debug-eselect-python-2.7.1 The output of the third call is the interesting part, see attachment. Besides my earlier mixup of eselect python set --pythonX pythonX.Y # good with eselect python set pythonX.Y --pythonX # bad the patch proposed earlier seems to be a promising approach. Next I will apply this appraoch to dev-lang/python int the main tree. I expect that to take no longer than two hours, hopefully less. If you spot any practical problems with this please mail me ASAP. Wish me luck so I don't break anything for worse. Best, Sebastian
# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI="2" SLOT="2.7" KEYWORDS="amd64" DEBUG_DUMP_ACTIVE() { echo "DEBUG $1 $2 (slot ${SLOT}, version ${PV})" echo "DEBUG \${active_python_2} = '${active_python_2}'" echo "DEBUG \${active_python_3} = '${active_python_3}'" echo "DEBUG \${active_python_main} = '${active_python_main}'" echo "DEBUG \$(eselect python show --python2) = '$(eselect python show --python2)'" echo "DEBUG \$(eselect python show --python3) = '$(eselect python show --python3)'" echo "DEBUG \$(eselect python show) = '$(eselect python show)'" } save_active_python_version() { active_python_2=$(eselect python show --python2) active_python_3=$(eselect python show --python3) active_python_main=$(eselect python show) } pkg_preinst() { DEBUG_DUMP_ACTIVE Before ${FUNCNAME} save_active_python_version DEBUG_DUMP_ACTIVE After ${FUNCNAME} } ensure_python_symlink() { if [[ -z "$(eselect python show --python${PV%%.*})" ]]; then eselect python update --python${PV%%.*} fi } restore_active_python_version() { if [[ -n "${active_python_2}" && "${active_python_2}" != $(eselect python show --python2) ]] ; then einfo "Restoring active Python 2.x interpreter: ${active_python_2}" eselect python set --python2 "${active_python_2}" fi if [[ -n "${active_python_3}" && "${active_python_3}" != $(eselect python show --python3) ]] ; then einfo "Restoring active Python 3.x interpreter: ${active_python_3}" eselect python set --python3 "${active_python_3}" fi if [[ -n "${active_python_main}" && "${active_python_main}" != $(eselect python show) ]] ; then einfo "Restoring main active Python interpreter: ${active_python_main}" eselect python set "${active_python_main}" fi } pkg_postinst() { DEBUG_DUMP_ACTIVE Before ${FUNCNAME} restore_active_python_version ensure_python_symlink DEBUG_DUMP_ACTIVE After ${FUNCNAME} } pkg_postrm() { DEBUG_DUMP_ACTIVE Before ${FUNCNAME} ensure_python_symlink DEBUG_DUMP_ACTIVE After ${FUNCNAME} }
# Copyright 1999-2010 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ EAPI="2" SLOT="2.7" KEYWORDS="amd64" DEBUG_DUMP_ACTIVE() { echo "DEBUG $1 $2 (slot ${SLOT}, version ${PV})" echo "DEBUG \$(eselect python show --python2) = '$(eselect python show --python2)'" echo "DEBUG \$(eselect python show --python3) = '$(eselect python show --python3)'" echo "DEBUG \$(eselect python show) = '$(eselect python show)'" } eselect_python_update() { # Exaggerated to worst case: update of all active python versions eselect python update --python2 eselect python update --python3 eselect python update } pkg_postinst() { DEBUG_DUMP_ACTIVE Before ${FUNCNAME} eselect_python_update DEBUG_DUMP_ACTIVE After ${FUNCNAME} } pkg_postrm() { DEBUG_DUMP_ACTIVE Before ${FUNCNAME} eselect_python_update DEBUG_DUMP_ACTIVE After ${FUNCNAME} }
>>> Installing (1 of 1) virtual/debug-eselect-python-2.7.1 * checking 0 files for package collisions DEBUG Before pkg_preinst (slot 2.7, version 2.7.1) DEBUG ${active_python_2} = '' DEBUG ${active_python_3} = '' DEBUG ${active_python_main} = '' DEBUG $(eselect python show --python2) = 'python2.6' DEBUG $(eselect python show --python3) = 'python3.1' DEBUG $(eselect python show) = 'python2.6' DEBUG After pkg_preinst (slot 2.7, version 2.7.1) DEBUG ${active_python_2} = 'python2.6' DEBUG ${active_python_3} = 'python3.1' DEBUG ${active_python_main} = 'python2.6' DEBUG $(eselect python show --python2) = 'python2.6' DEBUG $(eselect python show --python3) = 'python3.1' DEBUG $(eselect python show) = 'python2.6' >>> Safely unmerging already-installed instance... No package files given... Grabbing a set. DEBUG Before pkg_postrm (slot 2.7, version 2.7) DEBUG $(eselect python show --python2) = 'python2.6' DEBUG $(eselect python show --python3) = 'python3.1' DEBUG $(eselect python show) = 'python2.6' Switching to python2.7 <--- Switching to python3.1 <--- Switching to python3.1 <--- DEBUG After pkg_postrm (slot 2.7, version 2.7) DEBUG $(eselect python show --python2) = 'python2.7' <--- DEBUG $(eselect python show --python3) = 'python3.1' DEBUG $(eselect python show) = 'python3.1' <--- >>> Original instance of package unmerged safely. DEBUG Before pkg_postinst (slot 2.7, version 2.7.1) DEBUG ${active_python_2} = 'python2.6' DEBUG ${active_python_3} = 'python3.1' DEBUG ${active_python_main} = 'python2.6' DEBUG $(eselect python show --python2) = 'python2.7' DEBUG $(eselect python show --python3) = 'python3.1' DEBUG $(eselect python show) = 'python3.1' * Restoring active Python 2.x interpreter: python2.6 <--- * Restoring main active Python interpreter: python2.6 <--- DEBUG After pkg_postinst (slot 2.7, version 2.7.1) DEBUG ${active_python_2} = 'python2.6' DEBUG ${active_python_3} = 'python3.1' DEBUG ${active_python_main} = 'python2.6' DEBUG $(eselect python show --python2) = 'python2.6' <--- DEBUG $(eselect python show --python3) = 'python3.1' DEBUG $(eselect python show) = 'python2.6' <--- >>> Auto-cleaning packages...