Let's assume that all libtool files have a consistent format and contain a line stating 'shouldnotlink=(yes|no)'. We use that to distinguish modules from libraries, so we can as well use it to validate the .la file to avoid removing non-libtool .la files.
This should also make the big 'if' a bit more readable. Note: this is '-w' patch, since a large block of code was reindented. Fixes: https://bugs.gentoo.org/show_bug.cgi?id=468380 --- gx86/eclass/eutils.eclass | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/gx86/eclass/eutils.eclass b/gx86/eclass/eutils.eclass index 04e99e3..db5aa18 100644 --- a/gx86/eclass/eutils.eclass +++ b/gx86/eclass/eutils.eclass @@ -1458,11 +1458,12 @@ prune_libtool_files() { local archivefile=${f/%.la/.a} [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed' - local reason pkgconfig_scanned + local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}") + + if [[ ${snotlink} == yes ]]; then # Remove static libs we're not supposed to link against. - if grep -q '^shouldnotlink=yes$' "${f}"; then if [[ -f ${archivefile} ]]; then einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)" queue+=( "${archivefile}" ) @@ -1474,13 +1475,19 @@ prune_libtool_files() { reason='module' fi + elif [[ ${snotlink} == no ]]; then + + # A valid .la file must have a valid 'shouldnotlink='. + # That assumption helps us avoid removing random files + # which match '*.la', see bug #468380. + # Remove .la files when: # - user explicitly wants us to remove all .la files, # - respective static archive doesn't exist, # - they are covered by a .pc file already, # - they don't provide any new information (no libs & no flags). - elif [[ ${removing_all} ]]; then + if [[ ${removing_all} ]]; then reason='requested' elif [[ ! -f ${archivefile} ]]; then reason='no static archive' @@ -1526,10 +1533,12 @@ prune_libtool_files() { fi pkgconfig_scanned=1 - fi + fi # pkgconfig_scanned has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc' - fi + fi # removal due to .pc + + fi # shouldnotlink==no if [[ ${reason} ]]; then einfo "Removing unnecessary ${f#${D%/}} (${reason})" -- 1.8.2.1
