diff options
author | Michał Górny <mgorny@gentoo.org> | 2013-11-11 15:58:40 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2013-11-11 15:58:40 +0000 |
commit | 77c5bc309c3bd262935c16ed757799b3ca49d1fd (patch) | |
tree | cddb6a52941ea4748c0a31a5c3f0b3f6becdff35 /eclass/distutils-r1.eclass | |
parent | sys-apps/kexec-tools: Drop USE=zlib as it is always requiered, #490326 (diff) | |
download | gentoo-2-77c5bc309c3bd262935c16ed757799b3ca49d1fd.tar.gz gentoo-2-77c5bc309c3bd262935c16ed757799b3ca49d1fd.tar.bz2 gentoo-2-77c5bc309c3bd262935c16ed757799b3ca49d1fd.zip |
Read all shebangs before moving files to avoid breaking symlinks that are going to be scanned.
Diffstat (limited to 'eclass/distutils-r1.eclass')
-rw-r--r-- | eclass/distutils-r1.eclass | 47 |
1 files changed, 30 insertions, 17 deletions
diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index 2b609b485648..49cd155eaa64 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.90 2013/10/26 17:47:51 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.91 2013/11/11 15:58:40 mgorny Exp $ # @ECLASS: distutils-r1 # @MAINTAINER: @@ -422,35 +422,48 @@ _distutils-r1_wrap_scripts() { local PYTHON_SCRIPTDIR=${bindir} fi - local f - while IFS= read -r -d '' f; do - local basename=${f##*/} - debug-print "${FUNCNAME}: found executable at ${f#${path}/}" + local f python_files=() non_python_files=() + + if [[ -d ${path}${PYTHON_SCRIPTDIR} ]]; then + for f in "${path}${PYTHON_SCRIPTDIR}"/*; do + [[ -d ${f} ]] && die "Unexpected directory: ${f}" + debug-print "${FUNCNAME}: found executable at ${f#${path}/}" + + local shebang + read -r shebang < "${f}" + if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then + debug-print "${FUNCNAME}: matching shebang: ${shebang}" + python_files+=( "${f}" ) + elif _python_want_python_exec2; then + debug-print "${FUNCNAME}: non-matching shebang: ${shebang}" + non_python_files+=( "${f}" ) + fi - [[ -d ${f} ]] && die "Unexpected directory: ${f}" + mkdir -p "${path}${bindir}" || die + done - mkdir -p "${path}${bindir}" || die - local shebang - read -r shebang < "${f}" - if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then - debug-print "${FUNCNAME}: matching shebang: ${shebang}" + for f in "${python_files[@]}"; do + local basename=${f##*/} if ! _python_want_python_exec2; then local newf=${f%/*}/${basename}-${EPYTHON} - debug-print "${FUNCNAME}: renaming to ${newf#${path}}" + debug-print "${FUNCNAME}: renaming ${f#${path}/} to ${newf#${path}/}" mv "${f}" "${newf}" || die fi debug-print "${FUNCNAME}: installing wrapper at ${bindir}/${basename}" _python_ln_rel "${path}${EPREFIX}"$(_python_get_wrapper_path) \ "${path}${bindir}/${basename}" || die - elif _python_want_python_exec2; then - debug-print "${FUNCNAME}: non-matching shebang: ${shebang}" + done + + # (non-empty only with python-exec:2) + for f in "${non_python_files[@]}"; do + local basename=${f##*/} - debug-print "${FUNCNAME}: moving to ${bindir}/${basename}" + debug-print "${FUNCNAME}: moving ${f#${path}/} to ${bindir}/${basename}" mv "${f}" "${path}${bindir}/${basename}" || die - fi - done < <(find "${path}${PYTHON_SCRIPTDIR}" -mindepth 1 -print0) + done + fi } # @FUNCTION: distutils-r1_python_install |