1 |
commit: 78c036c507ec8c87bf5dd7cc388cbf7e038a51ed |
2 |
Author: Michał Górny <mgorny <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Sep 25 19:12:20 2018 +0000 |
4 |
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Sep 28 20:32:40 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=78c036c5 |
7 |
|
8 |
ecompress: Detect and report colliding (un)compressed files |
9 |
|
10 |
Whenever the install directory contains files that would collide upon |
11 |
(re)compressing, report them explicitly and skip decompressing. |
12 |
|
13 |
To reduce performance impact, the check is only done whenever compressed |
14 |
files are found. This is sufficient since for issue to occur there must |
15 |
be at least one compressed variant. |
16 |
|
17 |
Bug: https://bugs.gentoo.org/667072 |
18 |
Signed-off-by: Michał Górny <mgorny <AT> gentoo.org> |
19 |
Reviewed-by: Zac Medico <zmedico <AT> gentoo.org> |
20 |
|
21 |
bin/ecompress | 32 ++++++++++++++++++++++++++++++++ |
22 |
1 file changed, 32 insertions(+) |
23 |
|
24 |
diff --git a/bin/ecompress b/bin/ecompress |
25 |
index 36bdb585b..635073b5f 100755 |
26 |
--- a/bin/ecompress |
27 |
+++ b/bin/ecompress |
28 |
@@ -48,9 +48,41 @@ while [[ $# -gt 0 ]] ; do |
29 |
[[ -n ${PORTAGE_DOCOMPRESS_SIZE_LIMIT} ]] && |
30 |
find_args+=( -size "+${PORTAGE_DOCOMPRESS_SIZE_LIMIT}c" ) |
31 |
|
32 |
+ declare -A collisions |
33 |
while IFS= read -d '' -r path; do |
34 |
+ # detect the horrible posibility of the ebuild installing |
35 |
+ # colliding compressed and/or uncompressed variants |
36 |
+ # and fail hard (bug #667072) |
37 |
+ # |
38 |
+ # note: to save time, we need to do this only if there's |
39 |
+ # at least one compressed file |
40 |
+ case ${path} in |
41 |
+ *.Z|*.gz|*.bz2|*.lzma|*.xz) |
42 |
+ vpath=${path%.*} |
43 |
+ for comp in '' .Z .gz .bz2 .lzma .xz; do |
44 |
+ if [[ ${vpath}${comp} != ${path} && \ |
45 |
+ -e ${vpath}${comp} ]]; then |
46 |
+ collisions[${path}]=1 |
47 |
+ collisions[${vpath}]=1 |
48 |
+ # ignore compressed variants in that case |
49 |
+ continue 2 |
50 |
+ fi |
51 |
+ done |
52 |
+ ;; |
53 |
+ esac |
54 |
+ |
55 |
>> "${path}.ecompress" || die |
56 |
done < <(find "${find_args[@]}" -print0 || die) |
57 |
+ |
58 |
+ if [[ ${#collisions[@]} -gt 0 ]]; then |
59 |
+ eqawarn "Colliding files found by ecompress:" |
60 |
+ eqawarn |
61 |
+ for x in "${!collisions[@]}"; do |
62 |
+ eqawarn " ${x}" |
63 |
+ done |
64 |
+ eqawarn |
65 |
+ eqawarn "Please remove the extraneous compressed variants." |
66 |
+ fi |
67 |
fi |
68 |
|
69 |
exit 0 |