cookutils rev 872
modules/compressor: recompress *.gz files
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Thu Jan 26 18:10:16 2017 +0200 (2017-01-26) |
parents | 1fb0744972f7 |
children | f816ea3e8dcc |
files | doc/cookopts.txt modules/compressor |
line diff
1.1 --- a/doc/cookopts.txt Thu Jan 26 11:03:27 2017 +0200 1.2 +++ b/doc/cookopts.txt Thu Jan 26 18:10:16 2017 +0200 1.3 @@ -64,6 +64,12 @@ 1.4 be left "as is"). Please note that these files may be installed in a 1.5 compressed format. 1.6 1.7 +!gz 1.8 + Default action is to recompress all *.gz files (excluding man pages) with 1.9 + the better compression ratio. 1.10 + The presence of this option overrides the default action (all *.gzip files 1.11 + will be left "as is"). 1.12 + 1.13 !pngz 1.14 Default action is to compress all PNG images. Image compression allows you 1.15 to save some space, but it takes a lot of time.
2.1 --- a/modules/compressor Thu Jan 26 11:03:27 2017 +0200 2.2 +++ b/modules/compressor Thu Jan 26 18:10:16 2017 +0200 2.3 @@ -73,6 +73,7 @@ 2.4 mo1) find $install -type f -name '*.mo' -exec ls -l \{\} \; ;; 2.5 loc) find $install/usr/share/i18n/locales -type f -exec ls -l \{\} \; ;; 2.6 mo2) find $fs/usr/share/locale -type f -name '*.mo' -exec ls -l \{\} \; ;; 2.7 + gz) find $install -type f -name '*.gz' ! -path '*/share/man/*' -exec ls -l \{\} \; ;; 2.8 esac | awk '{s+=$5}END{print s}' 2.9 } 2.10 2.11 @@ -145,6 +146,30 @@ 2.12 } 2.13 2.14 2.15 +# Function to recompress all gzip archives 2.16 +# Recompressing can be disabled with COOKOPTS="!gz" 2.17 + 2.18 +recompress_gz() { 2.19 + time0=$(date +%s) 2.20 + [ "${COOKOPTS/!gz/}" != "$COOKOPTS" ] && return 2.21 + size0=$(sizes gz); [ -z "$size0" ] && return 2.22 + 2.23 + tazpkg -gi advancecomp --quiet --cookmode 2.24 + 2.25 + action 'Recompressing gzip files...' 2.26 + 2.27 + # Recompress with advdef 2.28 + for i in $(find $install -type f -name '*.gz' ! -path '*/share/man/*'); do 2.29 + if ! cached_path=$(query_cache gz "$i"); then 2.30 + advdef -z4q "$i" 2.31 + store_cache "$cached_path" "$i" 2.32 + fi 2.33 + done 2.34 + 2.35 + comp_summary "$time0" "$size0" "$(sizes gz)" 2.36 +} 2.37 + 2.38 + 2.39 # Function used after compile_rules() to compress all png images 2.40 # Compressing can be disabled with COOKOPTS="!pngz" 2.41 2.42 @@ -551,6 +576,7 @@ 2.43 case "$ARCH" in 2.44 arm*) ;; 2.45 *) 2.46 + recompress_gz 2.47 compress_manpages 2.48 compress_png 2.49 compress_svg