> 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 > }
I have combined your idea with Arfever's no-active-version-prevention into the patch attached. Anyone, please let me know if you consider it sane enough for applying to all dev-lang/python ebuilds in Gentoo. Thanks! Sebastian
>From 8a6e0f532e469d851777c98a92fa09c2ae59489f Mon Sep 17 00:00:00 2001 From: Sebastian Pipping <sebast...@pipping.org> Date: Tue, 30 Nov 2010 17:52:55 +0100 Subject: [PATCH] dev-lang/python: Apply combined restoring (zmedico) and repair (arfrever) of active python version --- dev-lang/python/Manifest | 2 +- dev-lang/python/python-2.7.1.ebuild | 38 +++++++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletions(-) diff --git a/dev-lang/python/Manifest b/dev-lang/python/Manifest index 9baa821..a068c28 100644 --- a/dev-lang/python/Manifest +++ b/dev-lang/python/Manifest @@ -25,7 +25,7 @@ EBUILD python-2.4.6.ebuild 8977 RMD160 38f346fc41002623b3b2b0a2b0b711bb7db7dd4e EBUILD python-2.5.4-r4.ebuild 9327 RMD160 a6457b0ff606f4049cadeb9884cb4fe957b9958c SHA1 e747734e97cb520fb39f320f2c455b14b3ea0e6e SHA256 3bf309b7d68e56c45ace9d6967df8b534775593730ae5be67ce155f6b33d2bb0 EBUILD python-2.6.5-r3.ebuild 9122 RMD160 27044cab65202cfadfb8499b8a772fbfa52b1fc2 SHA1 ca3bdf0cf333de4d51fd7ac8a624ea97bf0cd00b SHA256 80c0fb7445edd89b371380f9aefdaeb4f4951aa5a534250e0ebbf8080dbba9d4 EBUILD python-2.6.6-r1.ebuild 9315 RMD160 35f711a57bb4947d791d7702097e907817d3d3cf SHA1 01bac9a202d9cde208c6812b3238c8e1cf4e8a02 SHA256 0920fb7e34be6cec6e0f7dc7bf1d63f9312293a95b6f1f74accdd443053c60ef -EBUILD python-2.7.1.ebuild 10966 RMD160 7594d04f91503a6ae99cf4e6f322706f90dee217 SHA1 ed45a2db66c88b76c2b8cba260dc05fe91d2a2fb SHA256 3901a104673f155f4e35d9fee6f006d4655c688cfa7595aac83950b3d67446c0 +EBUILD python-2.7.1.ebuild 12114 RMD160 b53e6cfe32cfea5ed7f74183e4c66725284f8206 SHA1 a95c77665111d59d7dae83ae557d3966fcf3b42d SHA256 4fb4e52af3f2bc9a0a00d73fe922e92d32e071fce9228424ecc014cbd1d7de05 EBUILD python-2.7.ebuild 9425 RMD160 243ca80a7c4099fb0c06ababc461ef8bd1ad8417 SHA1 720f41cffb98b733fe242a415f43e575eb865a1f SHA256 dbb329d402907253537750ad2fa9c133037c9f4c28aa70c3720f5d21b2fdb3f1 EBUILD python-3.1.2-r4.ebuild 9215 RMD160 36e9ddbf18008b63653a3704c20e64e9f321c092 SHA1 33cb0ab09dd085b3a7724e9cc07ee630e13b6e6d SHA256 598c9199129f5b6efa9dc283f8d3de89428f034591365180f7a266fe2cce3d89 EBUILD python-3.1.3.ebuild 10398 RMD160 30ce48f92bf7796074e6410deca31ce9cc48e94a SHA1 4b68dbf85eb41c09e050c0f9ab54614ad43fa240 SHA256 2ed7457384281b818bacc6c904ccc24c032b0b7438ae7d625eb2c5f3c727bdec diff --git a/dev-lang/python/python-2.7.1.ebuild b/dev-lang/python/python-2.7.1.ebuild index 4b8c34c..3d5a1fe 100644 --- a/dev-lang/python/python-2.7.1.ebuild +++ b/dev-lang/python/python-2.7.1.ebuild @@ -331,13 +331,49 @@ src_install() { rmdir "${ED}$(python_get_libdir)/test/data" } +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() { + save_active_python_version + if has_version "<${CATEGORY}/${PN}-${SLOT}" && ! has_version "${CATEGORY}/${PN}:2.7"; then python_updater_warning="1" fi } +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 "${active_python_2}" --python2 + fi + if [[ -n "${active_python_3}" && + "${active_python_3}" != $(eselect python show --python3) ]] ; then + einfo "Restoring main active Python 3.x interpreter: ${active_python_3}" + eselect python set "${active_python_3}" --python3 + 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() { + restore_active_python_version + ensure_python_symlink + python_mod_optimize -f -x "/(site-packages|test|tests)/" $(python_get_libdir) if [[ "${python_updater_warning}" == "1" ]]; then @@ -354,5 +390,7 @@ pkg_postinst() { } pkg_postrm() { + ensure_python_symlink + python_mod_cleanup $(python_get_libdir) } -- 1.7.3.2