public inbox for gentoo-python@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-python] [PATCH] Introduce python_newscript().
@ 2013-02-02  1:46 Michał Górny
  2013-02-02  1:56 ` [gentoo-python] " Mike Gilbert
  0 siblings, 1 reply; 4+ messages in thread
From: Michał Górny @ 2013-02-02  1:46 UTC (permalink / raw
  To: gentoo-python; +Cc: python, jlec, Michał Górny

Requested by jlec, I think.
---
 gx86/eclass/python-utils-r1.eclass | 47 ++++++++++++++++++++++++++++++--------
 1 file changed, 37 insertions(+), 10 deletions(-)

diff --git a/gx86/eclass/python-utils-r1.eclass b/gx86/eclass/python-utils-r1.eclass
index b425302..c5a1f6e 100644
--- a/gx86/eclass/python-utils-r1.eclass
+++ b/gx86/eclass/python-utils-r1.eclass
@@ -521,7 +521,34 @@ python_scriptinto() {
 python_doscript() {
 	debug-print-function ${FUNCNAME} "${@}"
 
+	local f
+	for f; do
+		python_newscript "${f}" "${f}"
+	done
+}
+
+# @FUNCTION: python_newscript
+# @USAGE: <path> <new-name>
+# @DESCRIPTION:
+# Install the given script into current python_scriptroot
+# for the current Python implementation (${EPYTHON}), and name it
+# <new-name>.
+#
+# The file must start with a 'python' shebang. The shebang will be
+# converted, the file will be renamed to be EPYTHON-suffixed
+# and a wrapper will be installed in place of the <new-name>.
+#
+# Example:
+# @CODE
+# src_install() {
+#   python_foreach_impl python_newscript foo.py foo
+# }
+# @CODE
+python_newscript() {
+	debug-print-function ${FUNCNAME} "${@}"
+
 	[[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).'
+	[[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>"
 
 	local d=${python_scriptroot:-${DESTTREE}/bin}
 	local INSDESTTREE INSOPTIONS
@@ -529,18 +556,18 @@ python_doscript() {
 	insinto "${d}"
 	insopts -m755
 
-	local f
-	for f; do
-		local oldfn=${f##*/}
-		local newfn=${oldfn}-${EPYTHON}
+	local f=${1}
+	local barefn=${2}
 
-		debug-print "${FUNCNAME}: ${oldfn} -> ${newfn}"
-		newins "${f}" "${newfn}" || die
-		_python_rewrite_shebang "${ED}/${d}/${newfn}"
+	local oldfn=${f##*/}
+	local newfn=${barefn}-${EPYTHON}
 
-		# install the wrapper
-		_python_ln_rel "${ED}"/usr/bin/python-exec "${ED}/${d}/${oldfn}" || die
-	done
+	debug-print "${FUNCNAME}: ${oldfn} -> ${newfn}"
+	newins "${f}" "${newfn}" || die
+	_python_rewrite_shebang "${ED}/${d}/${newfn}"
+
+	# install the wrapper
+	_python_ln_rel "${ED}"/usr/bin/python-exec "${ED}/${d}/${barefn}" || die
 }
 
 # @ECLASS-VARIABLE: python_moduleroot
-- 
1.8.1.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-02-02 15:32 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-02  1:46 [gentoo-python] [PATCH] Introduce python_newscript() Michał Górny
2013-02-02  1:56 ` [gentoo-python] " Mike Gilbert
2013-02-02  9:58   ` Michał Górny
2013-02-02 15:32     ` Mike Gilbert

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox