Gentoo Archives: gentoo-portage-dev

From: Alec Warner <antarus@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Sam James <sam@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH 2/2] Binpkg.py: check for inconsistent PROVIDES/image when unpacking binpkg
Date: Mon, 04 Oct 2021 19:36:40
Message-Id: CAAr7Pr_yy67aF5XZ8faekGrbt_thrsdh0UApSgYF7WftJHAP3g@mail.gmail.com
In Reply to: [gentoo-portage-dev] [PATCH 2/2] Binpkg.py: check for inconsistent PROVIDES/image when unpacking binpkg by Sam James
1 On Sat, Oct 2, 2021 at 1:11 PM Sam James <sam@g.o> wrote:
2 >
3 > This is part of a series of fixes for the linked bug (failure
4 > to preserve libraries in some situations).
5 >
6 > When unpacking a binpkg to be installed, we should check
7 > for the existence of PROVIDES if we're installing any
8 > dynamic libraries. If PROVIDES does not exist in that case,
9 > this suggests that e.g. scanelf malfunctioned or some corruption occurred.
10 >
11 > Bug: https://bugs.gentoo.org/811462
12 > Signed-off-by: Sam James <sam@g.o>
13 > ---
14 > lib/_emerge/Binpkg.py | 28 +++++++++++++++++++++++++++-
15 > 1 file changed, 27 insertions(+), 1 deletion(-)
16 >
17 > diff --git a/lib/_emerge/Binpkg.py b/lib/_emerge/Binpkg.py
18 > index c7dde69bd..9b876f354 100644
19 > --- a/lib/_emerge/Binpkg.py
20 > +++ b/lib/_emerge/Binpkg.py
21 > @@ -2,7 +2,7 @@
22 > # Distributed under the terms of the GNU General Public License v2
23 >
24 > import functools
25 > -
26 > +import glob
27 > import _emerge.emergelog
28 > from _emerge.EbuildPhase import EbuildPhase
29 > from _emerge.BinpkgFetcher import BinpkgFetcher
30 > @@ -13,6 +13,7 @@ from _emerge.EbuildMerge import EbuildMerge
31 > from _emerge.EbuildBuildDir import EbuildBuildDir
32 > from _emerge.SpawnProcess import SpawnProcess
33 > from portage.eapi import eapi_exports_replace_vars
34 > +from portage.output import colorize
35 > from portage.util import ensure_dirs
36 > from portage.util._async.AsyncTaskFuture import AsyncTaskFuture
37 > import portage
38 > @@ -425,6 +426,31 @@ class Binpkg(CompositeTask):
39 > self._async_unlock_builddir(returncode=self.returncode)
40 > return
41 >
42 > + # Before anything else, let's do an integrity check.
43 > + (provides,) = self._bintree.dbapi.aux_get(self.pkg.cpv, ["PROVIDES"])
44 > + if not provides:
45 > + # Let's check if we've got inconsistent results.
46 > + # If we're installing dynamic libraries (.so files), we should
47 > + # really have a PROVIDES.
48 > + # (This is a complementary check at the point of ingestion for the
49 > + # creation check in doebuild.py)
50 > + # Note: we could check a non-empty PROVIDES against the list of .sos,
51 > + # but this doesn't gain us anything. We're interested in failure
52 > + # to properly parse the installed files at all, which should really
53 > + # be a global problem (e.g. bug #811462)
54 > + installed_dynlibs = glob.glob(
55 > + self.settings["D"] + "/**/*.so", recursive=True
56 > + )
57 > + if installed_dynlibs:
58 > + self._writemsg_level(
59 > + colorize(
60 > + "BAD",
61 > + "!!! Error! Installing dynamic libraries (.so) with blank PROVIDES!",
62 > + ),
63 > + noiselevel=-1,
64 > + level=logging.ERROR,
65 > + )
66 > +
67
68 Here you have written the same code (and long comment block) as the
69 last patch...I'd take that as an argument to extract it into a
70 function (check_provides or whatever) and not copy and paste the code
71 around.
72
73 -A
74
75 > try:
76 > with io.open(
77 > _unicode_encode(
78 > --
79 > 2.33.0
80 >
81 >