Support PORTAGE_REPOSITORIES environmental variable, which overrides
[portage.git] / bin / ebuild-helpers / prepman
1 #!/bin/bash
2 # Copyright 1999-2012 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 # Do not compress man pages which are smaller than this (in bytes). #169260
6 SIZE_LIMIT='128'
7
8 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
9
10 if ! ___eapi_has_prefix_variables; then
11         ED=${D}
12 fi
13
14 if [[ -z $1 ]] ; then
15         mandir="${ED}usr/share/man"
16 else
17         mandir="${ED}$1/man"
18 fi
19
20 if [[ ! -d ${mandir} ]] ; then
21         eqawarn "QA Notice: prepman called with non-existent dir '${mandir#${ED}}'"
22         exit 0
23 fi
24
25 # replaced by controllable compression in EAPI 4
26 ___eapi_has_docompress && exit 0
27
28 shopt -s nullglob
29
30 really_is_mandir=0
31
32 # use some heuristics to test if this is a real mandir
33 for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do
34         [[ -d ${subdir} ]] && really_is_mandir=1 && break
35 done
36
37 [[ ${really_is_mandir} == 1 ]] && exec ecompressdir --limit ${SIZE_LIMIT} --queue "${mandir#${ED}}"
38
39 exit 0