From e76753b47f13fba670da0c2a794ce46224013eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Date: Sun, 20 Oct 2013 00:11:46 +0200 Subject: [PATCH] distutils-r1: parse & handle custom --install-scripts. Some ebuilds don't like the sane defaults and like to override --install-scripts. Parse that argument in order to obtain the requested install dir, and place the wrapper there. Fixes: https://bugs.gentoo.org/show_bug.cgi?id=487788 --- eclass/distutils-r1.eclass | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index acc791b..9ede335 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -407,21 +407,21 @@ distutils-r1_python_test() { } # @FUNCTION: _distutils-r1_wrap_scripts -# @USAGE: +# @USAGE: # @INTERNAL # @DESCRIPTION: # Moves and wraps all installed scripts/executables as necessary. _distutils-r1_wrap_scripts() { debug-print-function ${FUNCNAME} "${@}" + [[ ${#} -eq 2 ]] || die "usage: ${FUNCNAME} " local path=${1} - [[ ${path} ]] || die "${FUNCNAME}: no path given" + local bindir=${2} if ! _python_want_python_exec2; then - local PYTHON_SCRIPTDIR=${EPREFIX}/usr/bin + local PYTHON_SCRIPTDIR=${bindir} fi - mkdir -p "${path}${EPREFIX}/usr/bin" || die local f while IFS= read -r -d '' f; do local basename=${f##*/} @@ -429,6 +429,7 @@ _distutils-r1_wrap_scripts() { [[ -d ${f} ]] && die "Unexpected directory: ${f}" + mkdir -p "${path}${bindir}" || die local shebang read -r shebang < "${f}" if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then @@ -440,14 +441,14 @@ _distutils-r1_wrap_scripts() { mv "${f}" "${newf}" || die fi - debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}" + debug-print "${FUNCNAME}: installing wrapper at ${bindir}/${basename}" _python_ln_rel "${path}${EPREFIX}"$(_python_get_wrapper_path) \ - "${path}${EPREFIX}/usr/bin/${basename}" || die + "${path}${bindir}/${basename}" || die elif _python_want_python_exec2; then debug-print "${FUNCNAME}: non-matching shebang: ${shebang}" - debug-print "${FUNCNAME}: moving to /usr/bin/${basename}" - mv "${f}" "${path}${EPREFIX}/usr/bin/${basename}" || die + debug-print "${FUNCNAME}: moving to ${bindir}/${basename}" + mv "${f}" "${path}${bindir}/${basename}" || die fi done < <(find "${path}${PYTHON_SCRIPTDIR}" -mindepth 1 -print0) } @@ -491,14 +492,33 @@ distutils-r1_python_install() { flags+=( --install-scripts="${PYTHON_SCRIPTDIR}" ) fi - esetup.py install "${flags[@]}" "${@}" + esetup.py install "${@}" "${flags[@]}" if [[ -d ${root}$(python_get_sitedir)/tests ]]; then die "Package installs 'tests' package, file collisions likely." fi if [[ ! ${DISTUTILS_SINGLE_IMPL} ]]; then - _distutils-r1_wrap_scripts "${root}" + # user may override --install-scripts + # note: this is poor but distutils argv parsing is dumb + local scriptdir=${EPREFIX}/usr/bin + set -- "${mydistutilsargs[@]}" "${@}" + while [[ ${@} ]]; do + local a=${1} + shift + + case "${a}" in + --install-scripts=*) + scriptdir=${a#--install-scripts=} + ;; + --install-scripts) + scriptdir=${1} + shift + ;; + esac + done + + _distutils-r1_wrap_scripts "${root}" "${scriptdir}" multibuild_merge_root "${root}" "${D}" fi } -- 1.8.4