Support FEATURES=force-prefix.
[portage.git] / bin / ebuild-helpers / prepman
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 [[ " ${FEATURES} " == *" force-prefix "* ]] || \
8         case "$EAPI" in 0|1|2) ED=${D} ;; esac
9
10 if [[ -z $1 ]] ; then 
11         mandir="${ED}usr/share/man"
12 else
13         mandir="${ED}$1/man"
14 fi
15
16 if [[ ! -d ${mandir} ]] ; then
17         eqawarn "QA Notice: prepman called with non-existent dir '${mandir#${ED}}'"
18         exit 0
19 fi
20
21 # replaced by controllable compression in EAPI 4
22 has "${EAPI}" 0 1 2 3 || exit 0
23
24 shopt -s nullglob
25
26 really_is_mandir=0
27
28 # use some heuristics to test if this is a real mandir
29 for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do
30         [[ -d ${subdir} ]] && really_is_mandir=1 && break
31 done
32
33 [[ ${really_is_mandir} == 1 ]] && exec ecompressdir --queue "${mandir#${ED}}"
34
35 exit 0