summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichał Górny <mgorny@gentoo.org>2015-11-17 21:32:36 +0100
committerMichał Górny <mgorny@gentoo.org>2015-11-17 21:39:09 +0100
commitaae084d8e670a9f001cbcf486c34097ebedbb2b1 (patch)
tree54e3e8d776149e11cc9b76d5357195af75804276 /app-eselect/eselect-python
parentapp-eselect/eselect-python: Bump to 20151117 (diff)
downloadgentoo-aae084d8e670a9f001cbcf486c34097ebedbb2b1.tar.gz
gentoo-aae084d8e670a9f001cbcf486c34097ebedbb2b1.tar.bz2
gentoo-aae084d8e670a9f001cbcf486c34097ebedbb2b1.zip
app-eselect/eselect-python: Preserve previous python[23] selection
Diffstat (limited to 'app-eselect/eselect-python')
-rw-r--r--app-eselect/eselect-python/eselect-python-20151117.ebuild37
-rw-r--r--app-eselect/eselect-python/eselect-python-99999999.ebuild37
2 files changed, 62 insertions, 12 deletions
diff --git a/app-eselect/eselect-python/eselect-python-20151117.ebuild b/app-eselect/eselect-python/eselect-python-20151117.ebuild
index 9968e7fac7c4..86e9a3cf2af7 100644
--- a/app-eselect/eselect-python/eselect-python-20151117.ebuild
+++ b/app-eselect/eselect-python/eselect-python-20151117.ebuild
@@ -40,14 +40,39 @@ src_install() {
done
}
+pkg_preinst() {
+ local py
+
+ # Copy python[23] selection from the old format (symlink)
+ for py in 2 3; do
+ # default to none
+ declare -g "PREV_PYTHON${py}"=
+
+ if [[ -L ${EROOT}/usr/bin/python${py} ]]; then
+ local target=$(readlink "${EROOT}/usr/bin/python${py}")
+
+ # check if it's actually old eselect symlink
+ if [[ ${target} == python?.? ]]; then
+ declare -g "PREV_PYTHON${py}=${target}"
+ fi
+ fi
+ done
+}
+
pkg_postinst() {
+ local py
+
if has_version 'dev-lang/python'; then
eselect python update --if-unset
fi
- if has_version '=dev-lang/python-2*'; then
- eselect python update --python2 --if-unset
- fi
- if has_version '=dev-lang/python-3*'; then
- eselect python update --python3 --if-unset
- fi
+
+ for py in 2 3; do
+ local pyvar=PREV_PYTHON${py}
+ if [[ -n ${!pyvar} ]]; then
+ einfo "Setting Python${py} to ${!pyvar}"
+ eselect python set "--python${py}" "${!pyvar}"
+ elif has_version "=dev-lang/python-${py}*"; then
+ eselect python update "--python${py}" --if-unset
+ fi
+ done
}
diff --git a/app-eselect/eselect-python/eselect-python-99999999.ebuild b/app-eselect/eselect-python/eselect-python-99999999.ebuild
index 9968e7fac7c4..86e9a3cf2af7 100644
--- a/app-eselect/eselect-python/eselect-python-99999999.ebuild
+++ b/app-eselect/eselect-python/eselect-python-99999999.ebuild
@@ -40,14 +40,39 @@ src_install() {
done
}
+pkg_preinst() {
+ local py
+
+ # Copy python[23] selection from the old format (symlink)
+ for py in 2 3; do
+ # default to none
+ declare -g "PREV_PYTHON${py}"=
+
+ if [[ -L ${EROOT}/usr/bin/python${py} ]]; then
+ local target=$(readlink "${EROOT}/usr/bin/python${py}")
+
+ # check if it's actually old eselect symlink
+ if [[ ${target} == python?.? ]]; then
+ declare -g "PREV_PYTHON${py}=${target}"
+ fi
+ fi
+ done
+}
+
pkg_postinst() {
+ local py
+
if has_version 'dev-lang/python'; then
eselect python update --if-unset
fi
- if has_version '=dev-lang/python-2*'; then
- eselect python update --python2 --if-unset
- fi
- if has_version '=dev-lang/python-3*'; then
- eselect python update --python3 --if-unset
- fi
+
+ for py in 2 3; do
+ local pyvar=PREV_PYTHON${py}
+ if [[ -n ${!pyvar} ]]; then
+ einfo "Setting Python${py} to ${!pyvar}"
+ eselect python set "--python${py}" "${!pyvar}"
+ elif has_version "=dev-lang/python-${py}*"; then
+ eselect python update "--python${py}" --if-unset
+ fi
+ done
}