# HG changeset patch # User Aleksej Bobylev # Date 1485447016 -7200 # Node ID 111b6212516cd42117a2fd3498b7c981b764f448 # Parent 1fb0744972f73ea0c249a32b6035421cce9fc772 modules/compressor: recompress *.gz files diff -r 1fb0744972f7 -r 111b6212516c doc/cookopts.txt --- a/doc/cookopts.txt Thu Jan 26 11:03:27 2017 +0200 +++ b/doc/cookopts.txt Thu Jan 26 18:10:16 2017 +0200 @@ -64,6 +64,12 @@ be left "as is"). Please note that these files may be installed in a compressed format. +!gz + Default action is to recompress all *.gz files (excluding man pages) with + the better compression ratio. + The presence of this option overrides the default action (all *.gzip files + will be left "as is"). + !pngz Default action is to compress all PNG images. Image compression allows you to save some space, but it takes a lot of time. diff -r 1fb0744972f7 -r 111b6212516c modules/compressor --- a/modules/compressor Thu Jan 26 11:03:27 2017 +0200 +++ b/modules/compressor Thu Jan 26 18:10:16 2017 +0200 @@ -73,6 +73,7 @@ mo1) find $install -type f -name '*.mo' -exec ls -l \{\} \; ;; loc) find $install/usr/share/i18n/locales -type f -exec ls -l \{\} \; ;; mo2) find $fs/usr/share/locale -type f -name '*.mo' -exec ls -l \{\} \; ;; + gz) find $install -type f -name '*.gz' ! -path '*/share/man/*' -exec ls -l \{\} \; ;; esac | awk '{s+=$5}END{print s}' } @@ -145,6 +146,30 @@ } +# Function to recompress all gzip archives +# Recompressing can be disabled with COOKOPTS="!gz" + +recompress_gz() { + time0=$(date +%s) + [ "${COOKOPTS/!gz/}" != "$COOKOPTS" ] && return + size0=$(sizes gz); [ -z "$size0" ] && return + + tazpkg -gi advancecomp --quiet --cookmode + + action 'Recompressing gzip files...' + + # Recompress with advdef + for i in $(find $install -type f -name '*.gz' ! -path '*/share/man/*'); do + if ! cached_path=$(query_cache gz "$i"); then + advdef -z4q "$i" + store_cache "$cached_path" "$i" + fi + done + + comp_summary "$time0" "$size0" "$(sizes gz)" +} + + # Function used after compile_rules() to compress all png images # Compressing can be disabled with COOKOPTS="!pngz" @@ -551,6 +576,7 @@ case "$ARCH" in arm*) ;; *) + recompress_gz compress_manpages compress_png compress_svg