1 |
The vast majority of these small files do not compress better than |
2 |
their inputs, and they're just .so redirection. Omit compression |
3 |
on them to save disk and cpu and speed things up. |
4 |
|
5 |
URL: http://bugs.gentoo.org/169260 |
6 |
Signed-off-by: Mike Frysinger <vapier@g.o> |
7 |
--- |
8 |
v2 |
9 |
- fix printf thinko |
10 |
|
11 |
bin/ebuild-helpers/ecompressdir | 33 ++++++++++++++++++++++++++------- |
12 |
bin/ebuild-helpers/prepman | 5 ++++- |
13 |
2 files changed, 30 insertions(+), 8 deletions(-) |
14 |
|
15 |
diff --git a/bin/ebuild-helpers/ecompressdir b/bin/ebuild-helpers/ecompressdir |
16 |
index 75f3e3a..0f05c27 100755 |
17 |
--- a/bin/ebuild-helpers/ecompressdir |
18 |
+++ b/bin/ebuild-helpers/ecompressdir |
19 |
@@ -13,7 +13,9 @@ if ! ___eapi_has_prefix_variables; then |
20 |
ED=${D} EPREFIX= |
21 |
fi |
22 |
|
23 |
-case $1 in |
24 |
+SIZE_LIMIT='' |
25 |
+while [[ $# -gt 0 ]] ; do |
26 |
+ case $1 in |
27 |
--ignore) |
28 |
shift |
29 |
for skip in "$@" ; do |
30 |
@@ -28,7 +30,8 @@ case $1 in |
31 |
set -- "${@/#/${ED}}" |
32 |
ret=0 |
33 |
for x in "$@" ; do |
34 |
- >> "$x" |
35 |
+ # Stash the limit in the .dir file so we can reload it later. |
36 |
+ printf "${SIZE_LIMIT}" > "${x}" |
37 |
((ret|=$?)) |
38 |
done |
39 |
[[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed" |
40 |
@@ -42,29 +45,44 @@ case $1 in |
41 |
find "${ED}" -name '*.ecompress.skip' -print0 | ${XARGS} -0 rm -f |
42 |
exit 0 |
43 |
;; |
44 |
+ --limit) |
45 |
+ SIZE_LIMIT=$2 |
46 |
+ shift |
47 |
+ ;; |
48 |
--*) |
49 |
__helpers_die "${0##*/}: unknown arguments '$*'" |
50 |
exit 1 |
51 |
;; |
52 |
-esac |
53 |
+ *) |
54 |
+ break |
55 |
+ ;; |
56 |
+ esac |
57 |
+ shift |
58 |
+done |
59 |
|
60 |
# figure out the new suffix |
61 |
suffix=$(ecompress --suffix) |
62 |
|
63 |
-# funk_up_dir(action, suffix, binary) |
64 |
+# funk_up_dir(action, suffix, binary, [size_limit]) |
65 |
# - action: compress or decompress |
66 |
# - suffix: the compression suffix to work with |
67 |
# - binary: the program to execute that'll compress/decompress |
68 |
+# - size_limit: if compressing, skip files smaller than this |
69 |
# The directory we act on is implied in the ${dir} variable |
70 |
funk_up_dir() { |
71 |
- local act=$1 suffix=$2 binary=$3 |
72 |
+ local act=$1 suffix=$2 binary=$3 size_limit=$4 |
73 |
|
74 |
local negate="" |
75 |
[[ ${act} == "compress" ]] && negate="!" |
76 |
|
77 |
local ret=0 |
78 |
# first we act on all the files |
79 |
- find "${dir}" -type f ${negate} -iname '*'${suffix} -print0 | ${XARGS} -0 ${binary} |
80 |
+ local args=( |
81 |
+ -type f |
82 |
+ ${negate} -iname "*${suffix}" |
83 |
+ ) |
84 |
+ [[ -n ${size_limit} ]] && args+=( -size "+${size_limit}c" ) |
85 |
+ find "${dir}" "${args[@]}" -print0 | ${XARGS} -0 ${binary} |
86 |
((ret|=$?)) |
87 |
|
88 |
while read -r -d $'\0' brokenlink ; do |
89 |
@@ -152,6 +170,7 @@ for dir in "$@" ; do |
90 |
|
91 |
# since we've been requested to compress the whole dir, |
92 |
# delete any individual queued requests |
93 |
+ size_limit=${SIZE_LIMIT:-$(<"${actual_dir}.ecompress.dir")} |
94 |
rm -f "${actual_dir}.ecompress.dir" |
95 |
find "${dir}" -type f -name '*.ecompress.file' -print0 | ${XARGS} -0 rm -f |
96 |
|
97 |
@@ -179,7 +198,7 @@ for dir in "$@" ; do |
98 |
# now lets do our work |
99 |
if [[ -n ${suffix} ]] ; then |
100 |
__vecho "${0##*/}: $(ecompress --bin) /${actual_dir#${ED}}" |
101 |
- funk_up_dir "compress" "${suffix}" "ecompress" |
102 |
+ funk_up_dir "compress" "${suffix}" "ecompress" "${size_limit}" |
103 |
: $(( ret |= $? )) |
104 |
fi |
105 |
|
106 |
diff --git a/bin/ebuild-helpers/prepman b/bin/ebuild-helpers/prepman |
107 |
index 55a9483..fb5dcb4 100755 |
108 |
--- a/bin/ebuild-helpers/prepman |
109 |
+++ b/bin/ebuild-helpers/prepman |
110 |
@@ -2,6 +2,9 @@ |
111 |
# Copyright 1999-2012 Gentoo Foundation |
112 |
# Distributed under the terms of the GNU General Public License v2 |
113 |
|
114 |
+# Do not compress man pages which are smaller than this (in bytes). #169260 |
115 |
+SIZE_LIMIT='128' |
116 |
+ |
117 |
source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh |
118 |
|
119 |
if ! ___eapi_has_prefix_variables; then |
120 |
@@ -31,6 +34,6 @@ for subdir in "${mandir}"/man* "${mandir}"/*/man* ; do |
121 |
[[ -d ${subdir} ]] && really_is_mandir=1 && break |
122 |
done |
123 |
|
124 |
-[[ ${really_is_mandir} == 1 ]] && exec ecompressdir --queue "${mandir#${ED}}" |
125 |
+[[ ${really_is_mandir} == 1 ]] && exec ecompressdir --limit ${SIZE_LIMIT} --queue "${mandir#${ED}}" |
126 |
|
127 |
exit 0 |
128 |
-- |
129 |
1.8.1.2 |