Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: pinkbyte@g.o, "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH eutils] prune_libtool_files: do not remove non-libtool .la files.
Date: Fri, 03 May 2013 15:54:43
Message-Id: 1367596476-28639-1-git-send-email-mgorny@gentoo.org
1 Let's assume that all libtool files have a consistent format and contain
2 a line stating 'shouldnotlink=(yes|no)'. We use that to distinguish
3 modules from libraries, so we can as well use it to validate the .la
4 file to avoid removing non-libtool .la files.
5
6 This should also make the big 'if' a bit more readable.
7
8 Note: this is '-w' patch, since a large block of code was reindented.
9
10 Fixes: https://bugs.gentoo.org/show_bug.cgi?id=468380
11 ---
12 gx86/eclass/eutils.eclass | 19 ++++++++++++++-----
13 1 file changed, 14 insertions(+), 5 deletions(-)
14
15 diff --git a/gx86/eclass/eutils.eclass b/gx86/eclass/eutils.eclass
16 index 04e99e3..db5aa18 100644
17 --- a/gx86/eclass/eutils.eclass
18 +++ b/gx86/eclass/eutils.eclass
19 @@ -1458,11 +1458,12 @@ prune_libtool_files() {
20 local archivefile=${f/%.la/.a}
21
22 [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed'
23 -
24 local reason pkgconfig_scanned
25 + local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}")
26 +
27 + if [[ ${snotlink} == yes ]]; then
28
29 # Remove static libs we're not supposed to link against.
30 - if grep -q '^shouldnotlink=yes$' "${f}"; then
31 if [[ -f ${archivefile} ]]; then
32 einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)"
33 queue+=( "${archivefile}" )
34 @@ -1474,13 +1475,19 @@ prune_libtool_files() {
35 reason='module'
36 fi
37
38 + elif [[ ${snotlink} == no ]]; then
39 +
40 + # A valid .la file must have a valid 'shouldnotlink='.
41 + # That assumption helps us avoid removing random files
42 + # which match '*.la', see bug #468380.
43 +
44 # Remove .la files when:
45 # - user explicitly wants us to remove all .la files,
46 # - respective static archive doesn't exist,
47 # - they are covered by a .pc file already,
48 # - they don't provide any new information (no libs & no flags).
49
50 - elif [[ ${removing_all} ]]; then
51 + if [[ ${removing_all} ]]; then
52 reason='requested'
53 elif [[ ! -f ${archivefile} ]]; then
54 reason='no static archive'
55 @@ -1526,10 +1533,12 @@ prune_libtool_files() {
56 fi
57
58 pkgconfig_scanned=1
59 - fi
60 + fi # pkgconfig_scanned
61
62 has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc'
63 - fi
64 + fi # removal due to .pc
65 +
66 + fi # shouldnotlink==no
67
68 if [[ ${reason} ]]; then
69 einfo "Removing unnecessary ${f#${D%/}} (${reason})"
70 --
71 1.8.2.1

Replies