commit: 9089c2d755b0ecb1b340fc23dda461163f589c43 Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> AuthorDate: Sat May 31 23:15:20 2014 +0000 Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com> CommitDate: Tue Jun 17 18:49:37 2014 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9089c2d7
ebuild-helpers/xattr/install: use install-xattr Currently bin/ebuild-helpers/xattr/install uses ${PORTAGE_BIN_PATH}/install.py as a wrapper to coreutils' install to preserve a file's extended attributes when installing, usually during src_install(). This is needed, for instance, when preserving xattr based PaX flags, bug #465000. However the python wrapper is very slow, comment #42 of bug #465000. A C wrapper was developed and tested, bugs #501534 and #511984. This patch checks for the existence of the C wrapper, and uses it, falling back on the python wrapper only if not found, or if over- ridden by ${PORTAGE_INSTALL_XATTR_IMPLEMENTATION}. --- bin/ebuild-helpers/xattr/install | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/bin/ebuild-helpers/xattr/install b/bin/ebuild-helpers/xattr/install index f51f621..d572fe6 100755 --- a/bin/ebuild-helpers/xattr/install +++ b/bin/ebuild-helpers/xattr/install @@ -4,9 +4,32 @@ PORTAGE_BIN_PATH=${PORTAGE_BIN_PATH:-/usr/lib/portage/bin} PORTAGE_PYM_PATH=${PORTAGE_PYM_PATH:-/usr/lib/portage/pym} +INSTALL_XATTR=${EPREFIX}/usr/bin/install-xattr # Use safe cwd, avoiding unsafe import for bug #469338. export __PORTAGE_HELPER_CWD=${PWD} cd "${PORTAGE_PYM_PATH}" export __PORTAGE_HELPER_PATH=${BASH_SOURCE[0]} -PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ - exec "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/install.py" "$@" + +if [[ ${PORTAGE_INSTALL_XATTR_IMPLEMENTATION} == "c" ]]; then + implementation="c" +elif [[ ${PORTAGE_INSTALL_XATTR_IMPLEMENTATION} == "python" ]]; then + implementation="python" +else + # If PORTAGE_INSTALL_XATTR_IMPLEMENTATION is unset or not set to "c" or "python" + # then we'll autodetect, preferring "c" but falling back on "python" + if [[ -x "${INSTALL_XATTR}" ]]; then + implementation="c" + else + implementation="python" + fi +fi + +if [[ "${implementation}" == "c" ]]; then + exec "${INSTALL_XATTR}" "$@" +elif [[ "${implementation}" == "python" ]]; then + PYTHONPATH=${PORTAGE_PYTHONPATH:-${PORTAGE_PYM_PATH}} \ + exec "${PORTAGE_PYTHON:-/usr/bin/python}" "${PORTAGE_BIN_PATH}/install.py" "$@" +else + echo "Unknown implementation for PORTAGE_INSTALL_XATTR_IMPLEMENTATION" + exit -1 +fi