1 |
On 01/30/2018 10:18 AM, Zac Medico wrote: |
2 |
> On 01/29/2018 11:23 PM, Michał Górny wrote: |
3 |
>> Warn about empty directories installed to /var in install-qa-check phase |
4 |
>> (that were not "filled" using keepdir), to help developers stop relying |
5 |
>> upon Portage preserving them. Those directories are rather unlikely to |
6 |
>> be false positives. |
7 |
>> |
8 |
>> Furthermore, remove all the empty directories if FEATURES=strict-keepdir |
9 |
>> is used to catch even more problems (intended for developers). Here |
10 |
>> warnings are not really suitable since there will be a high number |
11 |
>> of false positives. |
12 |
>> |
13 |
>> The PMS specifies the behavior upon merging empty directories |
14 |
>> as undefined, and specifically prohibits ebuilds from attempting |
15 |
>> to install empty directories. However, ebuilds occasionally still fall |
16 |
>> into the trap of relying on 'dodir' preserving the directory. Make |
17 |
>> the Portage behavior more strict in order to prevent that. |
18 |
>> --- |
19 |
>> bin/install-qa-check.d/95empty-dirs | 42 +++++++++++++++++++++++++++++++++++++ |
20 |
>> man/make.conf.5 | 4 ++++ |
21 |
>> pym/portage/const.py | 1 + |
22 |
>> 3 files changed, 47 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..0d06b278d |
28 |
>> --- /dev/null |
29 |
>> +++ b/bin/install-qa-check.d/95empty-dirs |
30 |
>> @@ -0,0 +1,42 @@ |
31 |
>> +# Warn about and/or 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 |
>> +# For now, we emit QA warnings for empty directories in /var. |
43 |
>> +# Additionally, if FEATURES=strict-keepdir is enabled we explicitly |
44 |
>> +# remove *all* empty directories to trigger breakage. |
45 |
>> + |
46 |
>> +find_empty_dirs() { |
47 |
>> + local warn_dirs=() |
48 |
>> + local d striparg= |
49 |
>> + |
50 |
>> + [[ ${FEATURES} == *strict-keepdir* ]] && striparg=-delete |
51 |
>> + |
52 |
>> + while IFS= read -r -d $'\0' d; do |
53 |
>> + [[ ${d} == ${ED%/}/var/* ]] && warn_dirs+=( "${d}" ) |
54 |
>> + done < <(find "${ED}" -depth -mindepth 1 -type d -empty -print0 ${striparg} | sort -z) |
55 |
> |
56 |
> Are you sure that this sort call is guaranteed to produce the correct |
57 |
> order? Comparison of '-' characters with '/' characters can lead to odd |
58 |
> results like this: |
59 |
> |
60 |
> $ printf 'foo/bar\nfoo-bar/baz\nfoo/bar/baz\n' | sort |
61 |
> foo/bar |
62 |
> foo-bar/baz |
63 |
> foo/bar/baz |
64 |
|
65 |
The sort is only for display purposes, maybe use LC_ALL=C for locale |
66 |
independence? |
67 |
-- |
68 |
Thanks, |
69 |
Zac |