| 1 | # Copyright 1999-2008 Gentoo Foundation |
1 | # Copyright 1999-2008 Gentoo Foundation |
| 2 | # Distributed under the terms of the GNU General Public License v2 |
2 | # Distributed under the terms of the GNU General Public License v2 |
| 3 | # $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.47 2008/10/26 17:26:18 hawking Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.48 2008/10/26 17:34:44 hawking Exp $ |
| 4 | |
4 | |
| 5 | # @ECLASS: python.eclass |
5 | # @ECLASS: python.eclass |
| 6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
| 7 | # python@gentoo.org |
7 | # python@gentoo.org |
| 8 | # |
8 | # |
| … | |
… | |
| 154 | # |
154 | # |
| 155 | # Example: |
155 | # Example: |
| 156 | # python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py |
156 | # python_mod_compile /usr/lib/python2.3/site-packages/pygoogle.py |
| 157 | # |
157 | # |
| 158 | python_mod_compile() { |
158 | python_mod_compile() { |
| 159 | local f myroot |
159 | local f myroot myfiles=() |
| 160 | |
160 | |
| 161 | # Check if phase is pkg_postinst() |
161 | # Check if phase is pkg_postinst() |
| 162 | [[ ${EBUILD_PHASE} != postinst ]] &&\ |
162 | [[ ${EBUILD_PHASE} != postinst ]] &&\ |
| 163 | die "${FUNCNAME} should only be run in pkg_postinst()" |
163 | die "${FUNCNAME} should only be run in pkg_postinst()" |
| 164 | |
164 | |
| 165 | # allow compiling for older python versions |
165 | # allow compiling for older python versions |
| 166 | if [ -n "${PYTHON_OVERRIDE_PYVER}" ]; then |
166 | if [[ "${PYTHON_OVERRIDE_PYVER}" ]]; then |
| 167 | PYVER=${PYTHON_OVERRIDE_PYVER} |
167 | PYVER=${PYTHON_OVERRIDE_PYVER} |
| 168 | else |
168 | else |
| 169 | python_version |
169 | python_version |
| 170 | fi |
170 | fi |
| 171 | |
171 | |
| 172 | # strip trailing slash |
172 | # strip trailing slash |
| 173 | myroot="${ROOT%/}" |
173 | myroot="${ROOT%/}" |
| 174 | |
174 | |
| 175 | # respect ROOT |
175 | # respect ROOT |
| 176 | for f in $@; do |
176 | for f in $@; do |
| 177 | [ -f "${myroot}/${f}" ] && myfiles="${myfiles} ${myroot}/${f}" |
177 | [[ -f "${myroot}/${f}" ]] && myfiles+=("${myroot}/${f}") |
| 178 | done |
178 | done |
| 179 | |
179 | |
| 180 | if [ -n "${myfiles}" ]; then |
180 | if ((${#myfiles[@]})); then |
| 181 | python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py ${myfiles} |
181 | python${PYVER} ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}" |
| 182 | python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py ${myfiles} |
182 | python${PYVER} -O ${myroot}/usr/$(get_libdir)/python${PYVER}/py_compile.py "${myfiles[@]}" |
| 183 | else |
183 | else |
| 184 | ewarn "No files to compile!" |
184 | ewarn "No files to compile!" |
| 185 | fi |
185 | fi |
| 186 | } |
186 | } |
| 187 | |
187 | |