diff options
Diffstat (limited to 'portage_with_autodep/bin/ebuild-helpers')
47 files changed, 463 insertions, 521 deletions
diff --git a/portage_with_autodep/bin/ebuild-helpers/4/dodoc b/portage_with_autodep/bin/ebuild-helpers/4/dodoc deleted file mode 120000 index 35080ad..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/4/dodoc +++ /dev/null @@ -1 +0,0 @@ -../doins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/4/dohard b/portage_with_autodep/bin/ebuild-helpers/4/dohard deleted file mode 120000 index 1a6b57a..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/4/dohard +++ /dev/null @@ -1 +0,0 @@ -../../banned-helper
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/4/dosed b/portage_with_autodep/bin/ebuild-helpers/4/dosed deleted file mode 120000 index 1a6b57a..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/4/dosed +++ /dev/null @@ -1 +0,0 @@ -../../banned-helper
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/4/prepalldocs b/portage_with_autodep/bin/ebuild-helpers/4/prepalldocs deleted file mode 120000 index 1a6b57a..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/4/prepalldocs +++ /dev/null @@ -1 +0,0 @@ -../../banned-helper
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/dobin b/portage_with_autodep/bin/ebuild-helpers/dobin index f90d893..0ba1eb0 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dobin +++ b/portage_with_autodep/bin/ebuild-helpers/dobin @@ -1,19 +1,20 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ $# -lt 1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ ! -d ${ED}${DESTTREE}/bin ]] ; then - install -d "${ED}${DESTTREE}/bin" || { helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/bin"; exit 2; } + install -d "${ED}${DESTTREE}/bin" || { __helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/bin"; exit 2; } fi ret=0 @@ -28,5 +29,5 @@ for x in "$@" ; do ((ret|=$?)) done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/doconfd b/portage_with_autodep/bin/ebuild-helpers/doconfd index e146000..a3c09a5 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doconfd +++ b/portage_with_autodep/bin/ebuild-helpers/doconfd @@ -4,7 +4,7 @@ if [[ $# -lt 1 ]] ; then source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi diff --git a/portage_with_autodep/bin/ebuild-helpers/dodir b/portage_with_autodep/bin/ebuild-helpers/dodir index 90a3efe..e03ba9a 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dodir +++ b/portage_with_autodep/bin/ebuild-helpers/dodir @@ -1,13 +1,14 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi install -d ${DIROPTIONS} "${@/#/${ED}/}" ret=$? -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/dodoc b/portage_with_autodep/bin/ebuild-helpers/dodoc index 1f333a6..99122c4 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dodoc +++ b/portage_with_autodep/bin/ebuild-helpers/dodoc @@ -1,16 +1,24 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +if ___eapi_dodoc_supports_-r; then + exec \ + env \ + __PORTAGE_HELPER="dodoc" \ + doins "$@" +fi + if [ $# -lt 1 ] ; then - helpers_die "${0##*/}: at least one argument needed" - exit 1 + __helpers_die "${0##*/}: at least one argument needed" + exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi dir="${ED}usr/share/doc/${PF}/${_E_DOCDESTTREE_}" if [ ! -d "${dir}" ] ; then @@ -30,5 +38,5 @@ for x in "$@" ; do fi done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/doenvd b/portage_with_autodep/bin/ebuild-helpers/doenvd index 28ab5d2..9287933 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doenvd +++ b/portage_with_autodep/bin/ebuild-helpers/doenvd @@ -4,7 +4,7 @@ if [[ $# -lt 1 ]] ; then source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi diff --git a/portage_with_autodep/bin/ebuild-helpers/doexe b/portage_with_autodep/bin/ebuild-helpers/doexe index fb228f9..c34fcae 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doexe +++ b/portage_with_autodep/bin/ebuild-helpers/doexe @@ -1,23 +1,23 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ $# -lt 1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ ! -d ${ED}${_E_EXEDESTTREE_} ]] ; then install -d "${ED}${_E_EXEDESTTREE_}" fi -TMP=$T/.doexe_tmp -mkdir "$TMP" +TMP=$(mktemp -d "${T}/.doexe_tmp_XXXXXX") ret=0 @@ -26,7 +26,7 @@ for x in "$@" ; do cp "$x" "$TMP" mysrc=$TMP/${x##*/} elif [ -d "${x}" ] ; then - vecho "doexe: warning, skipping directory ${x}" + __vecho "doexe: warning, skipping directory ${x}" continue else mysrc="${x}" @@ -42,5 +42,5 @@ done rm -rf "$TMP" -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/dohard b/portage_with_autodep/bin/ebuild-helpers/dohard index b52fd7c..e0a44fa 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dohard +++ b/portage_with_autodep/bin/ebuild-helpers/dohard @@ -1,14 +1,22 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh + +if ! ___eapi_has_dohard; then + die "'${0##*/}' has been banned for EAPI '$EAPI'" + exit 1 +fi + if [[ $# -ne 2 ]] ; then echo "$0: two arguments needed" 1>&2 exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi destdir=${2%/*} [[ ! -d ${ED}${destdir} ]] && dodir "${destdir}" diff --git a/portage_with_autodep/bin/ebuild-helpers/dohtml b/portage_with_autodep/bin/ebuild-helpers/dohtml index 630629a..75d3d00 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dohtml +++ b/portage_with_autodep/bin/ebuild-helpers/dohtml @@ -1,14 +1,19 @@ #!/bin/bash -# Copyright 2009-2010 Gentoo Foundation +# Copyright 2009-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} -PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ +# Use safe cwd, avoiding unsafe import for bug #469338. +export __PORTAGE_HELPER_CWD=${PWD} +cd "${PORTAGE_PYM_PATH}" +PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/dohtml.py" "$@" ret=$? -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +# Restore cwd for display by __helpers_die +cd "${__PORTAGE_HELPER_CWD}" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/doinfo b/portage_with_autodep/bin/ebuild-helpers/doinfo index 8fd7d45..2edbdc5 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doinfo +++ b/portage_with_autodep/bin/ebuild-helpers/doinfo @@ -1,19 +1,20 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ -z $1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" - exit 1 + __helpers_die "${0##*/}: at least one argument needed" + exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ ! -d ${ED}usr/share/info ]] ; then - install -d "${ED}usr/share/info" || { helpers_die "${0##*/}: failed to install ${ED}usr/share/info"; exit 1; } + install -d "${ED}usr/share/info" || { __helpers_die "${0##*/}: failed to install ${ED}usr/share/info"; exit 1; } fi install -m0644 "$@" "${ED}usr/share/info" @@ -22,6 +23,6 @@ if [ $rval -ne 0 ] ; then for x in "$@" ; do [ -e "$x" ] || echo "!!! ${0##*/}: $x does not exist" 1>&2 done - helpers_die "${0##*/} failed" + __helpers_die "${0##*/} failed" fi exit $rval diff --git a/portage_with_autodep/bin/ebuild-helpers/doinitd b/portage_with_autodep/bin/ebuild-helpers/doinitd index b711e19..476b858 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doinitd +++ b/portage_with_autodep/bin/ebuild-helpers/doinitd @@ -4,7 +4,7 @@ if [[ $# -lt 1 ]] ; then source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi diff --git a/portage_with_autodep/bin/ebuild-helpers/doins b/portage_with_autodep/bin/ebuild-helpers/doins index 443bfdb..c60e057 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doins +++ b/portage_with_autodep/bin/ebuild-helpers/doins @@ -1,14 +1,17 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -if [[ ${0##*/} == dodoc ]] ; then +helper=${__PORTAGE_HELPER:-${0##*/}} + +if [[ ${helper} == dodoc ]] ; then if [ $# -eq 0 ] ; then # default_src_install may call dodoc with no arguments # when DOC is defined but empty, so simply return # sucessfully in this case. + eqawarn "QA Notice: dodoc called with no arguments" exit 0 fi export INSOPTIONS=-m0644 @@ -16,7 +19,7 @@ if [[ ${0##*/} == dodoc ]] ; then fi if [ $# -lt 1 ] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${helper}: at least one argument needed" exit 1 fi @@ -27,28 +30,26 @@ else DOINSRECUR=n fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) export ED="${D}" ;; esac +if ! ___eapi_has_prefix_variables; then + export ED="${D}" +fi if [[ ${INSDESTTREE#${ED}} != "${INSDESTTREE}" ]]; then - vecho "-------------------------------------------------------" 1>&2 - vecho "You should not use \${D} or \${ED} with helpers." 1>&2 - vecho " --> ${INSDESTTREE}" 1>&2 - vecho "-------------------------------------------------------" 1>&2 - helpers_die "${0##*/} used with \${D} or \${ED}" + __vecho "-------------------------------------------------------" 1>&2 + __vecho "You should not use \${D} or \${ED} with helpers." 1>&2 + __vecho " --> ${INSDESTTREE}" 1>&2 + __vecho "-------------------------------------------------------" 1>&2 + __helpers_die "${helper} used with \${D} or \${ED}" exit 1 fi -case "$EAPI" in - 0|1|2|3|3_pre2) - PRESERVE_SYMLINKS=n - ;; - *) - PRESERVE_SYMLINKS=y - ;; -esac +if ___eapi_doins_and_newins_preserve_symlinks; then + PRESERVE_SYMLINKS=y +else + PRESERVE_SYMLINKS=n +fi -export TMP=$T/.doins_tmp +export TMP=$(mktemp -d "${T}/.doins_tmp_XXXXXX") # Use separate directories to avoid potential name collisions. mkdir -p "$TMP"/{1,2} @@ -79,7 +80,7 @@ _doins() { install ${INSOPTIONS} "${mysrc}" "${ED}${INSDESTTREE}/${mydir}" rval=$? [[ -n ${cleanup} ]] && rm -f "${cleanup}" - [ $rval -ne 0 ] && echo "!!! ${0##*/}: $mysrc does not exist" 1>&2 + [ $rval -ne 0 ] && echo "!!! ${helper}: $mysrc does not exist" 1>&2 return $rval } @@ -99,8 +100,8 @@ for x in "$@" ; do if [[ $PRESERVE_SYMLINKS = n && -d $x ]] || \ [[ $PRESERVE_SYMLINKS = y && -d $x && ! -L $x ]] ; then if [ "${DOINSRECUR}" == "n" ] ; then - if [[ ${0##*/} == dodoc ]] ; then - echo "!!! ${0##*/}: $x is a directory" 1>&2 + if [[ ${helper} == dodoc ]] ; then + echo "!!! ${helper}: $x is a directory" 1>&2 ((failed|=1)) fi continue @@ -155,4 +156,4 @@ for x in "$@" ; do fi done rm -rf "$TMP" -[[ $failed -ne 0 || $success -eq 0 ]] && { helpers_die "${0##*/} failed"; exit 1; } || exit 0 +[[ $failed -ne 0 || $success -eq 0 ]] && { __helpers_die "${helper} failed"; exit 1; } || exit 0 diff --git a/portage_with_autodep/bin/ebuild-helpers/dolib b/portage_with_autodep/bin/ebuild-helpers/dolib index 9af5418..fd92d7f 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dolib +++ b/portage_with_autodep/bin/ebuild-helpers/dolib @@ -1,11 +1,12 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi # Setup ABI cruft LIBDIR_VAR="LIBDIR_${ABI}" @@ -19,11 +20,11 @@ libdir="${ED}${DESTTREE}/${CONF_LIBDIR}" if [[ $# -lt 1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi if [[ ! -d ${libdir} ]] ; then - install -d "${libdir}" || { helpers_die "${0##*/}: failed to install ${libdir}"; exit 1; } + install -d "${libdir}" || { __helpers_die "${0##*/}: failed to install ${libdir}"; exit 1; } fi ret=0 @@ -42,5 +43,5 @@ for x in "$@" ; do ((ret|=$?)) done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/doman b/portage_with_autodep/bin/ebuild-helpers/doman index b4047ce..d680859 100755 --- a/portage_with_autodep/bin/ebuild-helpers/doman +++ b/portage_with_autodep/bin/ebuild-helpers/doman @@ -1,16 +1,17 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ $# -lt 1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi i18n="" @@ -58,10 +59,10 @@ for x in "$@" ; do ((ret|=1)) fi else - vecho "doman: '${x}' is probably not a man page; skipping" 1>&2 + __vecho "doman: '${x}' is probably not a man page; skipping" 1>&2 ((ret|=1)) fi done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/domo b/portage_with_autodep/bin/ebuild-helpers/domo index d994343..9a8dda3 100755 --- a/portage_with_autodep/bin/ebuild-helpers/domo +++ b/portage_with_autodep/bin/ebuild-helpers/domo @@ -1,17 +1,18 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh mynum=${#} if [ ${mynum} -lt 1 ] ; then - helpers_die "${0}: at least one argument needed" + __helpers_die "${0}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [ ! -d "${ED}${DESTTREE}/share/locale" ] ; then install -d "${ED}${DESTTREE}/share/locale/" @@ -34,5 +35,5 @@ for x in "$@" ; do ((ret|=$?)) done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/dosbin b/portage_with_autodep/bin/ebuild-helpers/dosbin index d101c8a..361ca83 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dosbin +++ b/portage_with_autodep/bin/ebuild-helpers/dosbin @@ -1,19 +1,20 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ $# -lt 1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ ! -d ${ED}${DESTTREE}/sbin ]] ; then - install -d "${ED}${DESTTREE}/sbin" || { helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/sbin"; exit 2; } + install -d "${ED}${DESTTREE}/sbin" || { __helpers_die "${0##*/}: failed to install ${ED}${DESTTREE}/sbin"; exit 2; } fi ret=0 @@ -28,5 +29,5 @@ for x in "$@" ; do ((ret|=$?)) done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/dosed b/portage_with_autodep/bin/ebuild-helpers/dosed index f202df7..7db0629 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dosed +++ b/portage_with_autodep/bin/ebuild-helpers/dosed @@ -1,14 +1,22 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh + +if ! ___eapi_has_dosed; then + die "'${0##*/}' has been banned for EAPI '$EAPI'" + exit 1 +fi + if [[ $# -lt 1 ]] ; then echo "!!! ${0##*/}: at least one argument needed" >&2 exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi ret=0 file_found=0 diff --git a/portage_with_autodep/bin/ebuild-helpers/dosym b/portage_with_autodep/bin/ebuild-helpers/dosym index 2489e22..649b100 100755 --- a/portage_with_autodep/bin/ebuild-helpers/dosym +++ b/portage_with_autodep/bin/ebuild-helpers/dosym @@ -5,12 +5,13 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ $# -ne 2 ]] ; then - helpers_die "${0##*/}: two arguments needed" + __helpers_die "${0##*/}: two arguments needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ ${2} == */ ]] || \ [[ -d ${ED}${2} && ! -L ${ED}${2} ]] ; then @@ -26,5 +27,5 @@ target="${1}" ln -snf "${target}" "${ED}${2}" ret=$? -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/ecompress b/portage_with_autodep/bin/ebuild-helpers/ecompress index b61421b..71287b4 100755 --- a/portage_with_autodep/bin/ebuild-helpers/ecompress +++ b/portage_with_autodep/bin/ebuild-helpers/ecompress @@ -5,7 +5,7 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh if [[ -z $1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi @@ -68,7 +68,7 @@ decompress_args() { case $1 in --suffix) - [[ -n $2 ]] && vecho "${0##*/}: --suffix takes no additional arguments" 1>&2 + [[ -n $2 ]] && __vecho "${0##*/}: --suffix takes no additional arguments" 1>&2 if [[ ! -e ${T}/.ecompress.suffix ]] ; then set -e @@ -93,7 +93,7 @@ case $1 in cat "${T}/.ecompress.suffix" ;; --bin) - [[ -n $2 ]] && vecho "${0##*/}: --bin takes no additional arguments" 1>&2 + [[ -n $2 ]] && __vecho "${0##*/}: --bin takes no additional arguments" 1>&2 echo "${PORTAGE_COMPRESS} ${PORTAGE_COMPRESS_FLAGS}" ;; @@ -104,18 +104,18 @@ case $1 in >> "$x" ((ret|=$?)) done - [[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" + [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret ;; --dequeue) - [[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2 + [[ -n $2 ]] && __vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2 find "${D}" -name '*.ecompress.file' -print0 \ | sed -e 's:\.ecompress\.file::g' \ | ${XARGS} -0 ecompress find "${D}" -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f ;; --*) - helpers_die "${0##*/}: unknown arguments '$*'" + __helpers_die "${0##*/}: unknown arguments '$*'" exit 1 ;; *) @@ -155,7 +155,7 @@ case $1 in # Finally, let's actually do some real work "${PORTAGE_COMPRESS}" ${PORTAGE_COMPRESS_FLAGS} "$@" ret=$? - [[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" + [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret ;; esac diff --git a/portage_with_autodep/bin/ebuild-helpers/ecompressdir b/portage_with_autodep/bin/ebuild-helpers/ecompressdir index a2c9e52..eca5888 100755 --- a/portage_with_autodep/bin/ebuild-helpers/ecompressdir +++ b/portage_with_autodep/bin/ebuild-helpers/ecompressdir @@ -1,18 +1,21 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/helper-functions.sh if [[ -z $1 ]] ; then - helpers_die "${0##*/}: at least one argument needed" + __helpers_die "${0##*/}: at least one argument needed" exit 1 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} EPREFIX= ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} EPREFIX= +fi -case $1 in +SIZE_LIMIT='' +while [[ $# -gt 0 ]] ; do + case $1 in --ignore) shift for skip in "$@" ; do @@ -27,45 +30,66 @@ case $1 in set -- "${@/#/${ED}}" ret=0 for x in "$@" ; do - >> "$x" + # Stash the limit in the .dir file so we can reload it later. + printf "${SIZE_LIMIT}" > "${x}" ((ret|=$?)) done - [[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" + [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret ;; --dequeue) - [[ -n $2 ]] && vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2 + [[ -n $2 ]] && __vecho "${0##*/}: --dequeue takes no additional arguments" 1>&2 find "${ED}" -name '*.ecompress.dir' -print0 \ | sed -e 's:\.ecompress\.dir::g' -e "s:${ED}:/:g" \ | ${XARGS} -0 ecompressdir find "${ED}" -name '*.ecompress.skip' -print0 | ${XARGS} -0 rm -f exit 0 ;; + --limit) + SIZE_LIMIT=$2 + shift + ;; --*) - helpers_die "${0##*/}: unknown arguments '$*'" + __helpers_die "${0##*/}: unknown arguments '$*'" exit 1 ;; -esac + *) + break + ;; + esac + shift +done # figure out the new suffix suffix=$(ecompress --suffix) -# funk_up_dir(action, suffix, binary) +# funk_up_dir(action, suffix, binary, [size_limit]) # - action: compress or decompress # - suffix: the compression suffix to work with # - binary: the program to execute that'll compress/decompress +# - size_limit: if compressing, skip files smaller than this # The directory we act on is implied in the ${dir} variable funk_up_dir() { - local act=$1 suffix=$2 binary=$3 + local act=$1 suffix=$2 binary=$3 size_limit=$4 local negate="" [[ ${act} == "compress" ]] && negate="!" + local ret=0 # first we act on all the files - find "${dir}" -type f ${negate} -iname '*'${suffix} -print0 | ${XARGS} -0 ${binary} + local args=( + -type f + ${negate} -iname "*${suffix}" + ) + [[ -n ${size_limit} ]] && args+=( -size "+${size_limit}c" ) + find "${dir}" "${args[@]}" -print0 | ${XARGS} -0 ${binary} ((ret|=$?)) - find "${dir}" -type l -print0 | \ + # Repeat until nothing changes, in order to handle multiple + # levels of indirection (see bug #470916). + local -i indirection=0 + while true ; do + local something_changed= while read -r -d $'\0' brokenlink ; do [[ -e ${brokenlink} ]] && continue olddest=$(readlink "${brokenlink}") @@ -80,15 +104,34 @@ funk_up_dir() { skip_dir_dest=${T}/ecompress-skip/${actual_dir#${ED}}/${brokenlink%/*}/${olddest} fi [[ -e ${skip_dir_dest} ]] && continue - [[ ${act} == "compress" ]] \ - && newdest="${olddest}${suffix}" \ - || newdest="${olddest%${suffix}}" + if [[ ${act} == "compress" ]] ; then + newdest=${olddest}${suffix} + else + [[ ${olddest} == *${suffix} ]] || continue + newdest=${olddest%${suffix}} + fi + if [[ "${newdest}" == /* ]] ; then + [[ -f "${D}${newdest}" ]] || continue + else + [[ -f "${dir}/${brokenlink%/*}/${newdest}" ]] || continue + fi + something_changed=${brokenlink} rm -f "${brokenlink}" [[ ${act} == "compress" ]] \ && ln -snf "${newdest}" "${brokenlink}${suffix}" \ || ln -snf "${newdest}" "${brokenlink%${suffix}}" ((ret|=$?)) + done < <(find "${dir}" -type l -print0) + [[ -n ${something_changed} ]] || break + (( indirection++ )) + if (( indirection >= 100 )) ; then + # Protect against possibility of a bug triggering an endless loop. + eerror "ecompressdir: too many levels of indirection for" \ + "'${actual_dir#${ED}}/${something_changed#./}'" + break + fi done + return ${ret} } # _relocate_skip_dirs(srctree, dsttree) @@ -124,13 +167,13 @@ decompressors=( ".lzma" "unxz -f" ) -multijob_init +__multijob_init for dir in "$@" ; do dir=${dir#/} dir="${ED}${dir}" if [[ ! -d ${dir} ]] ; then - vecho "${0##*/}: /${dir#${ED}} does not exist!" + __vecho "${0##*/}: /${dir#${ED}} does not exist!" continue fi cd "${dir}" @@ -142,39 +185,41 @@ for dir in "$@" ; do # since we've been requested to compress the whole dir, # delete any individual queued requests + size_limit=${SIZE_LIMIT:-$(<"${actual_dir}.ecompress.dir")} rm -f "${actual_dir}.ecompress.dir" find "${dir}" -type f -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f # not uncommon for packages to compress doc files themselves - for (( d = 0; d < ${#decompressors[@]}; d += 2 )) ; do + for (( i = 0; i < ${#decompressors[@]}; i += 2 )) ; do # It's faster to parallelize at this stage than to try to # parallelize the compressors. This is because the find|xargs # ends up launching less compressors overall, so the overhead # of forking children ends up dominating. ( - multijob_child_init + __multijob_child_init funk_up_dir "decompress" "${decompressors[i]}" "${decompressors[i+1]}" ) & - multijob_post_fork + __multijob_post_fork : $(( ret |= $? )) done + __multijob_finish + : $(( ret |= $? )) + # forcibly break all hard links as some compressors whine about it find "${dir}" -type f -links +1 -exec env file="{}" sh -c \ 'cp -p "${file}" "${file}.ecompress.break" ; mv -f "${file}.ecompress.break" "${file}"' \; - multijob_finish - : $(( ret |= $? )) - # now lets do our work if [[ -n ${suffix} ]] ; then - vecho "${0##*/}: $(ecompress --bin) /${actual_dir#${ED}}" - funk_up_dir "compress" "${suffix}" "ecompress" + __vecho "${0##*/}: $(ecompress --bin) /${actual_dir#${ED}}" + funk_up_dir "compress" "${suffix}" "ecompress" "${size_limit}" + : $(( ret |= $? )) fi # finally, restore the skipped stuff restore_skip_dirs done -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/emake b/portage_with_autodep/bin/ebuild-helpers/emake index d842781..69d836f 100755 --- a/portage_with_autodep/bin/ebuild-helpers/emake +++ b/portage_with_autodep/bin/ebuild-helpers/emake @@ -24,5 +24,5 @@ fi ${MAKE:-make} ${MAKEOPTS} ${EXTRA_EMAKE} "$@" ret=$? -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/fowners b/portage_with_autodep/bin/ebuild-helpers/fowners index a213c9e..cee4108 100755 --- a/portage_with_autodep/bin/ebuild-helpers/fowners +++ b/portage_with_autodep/bin/ebuild-helpers/fowners @@ -4,8 +4,9 @@ source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) EPREFIX= ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + EPREFIX= ED=${D} +fi # we can't prefix all arguments because # chown takes random options @@ -13,10 +14,5 @@ slash="/" chown "${@/#${slash}/${ED}${slash}}" ret=$? -if [[ ${ret} != 0 && -n ${EPREFIX} && ${EUID} != 0 ]] ; then - ewarn "fowners failure ignored in Prefix with non-privileged user" - exit 0 -fi - -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/fperms b/portage_with_autodep/bin/ebuild-helpers/fperms index a2f77ea..d854ebb 100755 --- a/portage_with_autodep/bin/ebuild-helpers/fperms +++ b/portage_with_autodep/bin/ebuild-helpers/fperms @@ -1,16 +1,17 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi # we can't prefix all arguments because # chmod takes random options slash="/" chmod "${@/#${slash}/${ED}${slash}}" ret=$? -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/newbin b/portage_with_autodep/bin/ebuild-helpers/newbin index bf98744..59a0db2 100755..120000 --- a/portage_with_autodep/bin/ebuild-helpers/newbin +++ b/portage_with_autodep/bin/ebuild-helpers/newbin @@ -1,22 +1 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec dobin "${T}/${2}" +newins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newconfd b/portage_with_autodep/bin/ebuild-helpers/newconfd index fa3710d..59a0db2 100755..120000 --- a/portage_with_autodep/bin/ebuild-helpers/newconfd +++ b/portage_with_autodep/bin/ebuild-helpers/newconfd @@ -1,22 +1 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec doconfd "${T}/${2}" +newins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newdoc b/portage_with_autodep/bin/ebuild-helpers/newdoc index df6fb1d..59a0db2 100755..120000 --- a/portage_with_autodep/bin/ebuild-helpers/newdoc +++ b/portage_with_autodep/bin/ebuild-helpers/newdoc @@ -1,22 +1 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec dodoc "${T}/${2}" +newins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newenvd b/portage_with_autodep/bin/ebuild-helpers/newenvd index c54af05..59a0db2 100755..120000 --- a/portage_with_autodep/bin/ebuild-helpers/newenvd +++ b/portage_with_autodep/bin/ebuild-helpers/newenvd @@ -1,22 +1 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec doenvd "${T}/${2}" +newins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newexe b/portage_with_autodep/bin/ebuild-helpers/newexe index 9bcf64b..59a0db2 100755..120000 --- a/portage_with_autodep/bin/ebuild-helpers/newexe +++ b/portage_with_autodep/bin/ebuild-helpers/newexe @@ -1,22 +1 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec doexe "${T}/${2}" +newins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newinitd b/portage_with_autodep/bin/ebuild-helpers/newinitd index 03bbe68..59a0db2 100755..120000 --- a/portage_with_autodep/bin/ebuild-helpers/newinitd +++ b/portage_with_autodep/bin/ebuild-helpers/newinitd @@ -1,22 +1 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec doinitd "${T}/${2}" +newins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newins b/portage_with_autodep/bin/ebuild-helpers/newins index adf2d80..0335985 100755 --- a/portage_with_autodep/bin/ebuild-helpers/newins +++ b/portage_with_autodep/bin/ebuild-helpers/newins @@ -1,38 +1,57 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +helper=${0##*/} + if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" + __helpers_die "${helper}: Need two arguments, old file and new file" exit 1 fi -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 +(($#>2)) && \ + eqawarn "QA Notice: ${helper} called with more than 2 arguments: ${@:3}" + +stdin= +if ___eapi_newins_supports_reading_from_standard_input && [[ $1 == "-" ]]; then + stdin=yes fi -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" || exit $? -case "$EAPI" in - 0|1|2|3|3_pre2) - cp "$1" "$T/$2" || exit $? - ;; - *) - cp -P "$1" "$T/$2" - ret=$? - if [[ $ret -ne 0 ]] ; then - helpers_die "${0##*/} failed" - exit $ret +TMP=$(mktemp -d "${T}/.newins_tmp_XXXXXX") +trap 'rm -rf "${TMP}"' EXIT + +if [[ ${stdin} ]] ; then + if [[ -t 0 ]] ; then + __helpers_die "!!! ${helper}: Input is from a terminal" + exit 1 + fi + cat > "${TMP}/$2" + ret=$? +else + if [[ ! -e $1 ]] ; then + __helpers_die "!!! ${helper}: $1 does not exist" + exit 1 + fi + + cp_args="-f" + if [[ ${helper} == newins ]] ; then + if ___eapi_doins_and_newins_preserve_symlinks; then + cp_args+=" -P" fi - ;; -esac -doins "${T}/${2}" + fi + + cp ${cp_args} "$1" "${TMP}/$2" + ret=$? +fi + +if [[ ${ret} -ne 0 ]] ; then + __helpers_die "${0##*/} failed" + exit ${ret} +fi + +do${helper#new} "${TMP}/$2" ret=$? -rm -rf "${T}/${2}" -[[ $ret -ne 0 ]] && helpers_die "${0##*/} failed" +[[ $ret -ne 0 ]] && __helpers_die "${helper} failed" exit $ret diff --git a/portage_with_autodep/bin/ebuild-helpers/newlib.a b/portage_with_autodep/bin/ebuild-helpers/newlib.a index 7ff8195..59a0db2 100755..120000 --- a/portage_with_autodep/bin/ebuild-helpers/newlib.a +++ b/portage_with_autodep/bin/ebuild-helpers/newlib.a @@ -1,22 +1 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec dolib.a "${T}/${2}" +newins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newlib.so b/portage_with_autodep/bin/ebuild-helpers/newlib.so index fd4c097..59a0db2 100755..120000 --- a/portage_with_autodep/bin/ebuild-helpers/newlib.so +++ b/portage_with_autodep/bin/ebuild-helpers/newlib.so @@ -1,22 +1 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec dolib.so "${T}/${2}" +newins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newman b/portage_with_autodep/bin/ebuild-helpers/newman index 889e0f9..59a0db2 100755..120000 --- a/portage_with_autodep/bin/ebuild-helpers/newman +++ b/portage_with_autodep/bin/ebuild-helpers/newman @@ -1,22 +1 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec doman "${T}/${2}" +newins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/newsbin b/portage_with_autodep/bin/ebuild-helpers/newsbin index 9df0af2..59a0db2 100755..120000 --- a/portage_with_autodep/bin/ebuild-helpers/newsbin +++ b/portage_with_autodep/bin/ebuild-helpers/newsbin @@ -1,22 +1 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -if [[ -z ${T} ]] || [[ -z ${2} ]] ; then - helpers_die "${0##*/}: Need two arguments, old file and new file" - exit 1 -fi - -if [ ! -e "$1" ] ; then - helpers_die "!!! ${0##*/}: $1 does not exist" - exit 1 -fi - -(($#>2)) && \ - eqawarn "QA Notice: ${0##*/} called with more than 2 arguments: ${@:3}" - -rm -rf "${T}/${2}" && \ -cp -f "${1}" "${T}/${2}" && \ -exec dosbin "${T}/${2}" +newins
\ No newline at end of file diff --git a/portage_with_autodep/bin/ebuild-helpers/portageq b/portage_with_autodep/bin/ebuild-helpers/portageq index ec30b66..b67b03f 100755 --- a/portage_with_autodep/bin/ebuild-helpers/portageq +++ b/portage_with_autodep/bin/ebuild-helpers/portageq @@ -1,8 +1,10 @@ #!/bin/bash -# Copyright 2009-2010 Gentoo Foundation +# Copyright 2009-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} -PYTHONPATH=$PORTAGE_PYM_PATH${PYTHONPATH:+:}$PYTHONPATH \ +# Use safe cwd, avoiding unsafe import for bug #469338. +cd "${PORTAGE_PYM_PATH}" +PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ exec "${PORTAGE_PYTHON:-/usr/bin/python}" "$PORTAGE_BIN_PATH/portageq" "$@" diff --git a/portage_with_autodep/bin/ebuild-helpers/prepall b/portage_with_autodep/bin/ebuild-helpers/prepall index 49e646c..fb5c2db 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepall +++ b/portage_with_autodep/bin/ebuild-helpers/prepall @@ -1,11 +1,12 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if has chflags $FEATURES ; then # Save all the file flags for restoration at the end of prepall. diff --git a/portage_with_autodep/bin/ebuild-helpers/prepalldocs b/portage_with_autodep/bin/ebuild-helpers/prepalldocs index 560a02b..3094661 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepalldocs +++ b/portage_with_autodep/bin/ebuild-helpers/prepalldocs @@ -1,15 +1,21 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh +if ___eapi_has_docompress; then + die "'${0##*/}' has been banned for EAPI '$EAPI'" + exit 1 +fi + if [[ -n $1 ]] ; then - vecho "${0##*/}: invalid usage; takes no arguments" 1>&2 + __vecho "${0##*/}: invalid usage; takes no arguments" 1>&2 fi -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi [[ -d ${ED}usr/share/doc ]] || exit 0 diff --git a/portage_with_autodep/bin/ebuild-helpers/prepallinfo b/portage_with_autodep/bin/ebuild-helpers/prepallinfo index db9bbfa..1a20275 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepallinfo +++ b/portage_with_autodep/bin/ebuild-helpers/prepallinfo @@ -1,11 +1,12 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi [[ -d ${ED}usr/share/info ]] || exit 0 diff --git a/portage_with_autodep/bin/ebuild-helpers/prepallman b/portage_with_autodep/bin/ebuild-helpers/prepallman index dee1c72..5331eaf 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepallman +++ b/portage_with_autodep/bin/ebuild-helpers/prepallman @@ -1,22 +1,22 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh # replaced by controllable compression in EAPI 4 -has "${EAPI}" 0 1 2 3 || exit 0 +___eapi_has_docompress && exit 0 -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi ret=0 -find "${ED}" -type d -name man > "${T}"/prepallman.filelist -while read -r mandir ; do +while IFS= read -r -d '' mandir ; do mandir=${mandir#${ED}} prepman "${mandir%/man}" ((ret|=$?)) -done < "${T}"/prepallman.filelist +done < <(find "${ED}" -type d -name man -print0) exit ${ret} diff --git a/portage_with_autodep/bin/ebuild-helpers/prepallstrip b/portage_with_autodep/bin/ebuild-helpers/prepallstrip index 28320d9..1aa6686 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepallstrip +++ b/portage_with_autodep/bin/ebuild-helpers/prepallstrip @@ -1,8 +1,11 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh + +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi exec prepstrip "${ED}" diff --git a/portage_with_autodep/bin/ebuild-helpers/prepinfo b/portage_with_autodep/bin/ebuild-helpers/prepinfo index ffe2ece..5afc18a 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepinfo +++ b/portage_with_autodep/bin/ebuild-helpers/prepinfo @@ -1,11 +1,12 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi if [[ -z $1 ]] ; then infodir="/usr/share/info" @@ -19,7 +20,7 @@ fi if [[ ! -d ${ED}${infodir} ]] ; then if [[ -n $1 ]] ; then - vecho "${0##*/}: '${infodir}' does not exist!" + __vecho "${0##*/}: '${infodir}' does not exist!" exit 1 else exit 0 @@ -33,5 +34,5 @@ find "${ED}${infodir}" -type d -print0 | while read -r -d $'\0' x ; do rm -f "${x}"/dir{,.info}{,.gz,.bz2} done -has "${EAPI}" 0 1 2 3 || exit 0 +___eapi_has_docompress && exit 0 exec ecompressdir --queue "${infodir}" diff --git a/portage_with_autodep/bin/ebuild-helpers/preplib b/portage_with_autodep/bin/ebuild-helpers/preplib deleted file mode 100755 index 6e91cf3..0000000 --- a/portage_with_autodep/bin/ebuild-helpers/preplib +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# Copyright 1999-2011 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 - -source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh - -eqawarn "QA Notice: Deprecated call to 'preplib'" - -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac - -LIBDIR_VAR="LIBDIR_${ABI}" -if [ -n "${ABI}" -a -n "${!LIBDIR_VAR}" ]; then - CONF_LIBDIR="${!LIBDIR_VAR}" -fi -unset LIBDIR_VAR - -if [ -z "${CONF_LIBDIR}" ]; then - # we need this to default to lib so that things dont break - CONF_LIBDIR="lib" -fi - -if [ -z "$1" ] ; then - z="${ED}usr/${CONF_LIBDIR}" -else - z="${ED}$1/${CONF_LIBDIR}" -fi - -if [ -d "${z}" ] ; then - ldconfig -n -N "${z}" -fi diff --git a/portage_with_autodep/bin/ebuild-helpers/prepman b/portage_with_autodep/bin/ebuild-helpers/prepman index f96b641..fb5dcb4 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepman +++ b/portage_with_autodep/bin/ebuild-helpers/prepman @@ -1,13 +1,17 @@ #!/bin/bash -# Copyright 1999-2011 Gentoo Foundation +# Copyright 1999-2012 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +# Do not compress man pages which are smaller than this (in bytes). #169260 +SIZE_LIMIT='128' + source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "$EAPI" in 0|1|2) ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + ED=${D} +fi -if [[ -z $1 ]] ; then +if [[ -z $1 ]] ; then mandir="${ED}usr/share/man" else mandir="${ED}$1/man" @@ -19,7 +23,7 @@ if [[ ! -d ${mandir} ]] ; then fi # replaced by controllable compression in EAPI 4 -has "${EAPI}" 0 1 2 3 || exit 0 +___eapi_has_docompress && exit 0 shopt -s nullglob @@ -30,6 +34,6 @@ for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do [[ -d ${subdir} ]] && really_is_mandir=1 && break done -[[ ${really_is_mandir} == 1 ]] && exec ecompressdir --queue "${mandir#${ED}}" +[[ ${really_is_mandir} == 1 ]] && exec ecompressdir --limit ${SIZE_LIMIT} --queue "${mandir#${ED}}" exit 0 diff --git a/portage_with_autodep/bin/ebuild-helpers/prepstrip b/portage_with_autodep/bin/ebuild-helpers/prepstrip index 85d5d6a..2332388 100755 --- a/portage_with_autodep/bin/ebuild-helpers/prepstrip +++ b/portage_with_autodep/bin/ebuild-helpers/prepstrip @@ -1,7 +1,8 @@ #!/bin/bash -# Copyright 1999-2012 Gentoo Foundation +# Copyright 1999-2013 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 +PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/helper-functions.sh # avoid multiple calls to `has`. this creates things like: @@ -15,11 +16,12 @@ exp_tf() { eval ${var}_${flag}=$(tf has ${flag} ${!var}) done } -exp_tf FEATURES compressdebug installsources nostrip splitdebug -exp_tf RESTRICT binchecks installsources strip +exp_tf FEATURES compressdebug installsources nostrip splitdebug xattr +exp_tf RESTRICT binchecks installsources splitdebug strip -[[ " ${FEATURES} " == *" force-prefix "* ]] || \ - case "${EAPI}" in 0|1|2) EPREFIX= ED=${D} ;; esac +if ! ___eapi_has_prefix_variables; then + EPREFIX= ED=${D} +fi banner=false SKIP_STRIP=false @@ -29,6 +31,30 @@ if ${RESTRICT_strip} || ${FEATURES_nostrip} ; then ${FEATURES_installsources} || exit 0 fi +PRESERVE_XATTR=false +if [[ ${KERNEL} == linux ]] && ${FEATURES_xattr} ; then + PRESERVE_XATTR=true + if type -P getfattr >/dev/null && type -P setfattr >/dev/null ; then + dump_xattrs() { + getfattr -d --absolute-names "$1" + } + restore_xattrs() { + setfattr --restore=- + } + else + dump_xattrs() { + PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ + "${PORTAGE_PYTHON:-/usr/bin/python}" \ + "${PORTAGE_BIN_PATH}/xattr-helper.py" --dump < <(echo -n "$1") + } + restore_xattrs() { + PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ + "${PORTAGE_PYTHON:-/usr/bin/python}" \ + "${PORTAGE_BIN_PATH}/xattr-helper.py" --restore + } + fi +fi + # look up the tools we might be using for t in STRIP:strip OBJCOPY:objcopy READELF:readelf ; do v=${t%:*} # STRIP @@ -51,7 +77,7 @@ case $(${STRIP} --version 2>/dev/null) in # We'll leave out -R .note for now until we can check out the relevance # of the section when it has the ALLOC flag set on it ... SAFE_STRIP_FLAGS="--strip-unneeded" - DEF_STRIP_FLAGS="-R .comment -R .GCC.command.line" + DEF_STRIP_FLAGS="-R .comment -R .GCC.command.line -R .note.gnu.gold-version" SPLIT_STRIP_FLAGS= ;; esac @@ -62,23 +88,13 @@ prepstrip_sources_dir=${EPREFIX}/usr/src/debug/${CATEGORY}/${PF} type -P debugedit >/dev/null && debugedit_found=true || debugedit_found=false debugedit_warned=false -multijob_init +__multijob_init # Setup $T filesystem layout that we care about. tmpdir="${T}/prepstrip" rm -rf "${tmpdir}" mkdir -p "${tmpdir}"/{inodes,splitdebug,sources} -# Usage: inode_var_name: <file> -inode_file_link() { - echo -n "${tmpdir}/inodes/" - if [[ ${USERLAND} == "BSD" ]] ; then - stat -f '%i' "$1" - else - stat -c '%i' "$1" - fi -} - # Usage: save_elf_sources <elf> save_elf_sources() { ${FEATURES_installsources} || return 0 @@ -93,7 +109,6 @@ save_elf_sources() { fi local x=$1 - [[ -f $(inode_file_link "${x}") ]] && return 0 # since we're editing the ELF here, we should recompute the build-id # (the -i flag below). save that output so we don't need to recompute @@ -101,20 +116,22 @@ save_elf_sources() { buildid=$(debugedit -i \ -b "${WORKDIR}" \ -d "${prepstrip_sources_dir}" \ - -l "${tmpdir}/sources/${x##*/}.${BASHPID}" \ + -l "${tmpdir}/sources/${x##*/}.${BASHPID:-$(__bashpid)}" \ "${x}") } # Usage: save_elf_debug <elf> [splitdebug file] save_elf_debug() { ${FEATURES_splitdebug} || return 0 + ${RESTRICT_splitdebug} && return 0 # NOTE: Debug files must be installed in # ${EPREFIX}/usr/lib/debug/${EPREFIX} (note that ${EPREFIX} occurs # twice in this path) in order for gdb's debug-file-directory # lookup to work correctly. local x=$1 - local splitdebug=$2 + local inode_debug=$2 + local splitdebug=$3 local y=${ED}usr/lib/debug/${x:${#D}}.debug # dont save debug info twice @@ -122,9 +139,8 @@ save_elf_debug() { mkdir -p "${y%/*}" - local inode=$(inode_file_link "${x}") - if [[ -f ${inode} ]] ; then - ln "${inode}" "${y}" + if [ -f "${inode_debug}" ] ; then + ln "${inode_debug}" "${y}" || die "ln failed unexpectedly" else if [[ -n ${splitdebug} ]] ; then mv "${splitdebug}" "${y}" @@ -134,64 +150,89 @@ save_elf_debug() { ${OBJCOPY} ${objcopy_flags} "${x}" "${y}" ${OBJCOPY} --add-gnu-debuglink="${y}" "${x}" fi - local args="a-x,o-w" - [[ -g ${x} || -u ${x} ]] && args+=",go-r" - chmod ${args} "${y}" - ln "${y}" "${inode}" + # Only do the following if the debug file was + # successfully created (see bug #446774). + if [ $? -eq 0 ] ; then + local args="a-x,o-w" + [[ -g ${x} || -u ${x} ]] && args+=",go-r" + chmod ${args} "${y}" + ln "${y}" "${inode_debug}" || die "ln failed unexpectedly" + fi fi # if we don't already have build-id from debugedit, look it up if [[ -z ${buildid} ]] ; then # convert the readelf output to something useful - buildid=$(${READELF} -x .note.gnu.build-id "${x}" 2>/dev/null \ - | awk '$NF ~ /GNU/ { getline; printf $2$3$4$5; getline; print $2 }') + buildid=$(${READELF} -n "${x}" 2>/dev/null | awk '/Build ID:/{ print $NF; exit }') fi if [[ -n ${buildid} ]] ; then local buildid_dir="${ED}usr/lib/debug/.build-id/${buildid:0:2}" local buildid_file="${buildid_dir}/${buildid:2}" mkdir -p "${buildid_dir}" - ln -s "../../${x:${#D}}.debug" "${buildid_file}.debug" - ln -s "/${x:${#D}}" "${buildid_file}" + [ -L "${buildid_file}".debug ] || ln -s "../../${x:${#D}}.debug" "${buildid_file}.debug" + [ -L "${buildid_file}" ] || ln -s "/${x:${#D}}" "${buildid_file}" fi } # Usage: process_elf <elf> process_elf() { - local x=$1 strip_flags=${*:2} - - vecho " ${x:${#ED}}" - save_elf_sources "${x}" + local x=$1 inode_link=$2 strip_flags=${*:3} + local already_stripped lockfile xt_data + + __vecho " ${x:${#ED}}" + + # If two processes try to debugedit or strip the same hardlink at the + # same time, it may corrupt files or cause loss of splitdebug info. + # So, use a lockfile to prevent interference (easily observed with + # dev-vcs/git which creates ~111 hardlinks to one file in + # /usr/libexec/git-core). + lockfile=${inode_link}_lockfile + if ! ln "${inode_link}" "${lockfile}" 2>/dev/null ; then + while [[ -f ${lockfile} ]] ; do + sleep 1 + done + unset lockfile + fi - if ${strip_this} ; then + [ -f "${inode_link}_stripped" ] && already_stripped=true || already_stripped=false - # If two processes try to strip the same hardlink at the same - # time, it will cause one of them to lose the splitdebug info. - # So, use a lockfile to prevent interference (easily observed - # with dev-vcs/git which creates ~109 hardlinks to one file in - # /usr/libexec/git-core). - local lockfile=$(inode_file_link "${x}")_lockfile - if ! ln "${x}" "${lockfile}" ; then - while [[ -f ${lockfile} ]] ; do - sleep 1 - done - unset lockfile + if ! ${already_stripped} ; then + if ${PRESERVE_XATTR} ; then + xt_data=$(dump_xattrs "${x}") fi + save_elf_sources "${x}" + fi + + if ${strip_this} ; then # see if we can split & strip at the same time if [[ -n ${SPLIT_STRIP_FLAGS} ]] ; then local shortname="${x##*/}.debug" - local splitdebug="${tmpdir}/splitdebug/${shortname}.${BASHPID}" + local splitdebug="${tmpdir}/splitdebug/${shortname}.${BASHPID:-$(__bashpid)}" + ${already_stripped} || \ ${STRIP} ${strip_flags} \ -f "${splitdebug}" \ -F "${shortname}" \ "${x}" - save_elf_debug "${x}" "${splitdebug}" + save_elf_debug "${x}" "${inode_link}_debug" "${splitdebug}" else - save_elf_debug "${x}" + save_elf_debug "${x}" "${inode_link}_debug" + ${already_stripped} || \ ${STRIP} ${strip_flags} "${x}" fi - [[ -n ${lockfile} ]] && rm -f "${lockfile}" fi + + if ${already_stripped} ; then + rm -f "${x}" || die "rm failed unexpectedly" + ln "${inode_link}_stripped" "${x}" || die "ln failed unexpectedly" + else + ln "${x}" "${inode_link}_stripped" || die "ln failed unexpectedly" + if [[ ${xt_data} ]] ; then + restore_xattrs <<< "${xt_data}" + fi + fi + + [[ -n ${lockfile} ]] && rm -f "${lockfile}" } # The existance of the section .symtab tells us that a binary is stripped. @@ -204,7 +245,7 @@ if ! ${RESTRICT_binchecks} && ! ${RESTRICT_strip} ; then log=${tmpdir}/scanelf-already-stripped.log scanelf -yqRBF '#k%F' -k '!.symtab' "$@" | sed -e "s#^${ED}##" > "${log}" ( - multijob_child_init + __multijob_child_init qa_var="QA_PRESTRIPPED_${ARCH/-/_}" [[ -n ${!qa_var} ]] && QA_PRESTRIPPED="${!qa_var}" if [[ -n ${QA_PRESTRIPPED} && -s ${log} && \ @@ -219,28 +260,49 @@ if ! ${RESTRICT_binchecks} && ! ${RESTRICT_strip} ; then fi sed -e "/^\$/d" -e "s#^#/#" -i "${log}" if [[ -s ${log} ]] ; then - vecho -e "\n" + __vecho -e "\n" eqawarn "QA Notice: Pre-stripped files found:" eqawarn "$(<"${log}")" else rm -f "${log}" fi ) & - multijob_post_fork + __multijob_post_fork +fi + +# Since strip creates a new inode, we need to know the initial set of +# inodes in advance, so that we can avoid interference due to trying +# to strip the same (hardlinked) file multiple times in parallel. +# See bug #421099. +if [[ ${USERLAND} == BSD ]] ; then + get_inode_number() { stat -f '%i' "$1"; } +else + get_inode_number() { stat -c '%i' "$1"; } fi +cd "${tmpdir}/inodes" || die "cd failed unexpectedly" +while read -r x ; do + inode_link=$(get_inode_number "${x}") || die "stat failed unexpectedly" + echo "${x}" >> "${inode_link}" || die "echo failed unexpectedly" +done < <( + # Use sort -u to eliminate duplicates for bug #445336. + ( + scanelf -yqRBF '#k%F' -k '.symtab' "$@" + find "$@" -type f ! -type l -name '*.a' + ) | LC_ALL=C sort -u +) # Now we look for unstripped binaries. -for x in \ - $(scanelf -yqRBF '#k%F' -k '.symtab' "$@") \ - $(find "$@" -type f -name '*.a') +for inode_link in $(shopt -s nullglob; echo *) ; do +while read -r x do + if ! ${banner} ; then - vecho "strip: ${STRIP} ${PORTAGE_STRIP_FLAGS}" + __vecho "strip: ${STRIP} ${PORTAGE_STRIP_FLAGS}" banner=true fi ( - multijob_child_init + __multijob_child_init f=$(file "${x}") || exit 0 [[ -z ${f} ]] && exit 0 @@ -275,27 +337,34 @@ do buildid= if [[ ${f} == *"current ar archive"* ]] ; then - vecho " ${x:${#ED}}" + __vecho " ${x:${#ED}}" if ${strip_this} ; then - # hmm, can we split debug/sources for .a ? - ${STRIP} -g "${x}" + # If we have split debug enabled, then do not strip this. + # There is no concept of splitdebug for objects not yet + # linked in (only for finally linked ELFs), so we have to + # retain the debug info in the archive itself. + if ! ${FEATURES_splitdebug} || ${RESTRICT_splitdebug} ; then + ${STRIP} -g "${x}" + fi fi elif [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* ]] ; then - process_elf "${x}" ${PORTAGE_STRIP_FLAGS} + process_elf "${x}" "${inode_link}" ${PORTAGE_STRIP_FLAGS} elif [[ ${f} == *"SB relocatable"* ]] ; then - process_elf "${x}" ${SAFE_STRIP_FLAGS} + process_elf "${x}" "${inode_link}" ${SAFE_STRIP_FLAGS} fi if ${was_not_writable} ; then chmod u-w "${x}" fi ) & - multijob_post_fork + __multijob_post_fork + +done < "${inode_link}" done # With a bit more work, we could run the rsync processes below in # parallel, but not sure that'd be an overall improvement. -multijob_finish +__multijob_finish cd "${tmpdir}"/sources/ && cat * > "${tmpdir}/debug.sources" 2>/dev/null if [[ -s ${tmpdir}/debug.sources ]] && \ @@ -303,11 +372,11 @@ if [[ -s ${tmpdir}/debug.sources ]] && \ ! ${RESTRICT_installsources} && \ ${debugedit_found} then - vecho "installsources: rsyncing source files" + __vecho "installsources: rsyncing source files" [[ -d ${D}${prepstrip_sources_dir} ]] || mkdir -p "${D}${prepstrip_sources_dir}" grep -zv '/<[^/>]*>$' "${tmpdir}"/debug.sources | \ (cd "${WORKDIR}"; LANG=C sort -z -u | \ - rsync -tL0 --files-from=- "${WORKDIR}/" "${D}${prepstrip_sources_dir}/" ) + rsync -tL0 --chmod=ugo-st,a+r,go-w,Da+x,Fa-x --files-from=- "${WORKDIR}/" "${D}${prepstrip_sources_dir}/" ) # Preserve directory structure. # Needed after running save_elf_sources. @@ -318,4 +387,5 @@ then done < <(find "${D}${prepstrip_sources_dir}/" -type d -empty -print0) fi +cd "${T}" rm -rf "${tmpdir}" |