1 |
commit: 104635efa9b4c9e268832d9ac64ad39e44002df3 |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Wed Jan 10 16:40:08 2018 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Jan 30 22:12:21 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=104635ef |
7 |
|
8 |
install-qa-check: New QA check/cleanup for empty directories |
9 |
|
10 |
Warn about empty directories installed to /var in install-qa-check phase |
11 |
(that were not "filled" using keepdir), to help developers stop relying |
12 |
upon Portage preserving them. Those directories are rather unlikely to |
13 |
be false positives. |
14 |
|
15 |
Furthermore, remove all the empty directories if FEATURES=strict-keepdir |
16 |
is used to catch even more problems (intended for developers). Here |
17 |
warnings are not really suitable since there will be a high number |
18 |
of false positives. |
19 |
|
20 |
The PMS specifies the behavior upon merging empty directories |
21 |
as undefined, and specifically prohibits ebuilds from attempting |
22 |
to install empty directories. However, ebuilds occasionally still fall |
23 |
into the trap of relying on 'dodir' preserving the directory. Make |
24 |
the Portage behavior more strict in order to prevent that. |
25 |
|
26 |
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org> |
27 |
|
28 |
bin/install-qa-check.d/95empty-dirs | 42 +++++++++++++++++++++++++++++++++++++ |
29 |
man/make.conf.5 | 4 ++++ |
30 |
pym/portage/const.py | 1 + |
31 |
3 files changed, 47 insertions(+) |
32 |
|
33 |
diff --git a/bin/install-qa-check.d/95empty-dirs b/bin/install-qa-check.d/95empty-dirs |
34 |
new file mode 100644 |
35 |
index 000000000..8599db395 |
36 |
--- /dev/null |
37 |
+++ b/bin/install-qa-check.d/95empty-dirs |
38 |
@@ -0,0 +1,42 @@ |
39 |
+# Warn about and/or remove empty directories installed by ebuild. |
40 |
+ |
41 |
+# Rationale: PMS prohibits ebuilds from installing empty directories. |
42 |
+# Cleaning them up from the installation image provides an easy way |
43 |
+# to make sure that ebuilds are not relying on it while making it easy |
44 |
+# for users to override this if they need to. |
45 |
+# |
46 |
+# The ebuilds that need to preserve empty directories should use keepdir |
47 |
+# as documented e.g.: |
48 |
+# https://devmanual.gentoo.org/function-reference/install-functions/index.html |
49 |
+# |
50 |
+# For now, we emit QA warnings for empty directories in /var. |
51 |
+# Additionally, if FEATURES=strict-keepdir is enabled we explicitly |
52 |
+# remove *all* empty directories to trigger breakage. |
53 |
+ |
54 |
+find_empty_dirs() { |
55 |
+ local warn_dirs=() |
56 |
+ local d striparg= |
57 |
+ |
58 |
+ [[ ${FEATURES} == *strict-keepdir* ]] && striparg=-delete |
59 |
+ |
60 |
+ while IFS= read -r -d $'\0' d; do |
61 |
+ [[ ${d} == ${ED%/}/var/* ]] && warn_dirs+=( "${d}" ) |
62 |
+ done < <(find "${ED}" -depth -mindepth 1 -type d -empty -print0 ${striparg} | LC_COLLATE=C sort -z) |
63 |
+ |
64 |
+ if [[ ${warn_dirs[@]} ]]; then |
65 |
+ eqawarn "One or more empty directories installed to /var:" |
66 |
+ eqawarn |
67 |
+ for d in "${warn_dirs[@]}"; do |
68 |
+ eqawarn " ${d#${ED%/}}" |
69 |
+ done |
70 |
+ eqawarn |
71 |
+ eqawarn "If those directories need to be preserved, please make sure to create" |
72 |
+ eqawarn "or mark them for keeping using 'keepdir'. Future versions of Portage" |
73 |
+ eqawarn "will strip empty directories from installation image." |
74 |
+ fi |
75 |
+} |
76 |
+ |
77 |
+find_empty_dirs |
78 |
+: # guarantee successful exit |
79 |
+ |
80 |
+# vim:ft=sh |
81 |
|
82 |
diff --git a/man/make.conf.5 b/man/make.conf.5 |
83 |
index a81b497bd..cb0f00237 100644 |
84 |
--- a/man/make.conf.5 |
85 |
+++ b/man/make.conf.5 |
86 |
@@ -623,6 +623,10 @@ see \fBinstallsources\fR. |
87 |
Have portage react strongly to conditions that have the potential to be |
88 |
dangerous (like missing or incorrect digests for ebuilds). |
89 |
.TP |
90 |
+.B strict-keepdir |
91 |
+Have portage strictly require keepdir calls in ebuilds. Empty |
92 |
+directories installed without explicit keepdir will be removed. |
93 |
+.TP |
94 |
.B stricter |
95 |
Have portage react strongly to conditions that may conflict with system |
96 |
security provisions (for example textrels, executable stack). Read about |
97 |
|
98 |
diff --git a/pym/portage/const.py b/pym/portage/const.py |
99 |
index e5fa4b67c..655be82b1 100644 |
100 |
--- a/pym/portage/const.py |
101 |
+++ b/pym/portage/const.py |
102 |
@@ -184,6 +184,7 @@ SUPPORTED_FEATURES = frozenset([ |
103 |
"split-elog", |
104 |
"split-log", |
105 |
"strict", |
106 |
+ "strict-keepdir", |
107 |
"stricter", |
108 |
"suidctl", |
109 |
"test", |