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] install-qa-check: Do not install empty directories
Date: Wed, 10 Jan 2018 16:48:59
Message-Id: 20180110164844.29444-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 | 21 +++++++++++++++++++++
22 1 file changed, 21 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..6b8790f59
28 --- /dev/null
29 +++ b/bin/install-qa-check.d/95empty-dirs
30 @@ -0,0 +1,21 @@
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 +# Technically, we could emit QA warnings here. However, we do not want
39 +# to pursue every upstream build system that creates a directory
40 +# and does not install any file into it (think of files installed
41 +# conditionally), as long as the package functions correctly without
42 +# the directory being actually installed.
43 +
44 +strip_empty_dirs() {
45 + find "${ED}" -mindepth 1 -type d -empty -delete
46 +}
47 +
48 +strip_empty_dirs
49 +: # guarantee successful exit
50 +
51 +# vim:ft=sh
52 --
53 2.16.0.rc1

Replies