Gentoo Archives: gentoo-portage-dev

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

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies