Gentoo Archives: gentoo-portage-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-portage-dev] [PATCH v2] install-qa-check: Do not install empty directories
Date: Wed, 10 Jan 2018 20:13:28
Message-Id: 20180110201317.10047-1-mgorny@gentoo.org
1 Remove empty directories in install-qa-check phase in order to prevent
2 Portage from installing them, and therefore from developers relying
3 on them being installed.
4
5 The PMS specifies the behavior upon merging empty directories
6 as undefined, and specifically prohibits ebuilds from attempting
7 to install empty directories. However, ebuilds occasionally still fall
8 into the trap of relying on 'dodir' preserving the directory. Make
9 the Portage behavior more strict in order to prevent that.
10
11 Use 'install-qa-check.d' machinery for this as this provides an easy way
12 for users to restore the old behavior (by overriding the check) if they
13 need it for their private ebuilds. It also makes it possible to extend
14 the check with some QA warnings, if we figure out how to do them.
15
16 Currently no QA warnings are emitted as we do not want to pursue
17 upstream build systems that create empty directories but the packages
18 themselves do not rely on them being installed, e.g. when some files
19 are installed into the directory conditionally.
20 ---
21 bin/install-qa-check.d/95empty-dirs | 25 +++++++++++++++++++++++++
22 1 file changed, 25 insertions(+)
23 create mode 100644 bin/install-qa-check.d/95empty-dirs
24
25 diff --git a/bin/install-qa-check.d/95empty-dirs b/bin/install-qa-check.d/95empty-dirs
26 new file mode 100644
27 index 000000000..92f3da86d
28 --- /dev/null
29 +++ b/bin/install-qa-check.d/95empty-dirs
30 @@ -0,0 +1,25 @@
31 +# Remove empty directories installed by ebuild.
32 +
33 +# Rationale: PMS prohibits ebuilds from installing empty directories.
34 +# Cleaning them up from the installation image provides an easy way
35 +# to make sure that ebuilds are not relying on it while making it easy
36 +# for users to override this if they need to.
37 +#
38 +# The ebuilds that need to preserve empty directories should use keepdir
39 +# as documented e.g.:
40 +# https://devmanual.gentoo.org/function-reference/install-functions/index.html
41 +#
42 +# Technically, we could emit QA warnings here. However, we do not want
43 +# to pursue every upstream build system that creates a directory
44 +# and does not install any file into it (think of files installed
45 +# conditionally), as long as the package functions correctly without
46 +# the directory being actually installed.
47 +
48 +strip_empty_dirs() {
49 + find "${ED}" -mindepth 1 -type d -empty -delete
50 +}
51 +
52 +strip_empty_dirs
53 +: # guarantee successful exit
54 +
55 +# vim:ft=sh
56 --
57 2.16.0.rc1

Replies