Gentoo Archives: gentoo-portage-dev

From: Sam James <sam@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Sam James <sam@g.o>
Subject: [gentoo-portage-dev] [PATCH 1/2] doebuild.py: check for inconsistent PROVIDES/image post-src_install
Date: Sat, 02 Oct 2021 20:11:39
Message-Id: 20211002201125.346005-2-sam@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 0/2] Detect broken VDB on merging/binpkg creation by Sam James
1 This is part of a series of fixes for the linked bug (failure
2 to preserve libraries in some situations).
3
4 At the point of installation (even if not merging), we need
5 to detect inconsistent metadata: PROVIDES should be populated
6 if we're installing any dynamic libraries. This suggests that
7 e.g. scanelf malfunctioned or some corruption occurred.
8
9 Bug: https://bugs.gentoo.org/811462
10 Signed-off-by: Sam James <sam@g.o>
11 ---
12 lib/portage/package/ebuild/doebuild.py | 24 +++++++++++++++++++++++-
13 1 file changed, 23 insertions(+), 1 deletion(-)
14
15 diff --git a/lib/portage/package/ebuild/doebuild.py b/lib/portage/package/ebuild/doebuild.py
16 index 9650a8444..dc3fe3d97 100644
17 --- a/lib/portage/package/ebuild/doebuild.py
18 +++ b/lib/portage/package/ebuild/doebuild.py
19 @@ -3,6 +3,7 @@
20
21 __all__ = ["doebuild", "doebuild_environment", "spawn", "spawnebuild"]
22
23 +import glob
24 import grp
25 import gzip
26 import errno
27 @@ -3079,7 +3080,7 @@ def _post_src_install_soname_symlinks(mysettings, out):
28 ) as f:
29 f.write(soname_deps.requires)
30
31 - if soname_deps.provides is not None:
32 + if soname_deps.provides:
33 with io.open(
34 _unicode_encode(
35 os.path.join(build_info_dir, "PROVIDES"),
36 @@ -3091,6 +3092,27 @@ def _post_src_install_soname_symlinks(mysettings, out):
37 errors="strict",
38 ) as f:
39 f.write(soname_deps.provides)
40 + else:
41 + # Let's check if we've got inconsistent results.
42 + # If we're installing dynamic libraries (.so files), we should
43 + # really have a PROVIDES.
44 + # (This is a complementary check at the point of creation for the
45 + # ingestion check in Binpkg.py)
46 + # Note: we could check a non-empty PROVIDES against the list of .sos,
47 + # but this doesn't gain us anything. We're interested in failure
48 + # to properly parse the installed files at all, which should really
49 + # be a global problem (e.g. bug #811462)
50 + installed_dynlibs = glob.glob(image_dir + "/**/*.so", recursive=True)
51 +
52 + if installed_dynlibs:
53 + self._writemsg_level(
54 + colorize(
55 + "BAD",
56 + "!!! Error! Installing dynamic libraries (.so) with blank PROVIDES!",
57 + ),
58 + noiselevel=-1,
59 + level=logging.ERROR,
60 + )
61
62 if unrecognized_elf_files:
63 qa_msg = ["QA Notice: Unrecognized ELF file(s):"]
64 --
65 2.33.0

Replies