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