diff options
author | Michał Górny <mgorny@gentoo.org> | 2012-11-21 09:01:50 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2012-11-21 09:01:50 +0000 |
commit | 0a95092d701db5438a86d291b70ff1ba19b074b2 (patch) | |
tree | d9daa8aa69eb08b3056bf12ed6e31499f3506794 | |
parent | Add debian patches to fix building with recent gtkmm3 wrt #444024 by Denis M.... (diff) | |
download | gentoo-2-0a95092d701db5438a86d291b70ff1ba19b074b2.tar.gz gentoo-2-0a95092d701db5438a86d291b70ff1ba19b074b2.tar.bz2 gentoo-2-0a95092d701db5438a86d291b70ff1ba19b074b2.zip |
Introduce python_doscript() to install Python scripts.
-rw-r--r-- | eclass/ChangeLog | 5 | ||||
-rw-r--r-- | eclass/python-r1.eclass | 75 |
2 files changed, 78 insertions, 2 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog index 2478d1953435..3ed122dd5797 100644 --- a/eclass/ChangeLog +++ b/eclass/ChangeLog @@ -1,6 +1,9 @@ # ChangeLog for eclass directory # Copyright 1999-2012 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.513 2012/11/19 21:38:33 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.514 2012/11/21 09:01:50 mgorny Exp $ + + 21 Nov 2012; Michał Górny <mgorny@gentoo.org> python-r1.eclass: + Introduce python_doscript() to install Python scripts. 19 Nov 2012; Michał Górny <mgorny@gentoo.org> python-r1.eclass: Introduce a check for USE_PYTHON & PYTHON_TARGETS compatibility. diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index a08e0a0523be..552341fd8ac5 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.18 2012/11/19 21:38:33 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.19 2012/11/21 09:01:50 mgorny Exp $ # @ECLASS: python-r1 # @MAINTAINER: @@ -743,3 +743,76 @@ python_replicate_script() { _python_ln_rel "${ED}"/usr/bin/python-exec "${f}" || die done } + +# @ECLASS-VARIABLE: python_scriptroot +# @DEFAULT_UNSET +# @DESCRIPTION: +# The current script destination for python_doscript(). The path +# is relative to the installation root (${ED}). +# +# When unset, ${DESTTREE}/bin (/usr/bin by default) will be used. +# +# Can be set indirectly through the python_scriptinto() function. +# +# Example: +# @CODE +# src_install() { +# local python_scriptroot=${GAMES_BINDIR} +# python_foreach_impl python_doscript foo +# } +# @CODE + +# @FUNCTION: python_scriptinto +# @USAGE: <new-path> +# @DESCRIPTION: +# Set the current scriptroot. The new value will be stored +# in the 'python_scriptroot' environment variable. The new value need +# be relative to the installation root (${ED}). +# +# Alternatively, you can set the variable directly. +python_scriptinto() { + debug-print-function ${FUNCNAME} "${@}" + + python_scriptroot=${1} +} + +# @FUNCTION: python_doscript +# @USAGE: <files>... +# @DESCRIPTION: +# Install the given scripts into current python_scriptroot, +# for the current Python implementation (${EPYTHON}). +# +# All specified files 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 original name. +# +# Example: +# @CODE +# src_install() { +# python_foreach_impl python_doscript ${PN} +# } +# @CODE +python_doscript() { + debug-print-function ${FUNCNAME} "${@}" + + [[ ${EPYTHON} ]] || die 'No Python implementation set (EPYTHON is null).' + + local d=${python_scriptroot:-${DESTTREE}/bin} + local INSDESTTREE INSOPTIONS + + insinto "${d}" + insopts -m755 + + local f + for f; do + local oldfn=${f##*/} + local newfn=${oldfn}-${EPYTHON} + + debug-print "${FUNCNAME}: ${oldfn} -> ${newfn}" + newins "${f}" "${newfn}" + _python_rewrite_shebang "${D}/${d}/${newfn}" + + # install the wrapper + _python_ln_rel "${ED}"/usr/bin/python-exec "${D}/${d}/${oldfn}" || die + done +} |