blob: f35cbc63a5976cf611c86e53381be27fd5851c9b [file] [log] [blame]
#!/bin/bash
# Copyright 1999-2006 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Id: /var/cvsroot/gentoo-src/portage/bin/doins,v 1.7.2.2 2004/12/17 22:25:13 carpaski Exp $
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
if [ $# -lt 1 ] ; then
echo "${0}: at least one argument needed"
exit 1
fi
if [ "${1}" == "-r" ] ; then
DOINSRECUR=y
shift
else
DOINSRECUR=n
fi
[ -z "${INSDEPTH}" ] && declare -i INSDEPTH=0
if [ ${INSDEPTH} -gt 30 ] ; then
echo "${0}: sanity check ... 30 directories is too much :("
exit 1
fi
if [ "${INSDESTTREE%${D}*}" == "" ]; then
vecho "-------------------------------------------------------" 1>&2
vecho "You should not use \${D} with helpers." 1>&2
vecho " --> ${INSDESTTREE}" 1>&2
vecho "-------------------------------------------------------" 1>&2
#exit 1
fi
[ ! -d "${D}${INSDESTTREE}" ] && dodir "${INSDESTTREE}"
for x in "$@" ; do
if [ -L "$x" ] ; then
cp "$x" "${T}"
mysrc="${T}/$(/usr/bin/basename "${x}")"
elif [ -d "$x" ] ; then
if [ "${DOINSRECUR}" == "n" ] ; then
continue
fi
mydir="${INSDESTTREE}/$(basename "${x}")"
find "${x}" -mindepth 1 -maxdepth 1 -exec \
env \
INSDESTTREE="${mydir}" \
INSDEPTH=$((INSDEPTH+1)) \
doins -r {} \;
continue
else
mysrc="${x}"
fi
install ${INSOPTIONS} "${mysrc}" "${D}${INSDESTTREE}"
done