Support FEATURES=force-prefix.
[portage.git] / bin / ebuild-helpers / dodoc
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 if [ $# -lt 1 ] ; then
8         helpers_die "${0##*/}: at least one argument needed"
9         exit 1  
10 fi
11
12 [[ " ${FEATURES} " == *" force-prefix "* ]] || \
13         case "$EAPI" in 0|1|2) ED=${D} ;; esac
14
15 dir="${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}"
16 if [ ! -d "${dir}" ] ; then
17         install -d "${dir}"
18 fi
19
20 ret=0
21 for x in "$@" ; do
22         if [ -d "${x}" ] ; then
23                 eqawarn "QA Notice: dodoc argument '${x}' is a directory"
24         elif [ -s "${x}" ] ; then
25                 install -m0644 "${x}" "${dir}" || { ((ret|=1)); continue; }
26                 ecompress --queue "${dir}/${x##*/}"
27         elif [ ! -e "${x}" ] ; then
28                 echo "!!! ${0##*/}: $x does not exist" 1>&2
29                 ((ret|=1))
30         fi
31 done
32
33 [[ $ret -ne 0 ]] && helpers_die "${0##*/} failed"
34 exit ${ret}