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