Gentoo Archives: gentoo-dev

From: Sam James <sam@g.o>
To: gentoo-dev@l.g.o
Cc: qa@g.o, Sam James <sam@g.o>
Subject: [gentoo-dev] [PATCH] metadata/install-qa-check.d: add 60libtool-la (check for unnecessary .la files)
Date: Fri, 15 Apr 2022 08:41:09
Message-Id: 20220415084032.725048-1-sam@gentoo.org
1 Signed-off-by: Sam James <sam@g.o>
2 ---
3 metadata/install-qa-check.d/60libtool-la | 45 ++++++++++++++++++++++++
4 1 file changed, 45 insertions(+)
5 create mode 100644 metadata/install-qa-check.d/60libtool-la
6
7 diff --git a/metadata/install-qa-check.d/60libtool-la b/metadata/install-qa-check.d/60libtool-la
8 new file mode 100644
9 index 000000000000..fd21ec8406d3
10 --- /dev/null
11 +++ b/metadata/install-qa-check.d/60libtool-la
12 @@ -0,0 +1,45 @@
13 +# Check if we're installing .la files unnecessarily
14 +# https://projects.gentoo.org/qa/policy-guide/installed-files.html#pg0303
15 +
16 +libtool_la_check() {
17 + if [[ ${CATEGORY}/${PN} == dev-libs/libltdl ]] ; then
18 + # bug #293921
19 + return
20 + fi
21 +
22 + # Bail out if there aren't any .la files being installed
23 + local files=$(find "${ED}"/usr/lib* -name '*.la' -print 2>/dev/null)
24 + [[ -n "${files[@]}" ]] || return
25 +
26 + if grep -q "dev-libs/libltdl" <<<${RDEPEND}; then
27 + # Nothing to do here
28 + return
29 + fi
30 +
31 + # Iterate over all the .la files we are installing to verify there's
32 + # a corresponding .a file - they're pointless without a corresponding
33 + # static library.
34 + local file
35 + local dir
36 + local base
37 + local bad_files=()
38 + for file in "${files[@]}" ; do
39 + dir=$(dirname ${file})
40 + base=${dir%/}
41 + base=${base%.la}
42 +
43 + if [[ ! -f ${dir}/${base}.a ]] ; then
44 + bad_files+=( ${file} )
45 + fi
46 + done
47 +
48 + if [[ -n "${bad_files[@]}" ]] ; then
49 + eqawarn "QA Notice: Installing libtool files (.la) without corresponding libraries!"
50 + eqatag -v libtool-la.unnecessary "${bad_files[@]#${D}}"
51 + fi
52 +}
53 +
54 +libtool_la_check
55 +: # guarantee successful exit
56 +
57 +# vim:ft=sh
58 --
59 2.35.1

Replies