public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Michał Górny" <mgorny@gentoo.org>
To: gentoo-python@lists.gentoo.org
Cc: "Michał Górny" <mgorny@gentoo.org>
Subject: [gentoo-python] [PATCH] distutils-r1: parse & handle custom --install-scripts.
Date: Sun, 20 Oct 2013 00:15:58 +0200	[thread overview]
Message-ID: <1382220958-26756-1-git-send-email-mgorny@gentoo.org> (raw)

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: <path>
+# @USAGE: <path> <bindir>
 # @INTERNAL
 # @DESCRIPTION:
 # Moves and wraps all installed scripts/executables as necessary.
 _distutils-r1_wrap_scripts() {
 	debug-print-function ${FUNCNAME} "${@}"
 
+	[[ ${#} -eq 2 ]] || die "usage: ${FUNCNAME} <path> <bindir>"
 	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



             reply	other threads:[~2013-10-19 22:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-19 22:15 Michał Górny [this message]
2013-10-22 15:18 ` [gentoo-python] [PATCH] distutils-r1: parse & handle custom --install-scripts Michał Górny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1382220958-26756-1-git-send-email-mgorny@gentoo.org \
    --to=mgorny@gentoo.org \
    --cc=gentoo-python@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox