7ea29d4d4d5d14858b9df3b73640f2ca6f24f449
[portage.git] / bin / ebuild-helpers / dobin
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}${DESTTREE}/bin ]] ; then
16         install -d "${ED}${DESTTREE}/bin" || { helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/bin"; exit 2; }
17 fi
18
19 ret=0
20
21 for x in "$@" ; do
22         if [[ -e ${x} ]] ; then
23                 install -m0755 -o ${PORTAGE_INST_UID:-0} -g ${PORTAGE_INST_GID:-0} "${x}" "${ED}${DESTTREE}/bin"
24         else
25                 echo "!!! ${0##*/}: $x does not exist" 1>&2
26                 false
27         fi
28         ((ret|=$?))
29 done
30
31 [[ $ret -ne 0 ]] && helpers_die "${0##*/} failed"
32 exit ${ret}