diff options
author | Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> | 2009-07-25 16:14:02 +0000 |
---|---|---|
committer | Arfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org> | 2009-07-25 16:14:02 +0000 |
commit | d013f09feb60aea17dc69211655641274061ba58 (patch) | |
tree | 1131012d1a842f4860819150ab6ba2dc3ca2f83c | |
parent | Check if interpreter exists (bug #271232). (diff) | |
download | eselect-python-d013f09feb60aea17dc69211655641274061ba58.tar.gz eselect-python-d013f09feb60aea17dc69211655641274061ba58.tar.bz2 eselect-python-d013f09feb60aea17dc69211655641274061ba58.zip |
Make /usr/bin/python a script instead of a symlink.
-rw-r--r-- | python.eselect | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/python.eselect b/python.eselect index 372a44a..04965f4 100644 --- a/python.eselect +++ b/python.eselect @@ -24,6 +24,18 @@ find_targets() { done } +set_python_script() { + local script="${INTERPRETER_PATH}${1}" target="${2}" + cat << EOF > "${script}" +#!/bin/sh +# Gentoo Python wrapper script + +[[ "\${EPYTHON}" == "${script##*/}" ]] && EPYTHON="${target}" +"\${0%/*}/\${EPYTHON:-${target}}" "\$@" +EOF + chmod +x "${script}" +} + # Try to remove python and python.1 symlinks remove_symlinks() { local symlink symlink_target symlink_target_found @@ -62,8 +74,8 @@ set_man_symlink() { popd 1>/dev/null } -# Set python and python.1 symlinks -set_symlinks() { +# Set python script and appropriate symlinks +set_scripts_and_symlinks() { local target="${1}" targets=($(find_targets )) if is_number "${target}" && [[ ${target} -ge 1 ]]; then target=${targets[$(( ${target} - 1 ))]} @@ -77,7 +89,7 @@ set_symlinks() { set_man_symlink "${target}" pushd "${INTERPRETER_PATH}" 1>/dev/null - ln -nfs "${target}" python + set_python_script "python" "${target}" ln -nfs "${target}" "${target%.*}" ln -nfs "${target/python/python-config-}" python-config ln -nfs "${target/python/pydoc}" pydoc @@ -152,17 +164,13 @@ do_set() { die -q "You didn't tell me which python interpreter to use" elif [[ -n "${2}" ]]; then die -q "Too many parameters" - elif [[ -L "${INTERPRETER_PATH}python" ]]; then + else if ! remove_symlinks; then die -q "Can't remove existing provider" - elif ! set_symlinks "${1}"; then + elif ! set_scripts_and_symlinks "${1}"; then die -q "Can't set new provider" fi set_python_docs "${1}" - elif [[ -e "${INTERPRETER_PATH}python" ]]; then - die -q "Sorry, ${INTERPRETER_PATH}python is not a symlink" - else - set_symlinks "${1}" || die -q "Can't set a new provider" fi } |