On 11/30/10 03:24, Zac Medico wrote:
> Yes, hopefully something like this will do it:
> 
> pkg_preinst() {
>       main_active_python=$(eselect python show)
> }
> 
> pkg_postinst() {
>       if [[ -n $main_active_python &&
>               $main_active_python != $(eselect python show) ]] ; then
>               einfo "restoring active python interpreter"
>               eselect python set "$main_active_python"
>       fi
> }

Intersting approach.

My debugging ebuild (attached) confirms a fitting order of invocations:

  # sudo EMERGE_DEFAULT_OPTS= emerge -1 =virtual/debug-2.7.1 \
      | fgrep STAGE
   * STAGE pkg_setup (slot 2.7, version 2.7.1)
   * STAGE src_unpack (slot 2.7, version 2.7.1)
   * STAGE src_prepare (slot 2.7, version 2.7.1)
   * STAGE src_configure (slot 2.7, version 2.7.1)
   * STAGE src_compile (slot 2.7, version 2.7.1)
   * STAGE src_install (slot 2.7, version 2.7.1)
   * STAGE pkg_preinst (slot 2.7, version 2.7.1)
   * STAGE pkg_prerm (version 2.7, slot 2.7)          <----
   * STAGE pkg_postrm (version 2.7, slot 2.7)         <----
   * STAGE pkg_postinst (slot 2.7, version 2.7.1)

Shall we give that approach a try?


One case it doesn't seem to catch though is when you just run

  emerge -C dev-lang/python:X.Y

on a machine where Python X.Y was installed with eselect_python_update()
still in place.  Correct?



Sebastian
# Copyright 1999-2010 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI="2"

inherit versionator

SLOT=$(get_version_component_range 1-2)
KEYWORDS="amd64"

for stage in src_{unpack,prepare,configure,compile,install} 
pkg_{config,setup,{pre,post}{inst,rm}} ; do
        eval "${stage}"'() {    ewarn "STAGE ${FUNCNAME} (slot ${SLOT}, version 
${PV})" ; }'
done

Reply via email to