From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 0417C1381F3 for ; Sat, 19 Oct 2013 22:18:07 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 90321E0AFB; Sat, 19 Oct 2013 22:18:06 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2D4D5E0AFB for ; Sat, 19 Oct 2013 22:18:06 +0000 (UTC) Received: from pomiot.lan (77-255-21-180.adsl.inetia.pl [77.255.21.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: mgorny) by smtp.gentoo.org (Postfix) with ESMTPSA id 91D1933F168; Sat, 19 Oct 2013 22:18:04 +0000 (UTC) From: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= To: gentoo-python@lists.gentoo.org Cc: =?UTF-8?q?Micha=C5=82=20G=C3=B3rny?= Subject: [gentoo-python] [PATCH] distutils-r1: parse & handle custom --install-scripts. Date: Sun, 20 Oct 2013 00:15:58 +0200 Message-Id: <1382220958-26756-1-git-send-email-mgorny@gentoo.org> X-Mailer: git-send-email 1.8.4 Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Discussions centering around the Python ecosystem in Gentoo Linux X-BeenThere: gentoo-python@gentoo.org X-BeenThere: gentoo-python@lists.gentoo.org X-Archives-Salt: fe5c04b8-c257-4181-b19d-bbc3d3ae5969 X-Archives-Hash: 2f3454f987db338374f60283249f6f24 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