1 |
Warn about empty directories installed to /var in install-qa-check phase |
2 |
(that were not "filled" using keepdir), to help developers stop relying |
3 |
upon Portage preserving them. Those directories are rather unlikely to |
4 |
be false positives. |
5 |
|
6 |
Furthermore, remove all the empty directories if FEATURES=strict-keepdir |
7 |
is used to catch even more problems (intended for developers). Here |
8 |
warnings are not really suitable since there will be a high number |
9 |
of false positives. |
10 |
|
11 |
The PMS specifies the behavior upon merging empty directories |
12 |
as undefined, and specifically prohibits ebuilds from attempting |
13 |
to install empty directories. However, ebuilds occasionally still fall |
14 |
into the trap of relying on 'dodir' preserving the directory. Make |
15 |
the Portage behavior more strict in order to prevent that. |
16 |
--- |
17 |
bin/install-qa-check.d/95empty-dirs | 43 +++++++++++++++++++++++++++++++++++++ |
18 |
1 file changed, 43 insertions(+) |
19 |
create mode 100644 bin/install-qa-check.d/95empty-dirs |
20 |
|
21 |
diff --git a/bin/install-qa-check.d/95empty-dirs b/bin/install-qa-check.d/95empty-dirs |
22 |
new file mode 100644 |
23 |
index 000000000..a9cda7fe1 |
24 |
--- /dev/null |
25 |
+++ b/bin/install-qa-check.d/95empty-dirs |
26 |
@@ -0,0 +1,43 @@ |
27 |
+# Warn about and/or remove empty directories installed by ebuild. |
28 |
+ |
29 |
+# Rationale: PMS prohibits ebuilds from installing empty directories. |
30 |
+# Cleaning them up from the installation image provides an easy way |
31 |
+# to make sure that ebuilds are not relying on it while making it easy |
32 |
+# for users to override this if they need to. |
33 |
+# |
34 |
+# The ebuilds that need to preserve empty directories should use keepdir |
35 |
+# as documented e.g.: |
36 |
+# https://devmanual.gentoo.org/function-reference/install-functions/index.html |
37 |
+# |
38 |
+# For now, we emit QA warnings for empty directories in /var. |
39 |
+# Additionally, if FEATURES=strict-keepdir is enabled we explicitly |
40 |
+# remove *all* empty directories to trigger breakage. |
41 |
+ |
42 |
+find_empty_dirs() { |
43 |
+ local warn_dirs=() |
44 |
+ local d strip= |
45 |
+ |
46 |
+ [[ ${FEATURES} == *strict-keepdir* ]] && strip=1 |
47 |
+ |
48 |
+ while IFS= read -r -d $'\0' d; do |
49 |
+ warn_dirs+=( "${d}" ) |
50 |
+ done < <(find "${ED}" -mindepth 1 -type d -empty -print0) |
51 |
+ |
52 |
+ if [[ ${warn_dirs[@]} ]]; then |
53 |
+ eqawarn "One or more empty directories installed to /var:" |
54 |
+ eqawarn |
55 |
+ for d in "${warn_dirs[@]}"; do |
56 |
+ eqawarn " ${d#${ED%/}}" |
57 |
+ [[ ${strip} ]] && rmdir "${d}" |
58 |
+ done |
59 |
+ eqawarn |
60 |
+ eqawarn "If those directories need to be preserved, please make sure to create" |
61 |
+ eqawarn "or mark them for keeping using 'keepdir'. Future versions of Portage" |
62 |
+ eqawarn "will strip empty directories from installation image." |
63 |
+ fi |
64 |
+} |
65 |
+ |
66 |
+find_empty_dirs |
67 |
+: # guarantee successful exit |
68 |
+ |
69 |
+# vim:ft=sh |
70 |
-- |
71 |
2.16.1 |