7c60d9b86c063994d0d4b612d846641d128b0d62
[portage.git] / bin / ebuild-helpers / prepinfo
1 #!/bin/bash
2 # Copyright 1999-2011 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
6
7 [[ " ${USE} " == *" prefix "* ]] || \
8         case "$EAPI" in 0|1|2) ED=${D} ;; esac
9
10 if [[ -z $1 ]] ; then
11         infodir="/usr/share/info"
12 else
13         if [[ -d ${ED}$1/share/info ]] ; then
14                 infodir="$1/share/info"
15         else
16                 infodir="$1/info"
17         fi
18 fi
19
20 if [[ ! -d ${ED}${infodir} ]] ; then
21         if [[ -n $1 ]] ; then
22                 vecho "${0##*/}: '${infodir}' does not exist!"
23                 exit 1
24         else
25                 exit 0
26         fi
27 fi
28
29 find "${ED}${infodir}" -type d -print0 | while read -r -d $'\0' x ; do
30         for f in "${x}"/.keepinfodir*; do
31                 [[ -e ${f} ]] && continue 2
32         done
33         rm -f "${x}"/dir{,.info}{,.gz,.bz2}
34 done
35
36 has "${EAPI}" 0 1 2 3 || exit 0
37 exec ecompressdir --queue "${infodir}"