summaryrefslogtreecommitdiffstats
path: root/bin/ebuild-helpers
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2012-12-11 01:00:25 -0800
committerZac Medico <zmedico@gentoo.org>2012-12-11 01:01:03 -0800
commit3464e5ace3ef520344a330601e0aac69bcdef222 (patch)
tree52400017002b8cf1016ca0b7dafb7759ecdff194 /bin/ebuild-helpers
parentd08f5efd56c19afab3e4538baf91fe4d6d7ecb1b (diff)
downloadportage-3464e5ace3ef520344a330601e0aac69bcdef222.tar.gz
portage-3464e5ace3ef520344a330601e0aac69bcdef222.tar.bz2
portage-3464e5ace3ef520344a330601e0aac69bcdef222.zip
prepstrip: preserve xattrs, bug #446420
Diffstat (limited to 'bin/ebuild-helpers')
-rwxr-xr-xbin/ebuild-helpers/prepstrip36
1 files changed, 33 insertions, 3 deletions
diff --git a/bin/ebuild-helpers/prepstrip b/bin/ebuild-helpers/prepstrip
index 6a09ff457..fb20777e8 100755
--- a/bin/ebuild-helpers/prepstrip
+++ b/bin/ebuild-helpers/prepstrip
@@ -15,7 +15,7 @@ exp_tf() {
eval ${var}_${flag}=$(tf has ${flag} ${!var})
done
}
-exp_tf FEATURES compressdebug installsources nostrip splitdebug
+exp_tf FEATURES compressdebug installsources nostrip splitdebug xattr
exp_tf RESTRICT binchecks installsources strip
if ! ___eapi_has_prefix_variables; then
@@ -30,6 +30,28 @@ 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() {
+ "${PORTAGE_PYTHON:-/usr/bin/python}" \
+ "${PORTAGE_BIN_PATH}/xattr-helper.py" --dump < <(echo -n "$1")
+ }
+ restore_xattrs() {
+ "${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
@@ -152,7 +174,7 @@ save_elf_debug() {
# Usage: process_elf <elf>
process_elf() {
local x=$1 inode_link=$2 strip_flags=${*:3}
- local already_stripped lockfile
+ local already_stripped lockfile xt_data
__vecho " ${x:${#ED}}"
@@ -171,7 +193,12 @@ process_elf() {
[ -f "${inode_link}_stripped" ] && already_stripped=true || already_stripped=false
- ${already_stripped} || save_elf_sources "${x}"
+ if ! ${already_stripped} ; then
+ if ${PRESERVE_XATTR} ; then
+ xt_data=$(dump_xattrs "${x}")
+ fi
+ save_elf_sources "${x}"
+ fi
if ${strip_this} ; then
@@ -197,6 +224,9 @@ process_elf() {
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}"