#!@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=( -r -e "s,${at}PORTAGE_BASE${at},@PORTAGE_BASE@,g" -e "s,${at}PORTAGE_BASE_PATH${at},@PORTAGE_BASE@,g" -e "s,${at}PORTAGE_BIN_PATH${at},@PORTAGE_BASE@/bin,g" -e "s,${at}PORTAGE_BASH${at},@PORTAGE_BASH@,g" -e "s,${at}PORTAGE_EPREFIX${at},@PORTAGE_EPREFIX@,g" -e "s,${at}PORTAGE_MV${at},@PORTAGE_MV@,g" -e "s,${at}PREFIX_PORTAGE_PYTHON${at},@PREFIX_PORTAGE_PYTHON@,g" -e "s,${at}EPREFIX${at},@PORTAGE_EPREFIX@,g" -e "s,${at}INSTALL_TYPE${at},SYSTEM,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" ) if [[ $1 == --hprefixify ]] ; then shift dirs='/(usr|lib(|[onx]?32|n?64)|etc|bin|sbin|var|opt|run)' sedexp+=( -e 's,([^[:alnum:]}\)\.])'"${dirs}"',\1@PORTAGE_EPREFIX@/\2,g' -e 's,^'"${dirs}"',@PORTAGE_EPREFIX@/\1,' ) fi 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