#!@PORTAGE_BASH@ # for expansion below we need some things to be defined prefix="@prefix@" exec_prefix="@exec_prefix@" # For bug #279550 we have to do some nasty trick to make sure that sed # doesn't strip the backslash in the replacement value (because it can # be a backreference) and hence escape those. Eventually in strings we # need to escape the backslash too, such that the single backslash # doesn't get lost when considered an invalid escape rootuser='@rootuser@' portagegroup='@portagegroup@' portageuser='@portageuser@' rootuser=${rootuser//\\/\\\\} portagegroup=${portagegroup//\\/\\\\\\\\} portageuser=${portageuser//\\/\\\\\\\\} # there are many ways to do this all dynamic, but we only care for raw # speed here, so let configure fill in this list and be done with it at='@' sedexp=( -e "s,${at}DEFAULT_PATH${at},@DEFAULT_PATH@,g" -e "s,${at}EXTRA_PATH${at},@EXTRA_PATH@,g" -e "s,${at}EGREP${at},@EGREP@,g" -e "s,${at}PORTAGE_BASE${at},@PORTAGE_BASE@,g" -e "s,${at}PORTAGE_BASENAME${at},@PORTAGE_BASENAME@,g" -e "s,${at}PORTAGE_BASH${at},@PORTAGE_BASH@,g" -e "s,${at}PORTAGE_DIRNAME${at},@PORTAGE_DIRNAME@,g" -e "s,${at}PORTAGE_EPREFIX${at},@PORTAGE_EPREFIX@,g" -e "s,${at}PORTAGE_FIND${at},@PORTAGE_FIND@,g" -e "s,${at}PORTAGE_GREP${at},@PORTAGE_GREP@,g" -e "s,${at}PORTAGE_MV${at},@PORTAGE_MV@,g" -e "s,${at}PORTAGE_RM${at},@PORTAGE_RM@,g" -e "s,${at}PORTAGE_SED${at},@PORTAGE_SED@,g" -e "s,${at}PORTAGE_WGET${at},@PORTAGE_WGET@,g" -e "s,${at}PORTAGE_XARGS${at},@PORTAGE_XARGS@,g" -e "s,${at}PREFIX_PORTAGE_PYTHON${at},@PREFIX_PORTAGE_PYTHON@,g" -e "s,${at}datadir${at},@datadir@,g" -e "s,${at}portagegroup${at},${portagegroup},g" -e "s,${at}portageuser${at},${portageuser},g" -e "s,${at}rootgid${at},@rootgid@,g" -e "s,${at}rootuid${at},@rootuid@,g" -e "s,${at}rootuser${at},${rootuser},g" -e "s,${at}sysconfdir${at},@sysconfdir@,g" ) sources=( ) target= args=( "$@" ) while [[ ${#@} != 0 ]] ; do case "$1" in -t) [[ -n ${target} ]] && sources=( "${sources[@]}" "${target##*/}" ) shift target=":${1}" ;; -*) shift ;; *) if [[ -z ${target} ]] ; then target="${1}" elif [[ ${target} != ":"* ]] ; then sources=( "${sources[@]}" "${target##*/}" ) target="${1}" else sources=( "${sources[@]}" "${1##*/}" ) fi ;; esac shift done target=${target#:} INSTALL="@INSTALL@" echo @INSTALL_DATA@ "${args[@]}" if [[ ! -d ${target} ]] ; then # either install will die, or it was just a single file copy @INSTALL_DATA@ "${args[@]}" && sed -i "${sedexp[@]}" "${target}" else @INSTALL_DATA@ "${args[@]}" && sed -i "${sedexp[@]}" "${sources[@]/#/${target}/}" fi