Gentoo Archives: gentoo-dev

From: Maxwell Seefeld <cyberalamo@×××××.com>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH v2] distutils-r1.eclass: Add assertions for bindir correctness
Date: Fri, 10 Jun 2022 13:59:43
Message-Id: CAADn615Udtn+7Z8iJh2P1PJESBMAVfRbo0EgRq5VGjd5cCZCfA@mail.gmail.com
In Reply to: [gentoo-dev] [PATCH v2] distutils-r1.eclass: Add assertions for bindir correctness by "Michał Górny"
1 Hey, I'm new to the project is anyone maintaining Gentoo + BSD anymore or
2 the SELINUX package?
3
4 On Fri, Jun 10, 2022 at 8:17 AM Michał Górny <mgorny@g.o> wrote:
5
6 > The eclass code in distutils-r1_python_install makes some assumptions
7 > specific to _distutils-r1_post_python_compile being called,
8 > and scriptdir not being modified since. Make them more explicit by:
9 >
10 > 1) explicitly removing the files that we expect to have been created,
11 >
12 > 2) verifying that both the copied and the original scriptdir have
13 > the same list of files.
14 >
15 > Signed-off-by: Michał Górny <mgorny@g.o>
16 > ---
17 > eclass/distutils-r1.eclass | 30 +++++++++++++++++++++++++++---
18 > 1 file changed, 27 insertions(+), 3 deletions(-)
19 >
20 > Changes in v2:
21 > - use diff instead of cksum -- which makes the code both simpler
22 > and gives users clear info what's mismatched
23 >
24 > diff --git a/eclass/distutils-r1.eclass b/eclass/distutils-r1.eclass
25 > index f3d224a51224..3d5f0791baaf 100644
26 > --- a/eclass/distutils-r1.eclass
27 > +++ b/eclass/distutils-r1.eclass
28 > @@ -1514,13 +1514,37 @@ distutils-r1_python_install() {
29 > local merge_root=
30 > if [[ ${DISTUTILS_USE_PEP517} ]]; then
31 > local root=${BUILD_DIR}/install
32 > + local reg_scriptdir=${root}/${scriptdir}
33 > + local wrapped_scriptdir=${root}$(python_get_scriptdir)
34 > +
35 > + # we are assuming that _distutils-r1_post_python_compile
36 > + # has been called and ${root} has not been altered since
37 > + # let's explicitly verify these assumptions
38 > +
39 > + # remove files that we've created explicitly
40 > + rm
41 > "${reg_scriptdir}"/{"${EPYTHON}",python3,python,pyvenv.cfg} || die
42 > + # verify that scriptdir & wrapped_scriptdir both contain
43 > + # the same files
44 > + (
45 > + cd "${reg_scriptdir}" && find . -mindepth 1
46 > + ) | sort > "${T}"/files-bin
47 > + assert "listing ${reg_scriptdir} failed"
48 > + (
49 > + if [[ -d ${wrapped_scriptdir} ]]; then
50 > + cd "${wrapped_scriptdir}" && find .
51 > -mindepth 1
52 > + fi
53 > + ) | sort > "${T}"/files-wrapped
54 > + assert "listing ${wrapped_scriptdir} failed"
55 > + if ! diff -U 0 "${T}"/files-{bin,wrapped}; then
56 > + die "File lists for ${reg_scriptdir} and
57 > ${wrapped_scriptdir} differ (see diff above)"
58 > + fi
59 > +
60 > # remove the altered bindir, executables from the package
61 > # are already in scriptdir
62 > - rm -r "${root}${scriptdir}" || die
63 > + rm -r "${reg_scriptdir}" || die
64 > if [[ ${DISTUTILS_SINGLE_IMPL} ]]; then
65 > - local
66 > wrapped_scriptdir=${root}$(python_get_scriptdir)
67 > if [[ -d ${wrapped_scriptdir} ]]; then
68 > - mv "${wrapped_scriptdir}"
69 > "${root}${scriptdir}" || die
70 > + mv "${wrapped_scriptdir}"
71 > "${reg_scriptdir}" || die
72 > fi
73 > fi
74 > # prune empty directories to see if ${root} contains
75 > anything
76 > --
77 > 2.35.1
78 >
79 >
80 >

Replies