cookutils rev 954

cook: remove package in taz/ is package not needed; modules/compressor: recompress *.zip files (for LibreOffice).
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Aug 02 18:44:51 2017 +0300 (2017-08-02)
parents 160d8c595c75
children ba9972ca7cae
files cook doc/cookopts.txt modules/compressor
line diff
     1.1 --- a/cook	Tue Aug 01 00:39:36 2017 +0300
     1.2 +++ b/cook	Wed Aug 02 18:44:51 2017 +0300
     1.3 @@ -1106,7 +1106,11 @@
     1.4  			rm -f "$PKGS/$old_file"
     1.5  			status
     1.6  		fi
     1.7 +		# package changed, substitute old package by new
     1.8  		mv -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg $PKGS
     1.9 +	else
    1.10 +		# package not changed, remove new package
    1.11 +		rm -f $pkgdir/taz/$PACKAGE-$VERSION$EXTRAVERSION.tazpkg
    1.12  	fi
    1.13  
    1.14  	sed -i "/^${pkg}$/d" $broken
     2.1 --- a/doc/cookopts.txt	Tue Aug 01 00:39:36 2017 +0300
     2.2 +++ b/doc/cookopts.txt	Wed Aug 02 18:44:51 2017 +0300
     2.3 @@ -83,7 +83,13 @@
     2.4  !gz
     2.5      Default action is to recompress all *.gz files (excluding man pages) with
     2.6      the better compression ratio.
     2.7 -    The presence of this option overrides the default action (all *.gzip files
     2.8 +    The presence of this option overrides the default action (all *.gz files
     2.9 +    will be left "as is").
    2.10 +
    2.11 +!zip
    2.12 +    Default action is to recompress all *.zip files with the better compression
    2.13 +    ratio.
    2.14 +    The presence of this option overrides the default action (all *.zip files
    2.15      will be left "as is").
    2.16  
    2.17  !pngz
     3.1 --- a/modules/compressor	Tue Aug 01 00:39:36 2017 +0300
     3.2 +++ b/modules/compressor	Wed Aug 02 18:44:51 2017 +0300
     3.3 @@ -82,6 +82,7 @@
     3.4  		loc) find $install/usr/share/i18n/locales -type f                                       -exec ls -l \{\} \; ;;
     3.5  		mo2) find $fs/usr/share/locale            -type f -name '*.mo'                          -exec ls -l \{\} \; ;;
     3.6  		gz)  find $install                        -type f -name '*.gz' ! -path '*/share/man/*'  -exec ls -l \{\} \; ;;
     3.7 +		zip) find $install                        -type f -name '*.zip'                         -exec ls -l \{\} \; ;;
     3.8  		str) find $fs -type f \( -name '*.so*' -o -name '*.a' -o -name '*.pyc' -o -name '*.pyo' \
     3.9  				-o -name '.packlist' -o -name '*.pm' -o -name '*.pl' -o -name '*.pod' \) -exec ls -l \{\} \; ;;
    3.10  	esac | awk '{s+=$5}END{print s}'
    3.11 @@ -182,6 +183,31 @@
    3.12  }
    3.13  
    3.14  
    3.15 +# Function to recompress all zip archives
    3.16 +# Recompressing can be disabled with COOKOPTS="!zip"
    3.17 +
    3.18 +recompress_zip() {
    3.19 +	time0=$(get_time)
    3.20 +	[ "${COOKOPTS/!zip/}" != "$COOKOPTS" ] && return
    3.21 +	size0=$(sizes zip); [ -z "$size0" ] && return
    3.22 +
    3.23 +	tpi advancecomp-static
    3.24 +
    3.25 +	action 'Recompressing zip files...'
    3.26 +
    3.27 +	# Recompress with advzip
    3.28 +	IFS=$'\n'
    3.29 +	for i in $(find $install -type f -name '*.zip'); do
    3.30 +		if ! cached_path=$(query_cache zip "$i"); then
    3.31 +			advzip -z3qk "$i"	# -4 is more than 2 orders slower
    3.32 +			store_cache "$cached_path" "$i"
    3.33 +		fi
    3.34 +	done
    3.35 +
    3.36 +	comp_summary "$time0" "$size0" "$(sizes zip)"
    3.37 +}
    3.38 +
    3.39 +
    3.40  # Function used after compile_rules() to compress all png images
    3.41  # Compressing can be disabled with COOKOPTS="!pngz"
    3.42  
    3.43 @@ -605,6 +631,7 @@
    3.44  			arm*) ;;
    3.45  			*)
    3.46  				recompress_gz
    3.47 +				recompress_zip
    3.48  				compress_manpages
    3.49  				compress_png
    3.50  				compress_svg