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 4/4] ecompress: Fix duplicate pre-compressed file warning
Date: Fri, 28 Sep 2018 07:55:54
Message-Id: 20180928075529.7322-5-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 0/4] Proper fix for colliding (un)compressed files by "Michał Górny"
1 Fix the pre-compressed file warning to be reported only once, now that
2 files are processed in parallel. Also, print the list of precompressed
3 files verbosely.
4
5 Signed-off-by: Michał Górny <mgorny@g.o>
6 ---
7 bin/ecompress | 16 ++++++++++++++++
8 bin/ecompress-file | 16 +++-------------
9 2 files changed, 19 insertions(+), 13 deletions(-)
10
11 diff --git a/bin/ecompress b/bin/ecompress
12 index bc1f5e08a..38b91a121 100755
13 --- a/bin/ecompress
14 +++ b/bin/ecompress
15 @@ -70,6 +70,7 @@ while [[ $# -gt 0 ]] ; do
16 die "Aborting due to colliding compressed files."
17 fi
18 done
19 + echo "${path}" >> "${T}"/.ecompress_had_precompressed
20 ;;
21 esac
22
23 @@ -167,6 +168,21 @@ find "${ED}" -name '*.ecompress' -delete -print0 |
24 ___parallel_xargs -0 "${PORTAGE_BIN_PATH}"/ecompress-file
25 ret=${?}
26
27 +if [[ -f ${T}/.ecompress_had_precompressed ]]; then
28 + eqawarn "One or more compressed files were found in docompress-ed directories."
29 + eqawarn "Please fix the ebuild not to install compressed files (manpages,"
30 + eqawarn "documentation) when automatic compression is used:"
31 + eqawarn
32 + n=0
33 + while read -r f; do
34 + eqawarn " ${f#${D%/}}"
35 + if [[ $(( n++ )) -eq 10 ]]; then
36 + eqawarn " ..."
37 + break
38 + fi
39 + done <"${T}"/.ecompress_had_precompressed
40 +fi
41 +
42 fix_symlinks
43 : $(( ret |= ${?} ))
44 [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
45 diff --git a/bin/ecompress-file b/bin/ecompress-file
46 index 18269c91b..bc8fe5451 100755
47 --- a/bin/ecompress-file
48 +++ b/bin/ecompress-file
49 @@ -14,7 +14,6 @@ compress_file() {
50 set +f
51 mask_ext_re="^(${mask_ext_re:1})\$"
52 local filtered_args=()
53 - local had_precompressed=
54 for x in "$@" ; do
55 [[ ${x##*.} =~ $mask_ext_re ]] && continue
56 [[ -s ${x} ]] || continue
57 @@ -23,16 +22,13 @@ compress_file() {
58 case ${x} in
59 *.gz|*.Z)
60 gunzip -f "${x}" || __helpers_die "gunzip failed"
61 - x=${x%.*}
62 - had_precompressed=1;;
63 + x=${x%.*};;
64 *.bz2)
65 bunzip2 -f "${x}" || __helpers_die "bunzip2 failed"
66 - x=${x%.bz2}
67 - had_precompressed=1;;
68 + x=${x%.bz2};;
69 *.lzma|*.xz)
70 unxz -f "${x}" || __helpers_die "unxz failed"
71 - x=${x%.*}
72 - had_precompressed=1;;
73 + x=${x%.*};;
74 esac
75
76 filtered_args+=( "$x" )
77 @@ -40,12 +36,6 @@ compress_file() {
78 [[ ${#filtered_args[@]} -eq 0 ]] && return 0
79 set -- "${filtered_args[@]}"
80
81 - if [[ ${had_precompressed} ]]; then
82 - eqawarn "One or more compressed files were found in docompress-ed directories."
83 - eqawarn "Please fix the ebuild not to install compressed files (manpages,"
84 - eqawarn "documentation) when automatic compression is used."
85 - fi
86 -
87 # If a compressed version of the file already exists, simply
88 # delete it so that the compressor doesn't whine (bzip2 will
89 # complain and skip, gzip will prompt for input)
90 --
91 2.19.0