/[gentoo-x86]/eclass/python.eclass
Gentoo

Diff of /eclass/python.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.49 Revision 1.50
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.49 2008/10/26 17:46:31 hawking Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/python.eclass,v 1.50 2008/10/26 21:21:34 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#
276# and determine if they are orphaned (eg. their corresponding .py is missing.) 276# and determine if they are orphaned (eg. their corresponding .py is missing.)
277# if they are, then it will remove their corresponding .pyc and .pyo 277# if they are, then it will remove their corresponding .pyc and .pyo
278# 278#
279# This function should only be run in pkg_postrm() 279# This function should only be run in pkg_postrm()
280python_mod_cleanup() { 280python_mod_cleanup() {
281 local SEARCH_PATH myroot 281 local SEARCH_PATH=() myroot src_py
282 282
283 # Check if phase is pkg_postrm() 283 # Check if phase is pkg_postrm()
284 [[ ${EBUILD_PHASE} != postrm ]] &&\ 284 [[ ${EBUILD_PHASE} != postrm ]] &&\
285 die "${FUNCNAME} should only be run in pkg_postrm()" 285 die "${FUNCNAME} should only be run in pkg_postrm()"
286 286
287 # strip trailing slash 287 # strip trailing slash
288 myroot="${ROOT%/}" 288 myroot="${ROOT%/}"
289 289
290 if [ $# -gt 0 ]; then 290 if (($#)); then
291 for path in $@; do 291 SEARCH_PATH=("${@#/}")
292 SEARCH_PATH="${SEARCH_PATH} ${myroot}/${path#/}" 292 SEARCH_PATH=("${SEARCH_PATH[@]/#/$myroot/}")
293 done
294 else 293 else
295 for path in ${myroot}/usr/lib*/python*/site-packages; do 294 SEARCH_PATH=("${myroot}"/usr/lib*/python*/site-packages)
296 SEARCH_PATH="${SEARCH_PATH} ${path}"
297 done
298 fi 295 fi
299 296
300 for path in ${SEARCH_PATH}; do 297 for path in "${SEARCH_PATH[@]}"; do
301 einfo "Cleaning orphaned Python bytecode from ${path} .." 298 einfo "Cleaning orphaned Python bytecode from ${path} .."
302 for obj in $(find ${path} -name '*.py[co]'); do 299 while read -rd ''; do
303 src_py="${obj%[co]}" 300 src_py="${REPLY%[co]}"
304 if [ ! -f "${src_py}" ]; then 301 [[ -f "${src_py}" ]] && continue
305 einfo "Purging ${src_py}[co]" 302 einfo "Purging ${src_py}[co]"
306 rm -f ${src_py}[co] 303 rm -f "${src_py}"[co]
307 fi 304 done < <(find "${path}" -name '*.py[co]' -print0)
308 done 305
309 # attempt to remove directories that maybe empty 306 # attempt to remove directories that maybe empty
310 for dir in $(find ${path} -type d | sort -r); do 307 while read -r dir; do
311 rmdir ${dir} 2>/dev/null 308 rmdir "${dir}" 2>/dev/null
312 done 309 done < <(find "${path}" -type d | sort -r)
313 done 310 done
314} 311}

Legend:
Removed from v.1.49  
changed lines
  Added in v.1.50

  ViewVC Help
Powered by ViewVC 1.1.20