public inbox for gentoo-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-dev] [PATCH eutils] prune_libtool_files: do not remove non-libtool .la files.
@ 2013-05-03 15:54 Michał Górny
  2013-05-15 19:02 ` Michał Górny
  0 siblings, 1 reply; 2+ messages in thread
From: Michał Górny @ 2013-05-03 15:54 UTC (permalink / raw
  To: gentoo-dev; +Cc: pinkbyte, Michał Górny

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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [gentoo-dev] [PATCH eutils] prune_libtool_files: do not remove non-libtool .la files.
  2013-05-03 15:54 [gentoo-dev] [PATCH eutils] prune_libtool_files: do not remove non-libtool .la files Michał Górny
@ 2013-05-15 19:02 ` Michał Górny
  0 siblings, 0 replies; 2+ messages in thread
From: Michał Górny @ 2013-05-15 19:02 UTC (permalink / raw
  To: gentoo-dev; +Cc: pinkbyte

[-- Attachment #1: Type: text/plain, Size: 412 bytes --]

On Fri,  3 May 2013 17:54:36 +0200
Michał Górny <mgorny@gentoo.org> wrote:

> 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.

I've committed the patch.

-- 
Best regards,
Michał Górny

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 966 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-05-15 19:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-03 15:54 [gentoo-dev] [PATCH eutils] prune_libtool_files: do not remove non-libtool .la files Michał Górny
2013-05-15 19:02 ` Michał Górny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox