diff options
author | Ali Polatel <hawking@gentoo.org> | 2008-05-29 14:10:48 +0000 |
---|---|---|
committer | Ali Polatel <hawking@gentoo.org> | 2008-05-29 14:10:48 +0000 |
commit | 3041bd15522fa32d6a7fc8075286d2d234f3b9fc (patch) | |
tree | e5670bab8457ae082bed87ab7d3b03e095acdf09 /eclass | |
parent | added new version (diff) | |
download | gentoo-2-3041bd15522fa32d6a7fc8075286d2d234f3b9fc.tar.gz gentoo-2-3041bd15522fa32d6a7fc8075286d2d234f3b9fc.tar.bz2 gentoo-2-3041bd15522fa32d6a7fc8075286d2d234f3b9fc.zip |
python_mod_compile is now ROOT aware and can accept more than one files as argument.
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/python.eclass | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/eclass/python.eclass b/eclass/python.eclass index f17c7c7c7000..ed514f95416a 100644 --- a/eclass/python.eclass +++ b/eclass/python.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2008 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.34 2008/03/28 07:11:57 hawking Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.35 2008/05/29 14:10:48 hawking Exp $ # @ECLASS: python.eclass # @MAINTAINER: @@ -124,15 +124,16 @@ python_mod_exists() { } # @FUNCTION: python_mod_compile -# @USAGE: < file > +# @USAGE: < file > [more files ...] # @DESCRIPTION: -# Given a filename, it will pre-compile the module's .pyc and .pyo. +# Given filenames, it will pre-compile the module's .pyc and .pyo. # should only be run in pkg_postinst() # # Example: -# python_mod_compile ${ROOT}usr/lib/python2.3/site-packages/pygoogle.py +# python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py # python_mod_compile() { + local f myroot # allow compiling for older python versions if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then PYVER=${PYTHON_OVERRIDE_PYVER} @@ -140,13 +141,19 @@ python_mod_compile() { python_version fi - if [ -f "$1" ]; then - python${PYVER} -c "import py_compile; py_compile.compile('${1}')" || \ - ewarn "Failed to compile ${1}" - python${PYVER} -O -c "import py_compile; py_compile.compile('${1}')" || \ - ewarn "Failed to compile ${1}" + # strip trailing slash + myroot="${ROOT%/}" + + # respect ROOT + for f in $@; do + [ -f "${myroot}/${f}" ] && myfiles="${myfiles} ${myroot}/${f}" + done + + if [ -n "${myfiles}" ]; then + python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py ${myfiles} + python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py ${myfiles} else - ewarn "Unable to find ${1}" + ewarn "No files to compile!" fi } |