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