--- bin/prepstrip +++ bin/prepstrip @@ -25,9 +25,8 @@ banner=1 -save_elf_debug() { +save_elf_sources() { local x=$1 - local y="${D}usr/lib/debug/${x:${#D}}.debug" if hasq installsources ${FEATURES} && [ -x /usr/bin/debugedit ] ; then local sources_dir=/usr/src/debug/${CATEGORY}/${PF} @@ -40,12 +39,17 @@ rsync -rtL0 --files-from=- "${WORKDIR}/" "${D}${sources_dir}/" ) fi fi +} + +save_elf_debug() { + local x=$1 + local y="${D}usr/lib/debug/${x:${#D}}.debug" hasq splitdebug ${FEATURES} || return 0 [[ -z "${NOSTRIP}" ]] || return 0 # dont save debug info twice. - [[ ${x:7} == ".debug" ]] && return 0 + [[ ${x: -6} == ".debug" ]] && return 0 mkdir -p $(dirname "${y}") ${OBJCOPY} --only-keep-debug "${x}" "${y}" @@ -87,24 +91,23 @@ done set +o noglob + [[ -n ${NOSTRIP} ]] && stripitbaby=0 + if [[ ${f} == *"current ar archive"* ]] ; then vecho " ${x:${#D}}" [[ -n ${NOSTRIP} ]] && continue [[ ${stripitbaby} -eq 1 ]] && ${STRIP} -g "${x}" - elif [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* || ${f} == *"SB relocatable"* ]] ; then + elif [[ ${f} == *"SB executable"* || ${f} == *"SB shared object"* ]] ; then + vecho " ${x:${#D}}" + save_elf_sources "${x}" + save_elf_debug "${x}" + [[ ${stripitbaby} -eq 1 ]] && ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}" + elif [[ ${f} == *"SB relocatable"* ]] ; then vecho " ${x:${#D}}" - if [[ ${f} != *"SB relocatable"* ]] || [[ ${x} == *.ko ]] ; then - # only split debug info for final linked objects - # or kernel modules as debuginfo for intermediatary - # files (think crt*.o from gcc/glibc) is useless and - # actually causes problems + save_elf_sources "${x}" + if [[ ${x: -3} == ".ko" ]] ; then save_elf_debug "${x}" - fi - [[ -n ${NOSTRIP} ]] && continue - if [[ ${stripitbaby} -eq 1 ]] ; then - [[ ${f} == *"SB relocatable"* ]] \ - && ${STRIP} ${SAFE_STRIP_FLAGS} "${x}" \ - || ${STRIP} ${PORTAGE_STRIP_FLAGS} "${x}" + [[ ${stripitbaby} -eq 1 ]] && ${STRIP} ${SAFE_STRIP_FLAGS} "${x}" fi fi done