* [gentoo-portage-dev] [PATCH v2 3/4] ecompress: Detect and report colliding (un)compressed files
@ 2018-09-28 19:51 99% ` Michał Górny
0 siblings, 0 replies; 1+ results
From: Michał Górny @ 2018-09-28 19:51 UTC (permalink / raw
To: gentoo-portage-dev; +Cc: Michał Górny
Whenever the install directory contains files that would collide upon
(re)compressing, report them explicitly and skip decompressing.
To reduce performance impact, the check is only done whenever compressed
files are found. This is sufficient since for issue to occur there must
be at least one compressed variant.
Bug: https://bugs.gentoo.org/667072
Signed-off-by: Michał Górny <mgorny@gentoo.org>
fixup
---
bin/ecompress | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/bin/ecompress b/bin/ecompress
index 36bdb585b..635073b5f 100755
--- a/bin/ecompress
+++ b/bin/ecompress
@@ -48,9 +48,41 @@ while [[ $# -gt 0 ]] ; do
[[ -n ${PORTAGE_DOCOMPRESS_SIZE_LIMIT} ]] &&
find_args+=( -size "+${PORTAGE_DOCOMPRESS_SIZE_LIMIT}c" )
+ declare -A collisions
while IFS= read -d '' -r path; do
+ # detect the horrible posibility of the ebuild installing
+ # colliding compressed and/or uncompressed variants
+ # and fail hard (bug #667072)
+ #
+ # note: to save time, we need to do this only if there's
+ # at least one compressed file
+ case ${path} in
+ *.Z|*.gz|*.bz2|*.lzma|*.xz)
+ vpath=${path%.*}
+ for comp in '' .Z .gz .bz2 .lzma .xz; do
+ if [[ ${vpath}${comp} != ${path} && \
+ -e ${vpath}${comp} ]]; then
+ collisions[${path}]=1
+ collisions[${vpath}]=1
+ # ignore compressed variants in that case
+ continue 2
+ fi
+ done
+ ;;
+ esac
+
>> "${path}.ecompress" || die
done < <(find "${find_args[@]}" -print0 || die)
+
+ if [[ ${#collisions[@]} -gt 0 ]]; then
+ eqawarn "Colliding files found by ecompress:"
+ eqawarn
+ for x in "${!collisions[@]}"; do
+ eqawarn " ${x}"
+ done
+ eqawarn
+ eqawarn "Please remove the extraneous compressed variants."
+ fi
fi
exit 0
--
2.19.0
^ permalink raw reply related [relevance 99%]
Results 1-1 of 1 | reverse | options above
-- pct% links below jump to the message on this page, permalinks otherwise --
2018-09-28 19:51 [gentoo-portage-dev] [PATCH v2 1/4] Revert "ecompress-file: de-duplicate filtered_args (bug 667072)" Michał Górny
2018-09-28 19:51 99% ` [gentoo-portage-dev] [PATCH v2 3/4] ecompress: Detect and report colliding (un)compressed files Michał Górny
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox