Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o, Zac Medico <zmedico@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH v3] install-qa-check: New QA check/cleanup for empty directories
Date: Tue, 30 Jan 2018 19:01:31
Message-Id: 1517338884.20159.3.camel@gentoo.org
In Reply to: Re: [gentoo-portage-dev] [PATCH v3] install-qa-check: New QA check/cleanup for empty directories by Zac Medico
1 W dniu wto, 30.01.2018 o godzinie 10∶39 -0800, użytkownik Zac Medico
2 napisał:
3 > On 01/30/2018 10:18 AM, Zac Medico wrote:
4 > > On 01/29/2018 11:23 PM, Michał Górny wrote:
5 > > > Warn about empty directories installed to /var in install-qa-check phase
6 > > > (that were not "filled" using keepdir), to help developers stop relying
7 > > > upon Portage preserving them. Those directories are rather unlikely to
8 > > > be false positives.
9 > > >
10 > > > Furthermore, remove all the empty directories if FEATURES=strict-keepdir
11 > > > is used to catch even more problems (intended for developers). Here
12 > > > warnings are not really suitable since there will be a high number
13 > > > of false positives.
14 > > >
15 > > > The PMS specifies the behavior upon merging empty directories
16 > > > as undefined, and specifically prohibits ebuilds from attempting
17 > > > to install empty directories. However, ebuilds occasionally still fall
18 > > > into the trap of relying on 'dodir' preserving the directory. Make
19 > > > the Portage behavior more strict in order to prevent that.
20 > > > ---
21 > > > bin/install-qa-check.d/95empty-dirs | 42 +++++++++++++++++++++++++++++++++++++
22 > > > man/make.conf.5 | 4 ++++
23 > > > pym/portage/const.py | 1 +
24 > > > 3 files changed, 47 insertions(+)
25 > > > create mode 100644 bin/install-qa-check.d/95empty-dirs
26 > > >
27 > > > diff --git a/bin/install-qa-check.d/95empty-dirs b/bin/install-qa-check.d/95empty-dirs
28 > > > new file mode 100644
29 > > > index 000000000..0d06b278d
30 > > > --- /dev/null
31 > > > +++ b/bin/install-qa-check.d/95empty-dirs
32 > > > @@ -0,0 +1,42 @@
33 > > > +# Warn about and/or remove empty directories installed by ebuild.
34 > > > +
35 > > > +# Rationale: PMS prohibits ebuilds from installing empty directories.
36 > > > +# Cleaning them up from the installation image provides an easy way
37 > > > +# to make sure that ebuilds are not relying on it while making it easy
38 > > > +# for users to override this if they need to.
39 > > > +#
40 > > > +# The ebuilds that need to preserve empty directories should use keepdir
41 > > > +# as documented e.g.:
42 > > > +# https://devmanual.gentoo.org/function-reference/install-functions/index.html
43 > > > +#
44 > > > +# For now, we emit QA warnings for empty directories in /var.
45 > > > +# Additionally, if FEATURES=strict-keepdir is enabled we explicitly
46 > > > +# remove *all* empty directories to trigger breakage.
47 > > > +
48 > > > +find_empty_dirs() {
49 > > > + local warn_dirs=()
50 > > > + local d striparg=
51 > > > +
52 > > > + [[ ${FEATURES} == *strict-keepdir* ]] && striparg=-delete
53 > > > +
54 > > > + while IFS= read -r -d $'\0' d; do
55 > > > + [[ ${d} == ${ED%/}/var/* ]] && warn_dirs+=( "${d}" )
56 > > > + done < <(find "${ED}" -depth -mindepth 1 -type d -empty -print0 ${striparg} | sort -z)
57 > >
58 > > Are you sure that this sort call is guaranteed to produce the correct
59 > > order? Comparison of '-' characters with '/' characters can lead to odd
60 > > results like this:
61 > >
62 > > $ printf 'foo/bar\nfoo-bar/baz\nfoo/bar/baz\n' | sort
63 > > foo/bar
64 > > foo-bar/baz
65 > > foo/bar/baz
66 >
67 > The sort is only for display purposes, maybe use LC_ALL=C for locale
68 > independence?
69
70 That's what I wanted to suggest. Well, LC_COLLATE=C should be enough.
71
72 --
73 Best regards,
74 Michał Górny