diff options
author | 2014-06-05 04:22:21 -0700 | |
---|---|---|
committer | 2014-06-05 04:22:21 -0700 | |
commit | 23baad9afc3888016ffc721bd31f8548ec2a5457 (patch) | |
tree | d8249f32e5435b74c4978afa70e263aa0ef55207 /eclass | |
parent | eclass/pam-multilib: sync with upstream (diff) | |
download | gmt-23baad9afc3888016ffc721bd31f8548ec2a5457.tar.gz gmt-23baad9afc3888016ffc721bd31f8548ec2a5457.tar.bz2 gmt-23baad9afc3888016ffc721bd31f8548ec2a5457.zip |
eclass/*python*: move shebang fixing (partial upstream sync)
Signed-off-by: Gregory M. Tuner <gmt@be-evil.net>
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/python-multilib-r1.eclass | 4 | ||||
-rw-r--r-- | eclass/python-multilib-single-r1.eclass | 2 | ||||
-rw-r--r-- | eclass/python-multilib-utils-r1.eclass | 17 | ||||
-rw-r--r-- | eclass/python-single-r1.eclass | 46 |
4 files changed, 17 insertions, 52 deletions
diff --git a/eclass/python-multilib-r1.eclass b/eclass/python-multilib-r1.eclass index 481fa27..63df77a 100644 --- a/eclass/python-multilib-r1.eclass +++ b/eclass/python-multilib-r1.eclass @@ -831,7 +831,7 @@ python_replicate_script() { doexe "${files[@]}" ) - _python_rewrite_shebang "${EPYTHON}" \ + python_rewrite_shebang_multilib "${EPYTHON}" \ "${files[@]/*\//${D%/}/${PYTHON_SCRIPTDIR}/}" else local f @@ -839,7 +839,7 @@ python_replicate_script() { cp -p "${f}" "${f}-${EPYTHON}" || die done - _python_rewrite_shebang "${EPYTHON}" \ + python_rewrite_shebang_multilib "${EPYTHON}" \ "${files[@]/%/-${EPYTHON}}" fi } diff --git a/eclass/python-multilib-single-r1.eclass b/eclass/python-multilib-single-r1.eclass index 87689fd..a1d620f 100644 --- a/eclass/python-multilib-single-r1.eclass +++ b/eclass/python-multilib-single-r1.eclass @@ -489,7 +489,7 @@ python_fix_shebang() { debug-print "${FUNCNAME}: rewriting shebang: ${shebang}" einfo "Fixing shebang in ${f#${D}}" - python_multilib_rewrite_shebang "${f}" + python_rewrite_shebang_multilib "${f}" esac done < <(find "${path}" -type f -print0) done diff --git a/eclass/python-multilib-utils-r1.eclass b/eclass/python-multilib-utils-r1.eclass index 294ff8e..98439a5 100644 --- a/eclass/python-multilib-utils-r1.eclass +++ b/eclass/python-multilib-utils-r1.eclass @@ -1274,7 +1274,7 @@ python_get_scriptdir() { # From: #!/usr/bin/env FOO=bar python # To: #!/usr/bin/env FOO=bar python2.7-x86_32 # @CODE -python_multilib_rewrite_shebang() { +python_rewrite_shebang_multilib() { debug-print-function ${FUNCNAME} "$(mg-qm "${@}")" [[ $# -lt 1 ]] && return 0 @@ -1351,17 +1351,26 @@ python_multilib_rewrite_shebang() { } _python_rewrite_shebang() { - die "${FUNCNAME}: not supported here. Somebody forgot to use python_multilib_rewrite_shebang" + die "${FUNCNAME}: not supported here. Somebody forgot to use python_rewrite_shebang_multilib" } # pretty easy to make this typo since we dropped the '_'. -_python_multilib_rewrite_shebang() { +_python_rewrite_shebang_multilib() { ewarn "${FUNCNAME}: I'm gonna let it slide, but the correct function" ewarn "name is python_multilib_rewrite_shebang with no '_' in front of it." echo python_rewrite_shebang_multilib "$@" } +python_fix_shebang() { + die "${FUNCNAME}: not supported here. Somebody forgot to use python_fix_shebang_multilib" +} + +python_fix_shebang_multilib() { + # FIXME: drift vs upstream equivalent + python_rewrite_shebang_multilib "$@" +} + # @FUNCTION: _python_ln_rel # @USAGE: <from> <to> # @INTERNAL @@ -1568,7 +1577,7 @@ python_newscript() { exeinto "${d}" newexe "${f}" "${newfn}" || die ) - _python_rewrite_shebang "${ED%/}/${d}/${newfn}" + python_rewrite_shebang_multilib "${ED%/}/${d}/${newfn}" # install the wrapper _python_ln_rel "${ED%/}"$(_python_get_wrapper_path) \ diff --git a/eclass/python-single-r1.eclass b/eclass/python-single-r1.eclass index 2ae1c83..7de42bb 100644 --- a/eclass/python-single-r1.eclass +++ b/eclass/python-single-r1.eclass @@ -204,7 +204,7 @@ _python_single_set_globals() { } _python_single_set_globals -# @FUNCTION: _distutils-r1_python_is_multilib +# @FUNCTION: _python-single-r1_python_is_multilib # @INTERNAL # @DESCRIPTION: # Returns true iff the currently applicable python implementation @@ -284,49 +284,5 @@ python-single-r1_pkg_setup() { python_setup } -# @FUNCTION: python_fix_shebang -# @USAGE: <path>... -# @DESCRIPTION: -# Replace the shebang in Python scripts with the current Python -# implementation (EPYTHON). If a directory is passed, works recursively -# on all Python scripts. -# -# Only files having a 'python' shebang will be modified; other files -# will be skipped. If a script has a complete shebang matching -# the chosen interpreter version, it is left unmodified. If a script has -# a complete shebang matching other version, the command dies. -python_fix_shebang() { - debug-print-function ${FUNCNAME} "${@}" - - [[ ${1} ]] || die "${FUNCNAME}: no paths given" - [[ ${EPYTHON} ]] || die "${FUNCNAME}: EPYTHON unset (pkg_setup not called?)" - - local path f - for path; do - while IFS= read -r -d '' f; do - local shebang=$(head -n 1 "${f}") - - case "${shebang}" in - '#!'*${EPYTHON}*) - debug-print "${FUNCNAME}: in file ${f#${D}}" - debug-print "${FUNCNAME}: shebang matches EPYTHON: ${shebang}" - ;; - '#!'*python[23].[0123456789]*|'#!'*pypy-c*|'#!'*jython*) - debug-print "${FUNCNAME}: in file ${f#${D}}" - debug-print "${FUNCNAME}: incorrect specific shebang: ${shebang}" - - die "${f#${D}} has a specific Python shebang not matching EPYTHON" - ;; - '#!'*python*) - debug-print "${FUNCNAME}: in file ${f#${D}}" - debug-print "${FUNCNAME}: rewriting shebang: ${shebang}" - - einfo "Fixing shebang in ${f#${D}}" - _python_rewrite_shebang "${f}" - esac - done < <(find "${path}" -type f -print0) - done -} - _PYTHON_SINGLE_R1=1 fi |