cookutils rev 836
cook: add compress_ui()
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Mon Nov 14 16:58:35 2016 +0200 (2016-11-14) |
parents | cb0d015fce20 |
children | 275599c3423c |
files | cook doc/cookopts.txt |
line diff
1.1 --- a/cook Mon Nov 14 09:12:09 2016 +0100 1.2 +++ b/cook Mon Nov 14 16:58:35 2016 +0200 1.3 @@ -373,7 +373,7 @@ 1.4 [ -d $WOK/$pkg/install ] && prod=$(du -sh $WOK/$pkg/install | awk '{print $1}' 2>/dev/null) 1.5 [ -d $WOK/$pkg/source ] && srcdir=$(du -sh $WOK/$pkg/source | awk '{print $1}' 2>/dev/null) 1.6 fs=$(du -sh $WOK/$pkg/taz/* | awk '{print $1}') 1.7 - size=$(du -sh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $1}') 1.8 + size=$(ls -lh $PKGS/$pkg-${VERSION}*.tazpkg | awk '{print $5}') 1.9 files=$(cat $WOK/$pkg/taz/$pkg-*/files.list | wc -l) 1.10 [ -n "$TARBALL" ] && srcsize=$(du -sh $SRC/$TARBALL | awk '{print $1}') 1.11 1.12 @@ -388,7 +388,6 @@ 1.13 _ 'Packed : %s' "$fs" 1.14 _ 'Compressed : %s' "$size" 1.15 _ 'Files : %s' "$files" 1.16 - # L10n: 's' is for seconds (cooking time) 1.17 _ 'Cook time : %s' "$(disp_time "$time")" 1.18 _ 'Cook date : %s' "$(date "$(_ '+%%F %%R')")" 1.19 _ 'Host arch : %s' "$ARCH" 1.20 @@ -724,6 +723,34 @@ 1.21 } 1.22 1.23 1.24 +# Function used after compile_rules() to shrink all *.ui and *.glade files: 1.25 +# remove insignificant spaces and comments 1.26 +# Compressing can be disabled with COOKOPTS="!uiz" 1.27 + 1.28 +compress_ui() { 1.29 + [ "${COOKOPTS/!uiz/}" != "$COOKOPTS" ] && return 1.30 + case "$ARCH" in 1.31 + arm*) return;; # While SliTaz-arm miss `xmlstarlet` 1.32 + esac 1.33 + [ -z "$(find $install -type f \( -name '*.ui' -o -name '*.glade' \) )" ] && return 1.34 + 1.35 + action 'Compressing ui files...' 1.36 + local size0=$(find $install -type f \( -name '*.ui' -o -name '*.glade' \) -exec ls -l \{\} \; | awk '{s+=$5}END{print s}') 1.37 + local time0=$(date +%s) 1.38 + tazpkg -gi xmlstarlet --quiet 1.39 + temp_ui="$(mktemp)" 1.40 + for ui in $(find $install -type f \( -name '*.ui' -o -name '*.glade' \) ); do 1.41 + xmlstarlet c14n --without-comments "$ui" | xmlstarlet sel -B -t -c '*' > "$temp_ui" 1.42 + cat "$temp_ui" > "$ui" 1.43 + done 1.44 + local size1=$(find $install -type f \( -name '*.ui' -o -name '*.glade' \) -exec ls -l \{\} \; | awk '{s+=$5}END{print s}') 1.45 + local time1=$(date +%s) 1.46 + status 1.47 + comp_summary "$time0" "$time1" "$size0" "$size1" 1.48 + rm "$temp_ui" 1.49 +} 1.50 + 1.51 + 1.52 # The main cook function. 1.53 1.54 cookit() { 1.55 @@ -942,6 +969,7 @@ 1.56 compress_manpages 1.57 cook_compress_png 1.58 cook_compress_svg 1.59 + compress_ui 1.60 footer 1.61 1.62 # Execute testsuite.
2.1 --- a/doc/cookopts.txt Mon Nov 14 09:12:09 2016 +0100 2.2 +++ b/doc/cookopts.txt Mon Nov 14 16:58:35 2016 +0200 2.3 @@ -49,3 +49,7 @@ 2.4 2.5 !svgz 2.6 Don't compress all svg images. 2.7 + 2.8 +!uiz 2.9 + Don't compress Glade UI files. Compression means the removal of 2.10 + insignificant spaces and comments.