summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2016-02-01 23:25:47 +0100
committerMichał Górny <mgorny@gentoo.org>2016-02-06 10:57:35 +0100
commit58d767fc717245014598dea17b8f4e7c14bbe1a5 (patch)
treeb916bb782d404cf9f9134b5a1d4b33415f0a0c95 /dev-lang/python-exec
parentapp-eselect/eselect-python: Updated for wrappers' move to python-exec (diff)
downloadgentoo-58d767fc717245014598dea17b8f4e7c14bbe1a5.tar.gz
gentoo-58d767fc717245014598dea17b8f4e7c14bbe1a5.tar.bz2
gentoo-58d767fc717245014598dea17b8f4e7c14bbe1a5.zip
dev-lang/python-exec: Install and migrate configuration file
Diffstat (limited to 'dev-lang/python-exec')
-rw-r--r--dev-lang/python-exec/python-exec-2.9999.ebuild57
1 files changed, 45 insertions, 12 deletions
diff --git a/dev-lang/python-exec/python-exec-2.9999.ebuild b/dev-lang/python-exec/python-exec-2.9999.ebuild
index 80026683a4fe..81e31934113a 100644
--- a/dev-lang/python-exec/python-exec-2.9999.ebuild
+++ b/dev-lang/python-exec/python-exec-2.9999.ebuild
@@ -27,7 +27,7 @@ SLOT="2"
KEYWORDS="~alpha ~amd64 ~arm ~arm64 ~hppa ~ia64 ~m68k ~mips ~ppc ~ppc64 ~s390 ~sh ~sparc ~x86 ~ppc-aix ~amd64-fbsd ~x86-fbsd ~x64-freebsd ~x86-freebsd ~amd64-linux ~arm-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~m68k-mint ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
IUSE=""
-# eselect-python because of /usr/bin/python* collisions
+# eselect-python because of /usr/bin/python* collisions and new config
# python versions because of missing $scriptdir/python* symlinks
RDEPEND="
!<app-eselect/eselect-python-20160206
@@ -63,6 +63,12 @@ src_configure() {
src_install() {
default
+ # Prepare and own the template
+ sed -n -e '/^#/p' config/python-exec.conf.example \
+ > "${T}"/python-exec.conf || die
+ insinto /etc/python-exec
+ doins "${T}"/python-exec.conf
+
local f
for f in python{,2,3}; do
# can't use symlinks here since random stuff
@@ -75,18 +81,45 @@ src_install() {
}
pkg_preinst() {
- local py
+ if [[ -e ${EROOT}etc/python-exec/python-exec.conf ]]; then
+ # preserve current configuration
+ cp "${EROOT}"etc/python-exec/python-exec.conf \
+ "${ED}"etc/python-exec/python-exec.conf || die
+ else
+ # preserve previous Python version preference
+ local py old_pythons=()
+ local config_base=${EROOT}etc/env.d/python
+
+ # start with the 'global' preference (2 vs 3)
+ if [[ -f ${config_base}/config ]]; then
+ old_pythons+=( "$(<${config_base}/config)" )
+ fi
+
+ # then try specific py2/py3 selections
+ for py in 3 2; do
+ local target=
- # Copy python[23] selection from the old format (symlink)
- for py in 2 3; do
- if [[ -L ${EROOT}/usr/bin/python${py} ]]; then
- local target=$(readlink "${EROOT}/usr/bin/python${py}")
+ if [[ -f ${config_base}/python${py} ]]; then
+ # try the newer config files
+ target=$(<${config_base}/python${py})
+ elif [[ -L ${EROOT}/usr/bin/python${py} ]]; then
+ # check the older symlink format
+ target=$(readlink "${EROOT}/usr/bin/python${py}")
- # check if it's actually old eselect symlink
- if [[ ${target} == python?.? ]]; then
- einfo "Preserving Python${py} as ${target}"
- echo "${target}" > "${EROOT}/etc/env.d/python/python${py}" || die
+ # check if it's actually old eselect symlink
+ [[ ${target} == python?.? ]] || target=
fi
- fi
- done
+
+ # add the extra target if found and != global
+ if [[ ${target} && ${old_pythons[0]} != ${target} ]]; then
+ old_pythons+=( "${target}" )
+ fi
+ done
+
+ einfo "Keeping the following Python preference: ${old_pythons[*]}"
+
+ local IFS=$'\n'
+ echo "${old_pythons[*]}" \
+ >> "${ED}"etc/python-exec/python-exec.conf || die
+ fi
}