diff options
author | Michał Górny <mgorny@gentoo.org> | 2013-09-17 13:24:39 +0000 |
---|---|---|
committer | Michał Górny <mgorny@gentoo.org> | 2013-09-17 13:24:39 +0000 |
commit | 7ba398a91aa74eb10eb5d8f378f0ff93e2ff9046 (patch) | |
tree | 2c3a1f2eaaa3fe42f005b016743d2b9a16dd94ea /eclass | |
parent | Version bump (diff) | |
download | gentoo-2-7ba398a91aa74eb10eb5d8f378f0ff93e2ff9046.tar.gz gentoo-2-7ba398a91aa74eb10eb5d8f378f0ff93e2ff9046.tar.bz2 gentoo-2-7ba398a91aa74eb10eb5d8f378f0ff93e2ff9046.zip |
Clean up Python script install/wrapping functions.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/ChangeLog | 6 | ||||
-rw-r--r-- | eclass/distutils-r1.eclass | 35 | ||||
-rw-r--r-- | eclass/python-r1.eclass | 32 | ||||
-rw-r--r-- | eclass/python-utils-r1.eclass | 17 |
4 files changed, 43 insertions, 47 deletions
diff --git a/eclass/ChangeLog b/eclass/ChangeLog index a7fa0b572ee8..bf0f1799ae61 100644 --- a/eclass/ChangeLog +++ b/eclass/ChangeLog @@ -1,6 +1,10 @@ # ChangeLog for eclass directory # Copyright 1999-2013 Gentoo Foundation; Distributed under the GPL v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.967 2013/09/17 12:25:50 tommy Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/ChangeLog,v 1.968 2013/09/17 13:24:39 mgorny Exp $ + + 17 Sep 2013; Michał Górny <mgorny@gentoo.org> distutils-r1.eclass, + python-r1.eclass, python-utils-r1.eclass: + Clean up Python script install/wrapping functions. 17 Sep 2013; Thomas Sachau (Tommy[D]) <tommy@gentoo.org> multilib-build.eclass: diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass index c2872b30a6dd..1923084d1443 100644 --- a/eclass/distutils-r1.eclass +++ b/eclass/distutils-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.77 2013/08/25 21:15:28 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/distutils-r1.eclass,v 1.78 2013/09/17 13:24:39 mgorny Exp $ # @ECLASS: distutils-r1 # @MAINTAINER: @@ -409,39 +409,37 @@ distutils-r1_python_test() { : } -# @FUNCTION: _distutils-r1_rename_scripts +# @FUNCTION: _distutils-r1_wrap_scripts # @USAGE: <path> # @INTERNAL # @DESCRIPTION: -# Renames installed Python scripts to be implementation-suffixed. -# ${EPYTHON} needs to be set to the implementation name. -# -# All executable scripts having shebang referencing ${EPYTHON} -# in given path will be renamed. -_distutils-r1_rename_scripts() { +# Moves and wraps all installed scripts/executables as necessary. +_distutils-r1_wrap_scripts() { debug-print-function ${FUNCNAME} "${@}" local path=${1} [[ ${path} ]] || die "${FUNCNAME}: no path given" + mkdir -p "${path}/usr/bin" || die local f while IFS= read -r -d '' f; do - debug-print "${FUNCNAME}: found executable at ${f#${D}/}" + local basename=${f##*/} + debug-print "${FUNCNAME}: found executable at ${f#${path}/}" local shebang read -r shebang < "${f}" - if [[ ${shebang} == '#!'*${EPYTHON}* ]] - then + if [[ ${shebang} == '#!'*${EPYTHON}* ]]; then debug-print "${FUNCNAME}: matching shebang: ${shebang}" - local newf=${f}-${EPYTHON} - debug-print "${FUNCNAME}: renaming to ${newf#${D}/}" + local newf=${f%/*}/${basename}-${EPYTHON} + debug-print "${FUNCNAME}: renaming to ${newf#${path}}" mv "${f}" "${newf}" || die - debug-print "${FUNCNAME}: installing wrapper at ${f#${D}/}" - _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec "${f}" || die + debug-print "${FUNCNAME}: installing wrapper at /usr/bin/${basename}" + _python_ln_rel "${path}${EPREFIX}"/usr/bin/python-exec \ + "${path}${EPREFIX}/usr/bin/${basename}" || die fi - done < <(find "${path}" -type f -executable -print0) + done < <(find "${path}/usr/bin" -type f -print0) } # @FUNCTION: distutils-r1_python_install @@ -474,15 +472,16 @@ distutils-r1_python_install() { local root=${D}/_${EPYTHON} [[ ${DISTUTILS_SINGLE_IMPL} ]] && root=${D} + flags+=( --root="${root}" ) - esetup.py install "${flags[@]}" --root="${root}" "${@}" + 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_rename_scripts "${root}" + _distutils-r1_wrap_scripts "${root}" multibuild_merge_root "${root}" "${D}" fi } diff --git a/eclass/python-r1.eclass b/eclass/python-r1.eclass index 6994952ed5ef..6f59c5fdd619 100644 --- a/eclass/python-r1.eclass +++ b/eclass/python-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.59 2013/09/12 17:31:11 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python-r1.eclass,v 1.60 2013/09/17 13:24:39 mgorny Exp $ # @ECLASS: python-r1 # @MAINTAINER: @@ -741,28 +741,22 @@ python_export_best() { python_replicate_script() { debug-print-function ${FUNCNAME} "${@}" - local suffixes=() - - _add_suffix() { - suffixes+=( "${EPYTHON}" ) - } - python_foreach_impl _add_suffix - debug-print "${FUNCNAME}: suffixes = ( ${suffixes[@]} )" - - local f suffix - for suffix in "${suffixes[@]}"; do - for f; do - local newf=${f}-${suffix} - - debug-print "${FUNCNAME}: ${f} -> ${newf}" - cp "${f}" "${newf}" || die + _python_replicate_script() { + local f + for f in "${files[@]}"; do + cp -p "${f}" "${f}-${EPYTHON}" || die done + _python_rewrite_shebang "${EPYTHON}" \ + "${files[@]/%/-${EPYTHON}}" + } - _python_rewrite_shebang "${suffix}" "${@/%/-${suffix}}" - done + local files=( "${@}" ) + python_foreach_impl _python_replicate_script + # install the wrappers + local f for f; do - _python_ln_rel "${ED}"/usr/bin/python-exec "${f}" || die + _python_ln_rel "${ED%/}"/usr/bin/python-exec "${f}" || die done } diff --git a/eclass/python-utils-r1.eclass b/eclass/python-utils-r1.eclass index ed6fc0308ce4..0e4ab60a579f 100644 --- a/eclass/python-utils-r1.eclass +++ b/eclass/python-utils-r1.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.35 2013/09/16 17:58:15 mgorny Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python-utils-r1.eclass,v 1.36 2013/09/17 13:24:39 mgorny Exp $ # @ECLASS: python-utils-r1 # @MAINTAINER: @@ -734,22 +734,21 @@ python_newscript() { [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <path> <new-name>" local d=${python_scriptroot:-${DESTTREE}/bin} - local INSDESTTREE INSOPTIONS - - insinto "${d}" - insopts -m755 local f=${1} local barefn=${2} local newfn=${barefn}-${EPYTHON} - debug-print "${FUNCNAME}: ${f} -> ${d}/${newfn}" - newins "${f}" "${newfn}" || die - _python_rewrite_shebang "${ED}/${d}/${newfn}" + ( + exeinto "${d}" + newexe "${f}" "${newfn}" || die + ) + _python_rewrite_shebang "${ED%/}/${d}/${newfn}" # install the wrapper - _python_ln_rel "${ED}"/usr/bin/python-exec "${ED}/${d}/${barefn}" || die + _python_ln_rel "${ED%/}"/usr/bin/python-exec \ + "${ED%/}/${d}/${barefn}" || die } # @ECLASS-VARIABLE: python_moduleroot |