Support PORTAGE_REPOSITORIES environmental variable, which overrides
[portage.git] / bin / ebuild-helpers / doexe
1 #!/bin/bash
2 # Copyright 1999-2012 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 if ! ___eapi_has_prefix_variables; then
13         ED=${D}
14 fi
15
16 if [[ ! -d ${ED}${_E_EXEDESTTREE_} ]] ; then
17         install -d "${ED}${_E_EXEDESTTREE_}"
18 fi
19
20 TMP=$T/.doexe_tmp
21 mkdir "$TMP"
22
23 ret=0
24
25 for x in "$@" ; do
26         if [ -L "${x}" ] ; then
27                 cp "$x" "$TMP"
28                 mysrc=$TMP/${x##*/}
29         elif [ -d "${x}" ] ; then
30                 __vecho "doexe: warning, skipping directory ${x}"
31                 continue
32         else
33                 mysrc="${x}"
34         fi
35         if [ -e "$mysrc" ] ; then
36                 install $EXEOPTIONS "$mysrc" "$ED$_E_EXEDESTTREE_"
37         else
38                 echo "!!! ${0##*/}: $mysrc does not exist" 1>&2
39                 false
40         fi
41         ((ret|=$?))
42 done
43
44 rm -rf "$TMP"
45
46 [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
47 exit $ret