# HG changeset patch # User Aleksej Bobylev # Date 1479338910 -7200 # Node ID d8bac8bb4eab0d9508ba395284312eaa334c7cfb # Parent 275599c3423c90a03a24937ece2eb73c9f3558ab cook: strip unsupported translations. Rewrite the doc in cookopts.txt. diff -r 275599c3423c -r d8bac8bb4eab cook --- a/cook Tue Nov 15 03:40:41 2016 +0200 +++ b/cook Thu Nov 17 01:28:30 2016 +0200 @@ -483,6 +483,30 @@ } +# Get list of supported locales... + +get_supported_locales() { + local lpc='/slitaz-i18n/stuff/locale-pack.conf' LOCALE_PACK + if [ -e "$WOK$lpc" ]; then + # ... from package in the local wok + . "$WOK$lpc" + else + # ... from Hg + temp_conf=$(mktemp) + wget -q -O $temp_conf -T 10 "http://hg.slitaz.org/wok/raw-file/tip$lpc" + if [ -s $temp_conf ]; then + . $temp_conf + else + # Give up and use hardcoded list + LOCALE_PACK="ar ca cs da de el en es fi fr hr hu id is it ja nb nl nn pl pt \ + pt_BR ro ru sl sv tr uk zh_CN zh_TW" + fi + rm $temp_conf + fi + echo $LOCALE_PACK +} + + # Fix common errors and warnings in the .desktop files # Fixing can be disabled with COOKOPTS="!fixdesktops" @@ -490,10 +514,18 @@ [ "${COOKOPTS/!fixdesktops/}" != "$COOKOPTS" ] && return [ -z "$(find $install -type f -name '*.desktop')" ] && return + local size0=$(find $install -type f -name '*.desktop' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}') + local time0=$(date +%s) + if [ -n "$QA" -a -z "$(which desktop-file-validate)" ]; then tazpkg -gi desktop-file-utils-extra --quiet fi + # The variable $LOCALE is set in cook.conf and may be overridden in the receipt. + # Default value is "" (empty). That means for us that we'll use the full + # list of supported locales here. + [ -z "$LOCALE" ] && LOCALE=$(get_supported_locales) + for desktop in $(find $install -type f -name '*.desktop'); do cp "$desktop" "$desktop.orig" @@ -503,6 +535,14 @@ # Fix common errors in .desktop file fix-desktop-file "$desktop" + # Strip unsupported locales from .desktop file + [ "${COOKOPTS/!i18nz/}" == "$COOKOPTS" ] && + sdft "$desktop" -i -k "$LOCALE" + + # Extra-strip + [ "${COOKOPTS/!extradesktops/}" == "$COOKOPTS" ] && + sdft "$desktop" -i -g -x -tf -r 'Keywords*' -o + if [ -n "$QA" ]; then # Check the rest of errors, warnings and tips _ 'QA: Checking %s...' "$(basename $desktop)" @@ -513,6 +553,10 @@ rm "$desktop.orig" done + + local size1=$(find $install -type f -name '*.desktop' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}') + local time1=$(date +%s) + comp_summary "$time0" "$time1" "$size0" "$size1" } @@ -575,6 +619,44 @@ } +# Strip unsupported locales (.mo files) + +strip_mo_i18n() { + [ "${COOKOPTS/!i18nz/}" != "$COOKOPTS" ] && return + + [ -z "$(find $fs -type f -name '*.mo')" ] && return + + action 'Stripping translations files...' + local size0=$(find $fs -type f -name '*.mo' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}') + local time0=$(date +%s) + + # The variable $LOCALE is set in cook.conf and may be overridden in the receipt. + # Default value is "" (empty). That means for us that we'll use the full + # list of supported locales here. + [ -z "$LOCALE" ] && LOCALE=$(get_supported_locales) + + # Existing locales + elocales=" $(ls -1 "$fs/usr/share/locale" | tr '\n' ' ') " + + # Thin out the list of existing locales. At the end there will be only locales that need + # to delete (and the garbage like '_AU', _US', '_BR' leaving from 'en_AU', 'en_US', 'pt_BR'...) + for keep_locale in $LOCALE; do + elocales=${elocales//$keep_locale} + done + + # Remove the unsupported locales + for rem_locale in $elocales; do + [ -d "$fs/usr/share/locale/$rem_locale" ] && + rm -r "$fs/usr/share/locale/$rem_locale" + done + + local size1=$(find $fs -type f -name '*.mo' -exec ls -l \{\} \; | awk '{s+=$5}END{print s}') + local time1=$(date +%s) + status + comp_summary "$time0" "$time1" "$size0" "$size1" +} + + # Update installed.cook.diff update_installed_cook_diff() { @@ -1042,6 +1124,7 @@ # Strip and stuff files. strip_package + strip_mo_i18n # Create files.list with redirecting find output. action 'Creating the list of files...' diff -r 275599c3423c -r d8bac8bb4eab doc/cookopts.txt --- a/doc/cookopts.txt Tue Nov 15 03:40:41 2016 +0200 +++ b/doc/cookopts.txt Thu Nov 17 01:28:30 2016 +0200 @@ -10,46 +10,95 @@ Currently, the following options are recognized: !pixmaps - Don't copy icons from a /usr/share/pixmaps folder as well as from stuff - folder (the same action that made obsolete option `GENERIC_PIXMAPS="no"`). + Default action is to copy icons from a /usr/share/pixmaps folder as well as + from stuff folder (the same action that made obsolete option + `GENERIC_PIXMAPS="no"`). + The presence of this option overrides the default action: files will not be + automatically copied. !menus - Don't copy desktop files from a /usr/share/applications folder (the same - action that made obsolete option `GENERIC_MENUS="no"`). + Default action is to copy desktop files from a /usr/share/applications + folder (the same action that made obsolete option `GENERIC_MENUS="no"`). + The presence of this option overrides the default action: files will not be + automatically copied. !fixdesktops - Don't fix common errors and warnings in the .desktop files. + Default action is to fix common errors and warnings in the .desktop files. + The presence of this option overrides the default action: .desktop files + will not be changed. + +!i18nz + 1. Default action is to delete locales that are not currently supported by + the SliTaz while processing desktop files. + The presence of this option overrides the default action: .desktop files + will contain the original set of locales. + Please note, this option does not have any action if the `!fixdesktops` + option provided: desktop files in any way not change. + 2. Default action is to keep only supported translations provided by the + *.mo files. + The presence of this option overrides the default action: all existing *.mo + files will remain. + Please note, you can add all translations to the package, for example, using + command: `cook_copy_files *.mo`, and then by default only supported locales + will be left. + +!extradesktops + Default action is to remove extra information from the desktop files: such + entries as 'GenericName', 'X-GNOME-FullName' (all X-* are exposed), + 'Terminal=false', Keywords, other sections. This extra information just not + supported in the current (LXDE) environment. + The presence of this option overrides the default action: extra information + will not be removed from the .desktop files. !strip - Don't strip executable files, shared and static libraries, as well as remove - Python (*.pyc and *.pyo) and Perl (perllocal.pod and .packlist) files. + Default action is to strip executable files, shared and static libraries, + as well as remove Python (*.pyc and *.pyo) and Perl (perllocal.pod and + .packlist) files. + The presence of this option overrides the default action: executable files + and libraries will not be stripped, and Python and Perl files all will be + left. !manz - Don't compress all man pages. + Default action is to compress all man pages. + The presence of this option overrides the default action: all man pages will + be left "as is". Please note that these files may be installed in compressed + form. !pngz - Don't compress all png images. Image compression allows you to save some - space, but it takes a lot of time. + Default action is to compress all PNG images. Image compression allows you + to save some space, but it takes a lot of time. + The presence of this option overrides the default action: all PNG images + will be left "as is". !pngquant - Don't use `pngquant` to compress png images. Note, `pngquant` produces - indexed images (max 256 colors) which can be inappropriate in some cases: - a few programs (such as SLiM) will not recognize this compressed PNG file - format. + Default action is to use `pngquant` while compressing PNG images. Please + note, `pngquant` produces indexed images (max 256 colors) which can be + inappropriate in some cases: a few programs (such as SLiM) will not + recognize this PNG file format. + The presence of this option overrides the default action: `pngquant` will + not be used. !optipng - Don't use `optipng` to compress png images. Note, `optipng` is lossless png - compressor. Using `pngquant` and `optipng` in conjunction allows to save - more space. + Default action is to use `optipng` to compress PNG images. Please note, + `optipng` is lossless PNG compressor. Using `pngquant` and `optipng` in + conjunction allows to save more space. + The presence of this option overrides the default action: `optipng` will not + be used. op0 to op8 - Use specified `optipng` optimization level. The higher the level, the slower - compression. Note, this option does not have an exclamation mark, because it - means "don't" and here is "do" otherwise. + Default action is to use opimization level 2 while processing PNG images by + `optipng`. Using this option you can set desired `optipng` optimization + level. The higher the level, the slower compression and the smaller file + size. Please note that this option has no exclamation mark, because it means + "don't do", and here, on the contrary, "to do". !svgz - Don't compress all svg images. + Default action is to compress all SVG images. + The presence of this option overrides the default action: all SVG images + will be left "as is". !uiz - Don't compress Glade UI files. Compression means the removal of - insignificant spaces and comments. + Default action is to compress Glade UI files. Compression means the removal + of insignificant spaces and comments. + The presence of this option overrides the default action: all *.ui and + *.glade files will be left "as is".