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

Replies