diff options
author | Michał Górny <mgorny@gentoo.org> | 2014-03-13 08:10:46 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2014-03-13 08:10:46 +0000 |
commit | 26bdccc726811aa853f80537a6097d6e0b1a9149 (patch) | |
tree | 799a288e0f843e8e823e03a3f92fda8613dd9c99 /eclass/python-utils-r1.eclass | |
parent | Initial import, ebuild by me (diff) | |
download | gentoo-2-26bdccc726811aa853f80537a6097d6e0b1a9149.tar.gz gentoo-2-26bdccc726811aa853f80537a6097d6e0b1a9149.tar.bz2 gentoo-2-26bdccc726811aa853f80537a6097d6e0b1a9149.zip |
Add python_doexe() and python_newexe() to handle implementation-specific executables without shebangs.
Diffstat (limited to 'eclass/python-utils-r1.eclass')
-rw-r--r-- | eclass/python-utils-r1.eclass | 98 |
1 files changed, 66 insertions, 32 deletions
diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index c1bb626a4388..979e44954f0a 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.51 2014/03/12 09:29:39 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.52 2014/03/13 08:10:46 mgorny Exp $ # @ECLASS: python-utils-r1 # @MAINTAINER: @@ -694,49 +694,32 @@ python_scriptinto() { python_scriptroot=${1} } -# @FUNCTION: python_doscript +# @FUNCTION: python_doexe # @USAGE: <files>... # @DESCRIPTION: -# Install the given scripts into current python_scriptroot, +# Install the given executables into current python_scriptroot, # for the current Python implementation (${EPYTHON}). # -# All specified files must start with a 'python' shebang. The shebang -# will be converted, the file will be renamed to be EPYTHON-suffixed -# and a wrapper will be installed in place of the original name. -# -# Example: -# @CODE -# src_install() { -# python_foreach_impl python_doscript ${PN} -# } -# @CODE -python_doscript() { +# The executable will be wrapped properly for the Python implementation, +# though no shebang mangling will be performed. +python_doexe() { debug-print-function ${FUNCNAME} "${@}" local f for f; do - python_newscript "${f}" "${f##*/}" + python_newexe "${f}" "${f##*/}" done } -# @FUNCTION: python_newscript +# @FUNCTION: python_newexe # @USAGE: <path> <new-name> -# @DESCRIPTION: -# Install the given script into current python_scriptroot -# for the current Python implementation (${EPYTHON}), and name it -# <new-name>. -# -# The file must start with a 'python' shebang. The shebang will be -# converted, the file will be renamed to be EPYTHON-suffixed -# and a wrapper will be installed in place of the <new-name>. +# Install the given executable into current python_scriptroot, +# for the current Python implementation (${EPYTHON}). # -# Example: -# @CODE -# src_install() { -# python_foreach_impl python_newscript foo.py foo -# } -# @CODE -python_newscript() { +# The executable will be wrapped properly for the Python implementation, +# though no shebang mangling will be performed. It will be renamed +# to <new-name>. +python_newexe() { debug-print-function ${FUNCNAME} "${@}" [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' @@ -763,11 +746,62 @@ python_newscript() { exeinto "${d}" newexe "${f}" "${newfn}" || die ) - _python_rewrite_shebang "${ED%/}/${d}/${newfn}" # install the wrapper _python_ln_rel "${ED%/}"$(_python_get_wrapper_path) \ "${ED%/}/${wrapd}/${barefn}" || die + + # don't use this at home, just call python_doscript() instead + if [[ ${_PYTHON_REWRITE_SHEBANG} ]]; then + _python_rewrite_shebang "${ED%/}/${d}/${newfn}" + fi +} + +# @FUNCTION: python_doscript +# @USAGE: <files>... +# @DESCRIPTION: +# Install the given scripts into current python_scriptroot, +# for the current Python implementation (${EPYTHON}). +# +# All specified files must start with a 'python' shebang. The shebang +# will be converted, and the files will be wrapped properly +# for the Python implementation. +# +# Example: +# @CODE +# src_install() { +# python_foreach_impl python_doscript ${PN} +# } +# @CODE +python_doscript() { + debug-print-function ${FUNCNAME} "${@}" + + local _PYTHON_REWRITE_SHEBANG=1 + python_doexe "${@}" +} + +# @FUNCTION: python_newscript +# @USAGE: <path> <new-name> +# @DESCRIPTION: +# Install the given script into current python_scriptroot +# for the current Python implementation (${EPYTHON}), and name it +# <new-name>. +# +# The file must start with a 'python' shebang. The shebang will be +# converted, and the file will be wrapped properly for the Python +# implementation. It will be renamed to <new-name>. +# +# Example: +# @CODE +# src_install() { +# python_foreach_impl python_newscript foo.py foo +# } +# @CODE +python_newscript() { + debug-print-function ${FUNCNAME} "${@}" + + local _PYTHON_REWRITE_SHEBANG=1 + python_newexe "${@}" } # @ECLASS-VARIABLE: python_moduleroot |