Bug#520255: gnome-user-guide: too big -- 50 MB is too much
This is a version of localepurge that behaves like the previous version plus: - purges locale files under /usr/share/doc/kde/HTML - has undergone some cleanup - is faster. I do not currently plan to make more improvements. I suggest that this version replace the one currently distributed with the localepurge package. ===File /usr/sbin/localepurge=== #! /bin/bash # Deleting all locale files and localized man pages installed # on system which are *not* listed in /etc/locale.nopurge set -e NOPURGECONF=/etc/locale.nopurge # Do nothing and report why if no valid configuration file exists: if [ ! -f $NOPURGECONF ] then echo No $NOPURGECONF file present, exiting ... exit 0 else if fgrep --quiet --line-regexp NEEDSCONFIGFIRST $NOPURGECONF then echo echo You have to configure \localepurge\ with the command echo echo dpkg-reconfigure localepurge echo echo to make $0 actually start to function. echo echo Nothing to be done, exiting ... echo exit 0 fi fi ## Initialise variables # Make sure to exclude running under any locale other than C: export LANG=C if [ $1 = -debug ] || [ $1 = -d ] \ || [ $2 = -debug ] || [ $2 = -d ]; then set -x fi # Initialise local variables ((true = 1)) ((false = 0)) ((VERBOSE = false)) ((DONTBOTHERNEWLOCALE = false)) ((SHOWFREEDSPACE = false)) ((MANDELETE = false)) ((globaltot = 0)) if fgrep --quiet --line-regexp DONTBOTHERNEWLOCALE $NOPURGECONF; then ((DONTBOTHERNEWLOCALE = true)) fi if fgrep --quiet --line-regexp SHOWFREEDSPACE $NOPURGECONF; then ((SHOWFREEDSPACE = true)) fi if fgrep --quiet --line-regexp MANDELETE $NOPURGECONF; then ((MANDELETE = true)) fi if fgrep --quiet --line-regexp VERBOSE $NOPURGECONF \ || [ $1 = -verbose ] || [ $1 = -v ] \ || [ $2 = -verbose ] || [ $2 = -v ]; then ((VERBOSE = true)) fi ## Manage the list of locales # First update $LOCALELIST with newly introduced locales if wanted LOCALELIST=/var/cache/localepurge/localelist NEWLOCALELIST=$LOCALELIST-new ((VERBOSE)) echo localepurge: checking system for new locale ... for NEWLOCALE in $(cd /usr/share/locale; ls .) do if [ -d /usr/share/locale/$NEWLOCALE/LC_MESSAGES ]; then if [ ! $(grep -cx $NEWLOCALE $LOCALELIST) = 1 ]; then echo $NEWLOCALE $NEWLOCALELIST fi fi done if [ -f $NEWLOCALELIST ]; then if ((DONTBOTHERNEWLOCALE)); then mv $NEWLOCALELIST $NEWLOCALELIST.temp sort -u $NEWLOCALELIST.temp $LOCALELIST $NEWLOCALELIST mv $NEWLOCALELIST $LOCALELIST rm $NEWLOCALELIST.temp else mv $NEWLOCALELIST $NEWLOCALELIST.temp sort -u $NEWLOCALELIST.temp $NEWLOCALELIST rm $NEWLOCALELIST.temp fi fi if [ -f $NEWLOCALELIST ] [ $DONTBOTHERNEWLOCALE != yes ]; then echo Some new locales have appeared on your system: echo tr '\n' ' ' $NEWLOCALELIST echo echo echo They will not be touched until you reconfigure localepurge echo with the following command: echo echo dpkg-reconfigure localepurge echo fi ## Create a Bash extended globbing pattern used to identify ## superfluous locales: start by creating a pattern to match locales ## not to be purged, use it to remove good locales from the list of ## all locales and create a pattern matching superfluous locales. nopurge=$( set -o noglob; # Disable path expansion and use 'echo' # below to change newlines into spaces echo $(grep --invert-match --extended-regexp '^[ \t]*(#|$)' $NOPURGECONF) ) nopurgepat='@(C|'${nopurge// /|}')' shopt -s extglob# enable extended globbing to use $nopurgepat localelist=$(grep --invert-match --extended-regexp '^[ \t]*(#|$)' $LOCALELIST) superfluouslocalepat=$( echo -n '@(nonexistent_locale_placeholder' for l in $localelist; do if [[ $l != $nopurgepat ]]; then echo -n |$l; fi done echo -n ')' ) ## Define utility functions # Function for disk space calculation # Usage: get_used_space dirname if ! ((SHOWFREEDSPACE)); then function get_used_space () { echo 0; } else if fgrep --quiet --line-regexp QUICKNDIRTYCALC $NOPURGECONF; then function get_used_space () { [ -d $1 ] || return 1 # bail out if there's no such dir set - $(df -P $1); shift $(($# - 6)); echo $3 } else function get_used_space () { [ -d $1 ] || return 1 # bail out if there's no such dir set - $(du -ks $1); echo $1 } fi fi # If the first argument is a superfluous locale, removes the regular
Bug#520255: gnome-user-guide: too big -- 50 MB is too much
This is a partly rewritten version of localepurge. It is more modular and thus much more readable. Still needs modularisation and optimisation, but it is better than the previous version I sent. Still does not purge Kde files. I see that multilingual help files are under /usr/share/doc/kde/HTML, but I guess there are others. ===File /usr/sbin/localepurge=== #! /bin/bash # Deleting all locale files and localized man pages installed # on system which are *not* listed in /etc/locale.nopurge set -e # Do nothing and report why if no valid configuration file exists: if [ ! -f /etc/locale.nopurge ] then echo No /etc/locale.nopurge file present, exiting ... exit 0 else if fgrep --quiet --line-regexp NEEDSCONFIGFIRST /etc/locale.nopurge then echo echo You have to configure \localepurge\ with the command echo echo dpkg-reconfigure localepurge echo echo to make $0 actually start to function. echo echo Nothing to be done, exiting ... echo exit 0 fi fi # Make sure to exclude running under any locale other than C: export LANG=C # Initialise local variables VERBOSE= DONTBOTHERNEWLOCALE=disabled SHOWFREEDSPACE=disabled MANDELETE=disabled globaltot=0 if [ $1 = -debug ] || [ $1 = -d ] \ || [ $2 = -debug ] || [ $2 = -d ]; then set -x fi if fgrep --quiet --line-regexp SHOWFREEDSPACE /etc/locale.nopurge; then SHOWFREEDSPACE=enabled fi if fgrep --quiet --line-regexp DONTBOTHERNEWLOCALE /etc/locale.nopurge; then DONTBOTHERNEWLOCALE=enabled fi if fgrep --quiet --line-regexp MANDELETE /etc/locale.nopurge; then MANDELETE=enabled fi if fgrep --quiet --line-regexp VERBOSE /etc/locale.nopurge \ || [ $1 = -verbose ] || [ $1 = -v ] \ || [ $2 = -verbose ] || [ $2 = -v ]; then VERBOSE=-v fi # Define a function for disk space calculation # Usage: get_used_space dirname if [ $SHOWFREEDSPACE = disabled ]; then function get_used_space () { echo 0; } else if fgrep --quiet --line-regexp QUICKNDIRTYCALC /etc/locale.nopurge; then function get_used_space () { [ -d $1 ] || return 1 # bail out if there's no such dir set - $(df -P $1); shift $(($# - 6)); echo $3 } else function get_used_space () { [ -d $1 ] || return 1 # bail out if there's no such dir set - $(du -ks $1); echo $1 } fi fi # first update $LOCALELIST with newly introduced locales if wanted LOCALELIST=/var/cache/localepurge/localelist NEWLOCALELIST=$LOCALELIST-new if [ $VERBOSE ]; then echo localepurge: checking system for new locale ... fi for NEWLOCALE in $(cd /usr/share/locale; ls .) do if [ -d /usr/share/locale/$NEWLOCALE/LC_MESSAGES ]; then if [ ! $(grep -cx $NEWLOCALE $LOCALELIST) = 1 ]; then echo $NEWLOCALE $NEWLOCALELIST fi fi done if [ -f $NEWLOCALELIST ]; then if [ $DONTBOTHERNEWLOCALE = enabled ]; then mv $NEWLOCALELIST $NEWLOCALELIST.temp sort -u $NEWLOCALELIST.temp $LOCALELIST $NEWLOCALELIST mv $NEWLOCALELIST $LOCALELIST rm $NEWLOCALELIST.temp else mv $NEWLOCALELIST $NEWLOCALELIST.temp sort -u $NEWLOCALELIST.temp $NEWLOCALELIST rm $NEWLOCALELIST.temp fi fi if [ -f $NEWLOCALELIST ] [ $DONTBOTHERNEWLOCALE != enabled ]; then echo Some new locales have appeared on your system: echo tr '\n' ' ' $NEWLOCALELIST echo echo echo They will not be touched until you reconfigure localepurge echo with the following command: echo echo dpkg-reconfigure localepurge echo fi # Return value tells if the argument is a locale to be deleted # Needs optimisation function superfluous () { local locale=$1 [ $locale != C ] ! fgrep --quiet --line-regexp $locale /etc/locale.nopurge fgrep --quiet --line-regexp $locale $LOCALELIST } # Removes files given as arguments, after checking them # Needs optimisation function remove_files () { for file; do if [ -f $file ] || [ -h $file ]; then rm $VERBOSE $file fi done } # Removes files under dirs given as arguments, after checking them # Currently unused function remove_files_under () { find $@ -mindepth 1 -type f -o -type l | xargs echo rm $VERBOSE } # Compute space before removing files function spacebefore () { if [ $SHOWFREEDSPACE = enabled ]; then local dir=$1 before=$(get_used_space $dir) fi } # Compute space freed after removing files and updates global total function spaceafter () { if [ $SHOWFREEDSPACE = enabled ]; then local dir=$1 after=$(get_used_space $dir) ((tot = before - after)); ((globaltot += tot)) echo localepurge: Disk space freed in $dir: ${tot}KiB fi } # Getting rid of superfluous
Bug#205214: Bug#520255: gnome-user-guide: too big -- 50 MB is too much
I added omf purging to the localepurge script. It now deletes files under /usr/share/locale /usr/share/man /usr/share/gnome/help /usr/share/omf The script is vastly inefficient, and it would be easy to make it more efficient using bash pattern matching rather than grep. I can do that, if there is nothing more important. One thing to add is checking for Kde help, but I do not use Kde, so I do not know what to look for. One more thing: the script has always needed bash, so it should depend on it. I adjusted the #! line accordingly. This is a bug even in the current repository version. ===File /usr/sbin/localepurge=== #!/bin/bash # Deleting all locale files and localized man pages installed # on system which are *not* listed in /etc/locale.nopurge set -e # Do nothing and report why if no valid configuration file exists: if [ ! -f /etc/locale.nopurge ] then echo No /etc/locale.nopurge file present, exiting ... exit 0 else if [ $(grep -x ^NEEDSCONFIGFIRST /etc/locale.nopurge) ] then echo echo You have to configure \localepurge\ with the command echo echo dpkg-reconfigure localepurge echo echo to make $0 actually start to function. echo echo Nothing to be done, exiting ... echo exit 0 fi fi # Make sure to exclude running under any locale other than C: export LANG=C # Initialise local variables VERBOSE= DONTBOTHERNEWLOCALE=disabled SHOWFREEDSPACE=disabled mantot=0 localetot=0 gnometot=0 if [ $1 = -debug ] || [ $1 = -d ] \ || [ $2 = -debug ] || [ $2 = -d ]; then set -x fi if [ $(grep -x ^SHOWFREEDSPACE /etc/locale.nopurge) ]; then SHOWFREEDSPACE=enabled fi if [ $(grep -x ^DONTBOTHERNEWLOCALE /etc/locale.nopurge) ]; then DONTBOTHERNEWLOCALE=enabled fi if [ $(grep -x ^VERBOSE /etc/locale.nopurge) ] \ || [ $1 = -verbose ] || [ $1 = -v ] \ || [ $2 = -verbose ] || [ $2 = -v ]; then VERBOSE=-v fi # Define a function for disk space calculation: if [ $SHOWFREEDSPACE = disabled ]; then get_used_space() { echo 0; } else if [ $(grep -x ^QUICKNDIRTYCALC /etc/locale.nopurge) ]; then get_used_space() # Usage: get_used_space dirname { [ -d $1 ] || return 1 # bail out if there's no such dir set - $(df -P $1); shift $(($# - 6)); echo $3 } else get_used_space() # Usage: get_used_space dirname { [ -d $1 ] || return 1 # bail out if there's no such dir set - $(du -ks $1); echo $1 } fi fi # first update $LOCALELIST with newly introduced locales if wanted LOCALELIST=/var/cache/localepurge/localelist NEWLOCALELIST=$LOCALELIST-new if [ $VERBOSE ]; then echo localepurge: checking system for new locale ... fi for NEWLOCALE in $(cd /usr/share/locale; ls .) do if [ -d /usr/share/locale/$NEWLOCALE/LC_MESSAGES ]; then if [ ! $(grep -cx $NEWLOCALE $LOCALELIST) = 1 ]; then echo $NEWLOCALE $NEWLOCALELIST fi fi done if [ -f $NEWLOCALELIST ]; then if [ $DONTBOTHERNEWLOCALE = enabled ]; then mv $NEWLOCALELIST $NEWLOCALELIST.temp sort -u $NEWLOCALELIST.temp $LOCALELIST $NEWLOCALELIST mv $NEWLOCALELIST $LOCALELIST rm $NEWLOCALELIST.temp else mv $NEWLOCALELIST $NEWLOCALELIST.temp sort -u $NEWLOCALELIST.temp $NEWLOCALELIST rm $NEWLOCALELIST.temp fi fi if [ -f $NEWLOCALELIST ] [ ! $DONTBOTHERNEWLOCALE = enabled ]; then echo Some new locales have appeared on your system: echo tr '\n' ' ' $NEWLOCALELIST echo echo echo They will not be touched until you reconfigure localepurge echo with the following command: echo echo dpkg-reconfigure localepurge echo fi # Getting rid of superfluous locale files in LOCALEDIR LOCALEDIR=/usr/share/locale if [ -d $LOCALEDIR ]; then localebefore=$(get_used_space $LOCALEDIR) test $VERBOSE echo localepurge: processing locale files ... for LOCALE in $(cd $LOCALEDIR; echo *); do if [ ! $(grep -x ^$LOCALE /etc/locale.nopurge) ] [ $(grep -x ^$LOCALE $LOCALELIST) ] [ -d $LOCALEDIR/$LOCALE/LC_MESSAGES ]; then for file in $LOCALEDIR/$LOCALE/*/* $LOCALEDIR/$LOCALE/*.po; do if [ -f $file ] || [ -h $file ]; then /bin/rm $VERBOSE $file fi done fi done if [ $SHOWFREEDSPACE = enabled ]; then localeafter=$(get_used_space $LOCALEDIR) ((localetot = localebefore - localeafter)) echo localepurge: Disk space freed in $LOCALEDIR: ${localetot}KB fi fi # Getting rid of localized man pages in $MANPAGEDIR MANPAGEDIR=/usr/share/man if [ -d $MANPAGEDIR ] [ $(grep -x ^MANDELETE /etc/locale.nopurge) ]; then manbefore=$(get_used_space $MANPAGEDIR) test $VERBOSE echo
Bug#520255: gnome-user-guide: too big -- 50 MB is too much
I enhanced the localpurge script. Now it deletes .po files in /usr/share/locale, which were previously left alone, and deletes locale files under /usr/share/gnome/help. ===File /usr/sbin/localepurge=== #!/bin/sh # Deleting all locale files and localized man pages installed # on system which are *not* listed in /etc/locale.nopurge set -e # Do nothing and report why if no valid configuration file exists: if [ ! -f /etc/locale.nopurge ] then echo No /etc/locale.nopurge file present, exiting ... exit 0 else if [ $(grep -x ^NEEDSCONFIGFIRST /etc/locale.nopurge) ] then echo echo You have to configure \localepurge\ with the command echo echo dpkg-reconfigure localepurge echo echo to make $0 actually start to function. echo echo Nothing to be done, exiting ... echo exit 0 fi fi # Make sure to exclude running under any locale other than C: export LANG=C # Initialise local variables VERBOSE= DONTBOTHERNEWLOCALE=disabled SHOWFREEDSPACE=disabled mantot=0 localetot=0 gnometot=0 if [ $1 = -debug ] || [ $1 = -d ] \ || [ $2 = -debug ] || [ $2 = -d ]; then set -x fi if [ $(grep -x ^SHOWFREEDSPACE /etc/locale.nopurge) ]; then SHOWFREEDSPACE=enabled fi if [ $(grep -x ^DONTBOTHERNEWLOCALE /etc/locale.nopurge) ]; then DONTBOTHERNEWLOCALE=enabled fi if [ $(grep -x ^VERBOSE /etc/locale.nopurge) ] \ || [ $1 = -verbose ] || [ $1 = -v ] \ || [ $2 = -verbose ] || [ $2 = -v ]; then VERBOSE=-v fi # Define a function for disk space calculation: if [ $SHOWFREEDSPACE = disabled ]; then get_used_space() { echo 0; } else if [ $(grep -x ^QUICKNDIRTYCALC /etc/locale.nopurge) ]; then get_used_space() # Usage: get_used_space dirname { [ -d $1 ] || return 1 # bail out if there's no such dir set - $(df -P $1); shift $(($# - 6)); echo $3 } else get_used_space() # Usage: get_used_space dirname { [ -d $1 ] || return 1 # bail out if there's no such dir set - $(du -ks $1); echo $1 } fi fi # first update $LOCALELIST with newly introduced locales if wanted LOCALELIST=/var/cache/localepurge/localelist NEWLOCALELIST=$LOCALELIST-new if [ $VERBOSE ]; then echo localepurge: checking system for new locale ... fi for NEWLOCALE in $(cd /usr/share/locale; ls .) do if [ -d /usr/share/locale/$NEWLOCALE/LC_MESSAGES ]; then if [ ! $(grep -cx $NEWLOCALE $LOCALELIST) = 1 ]; then echo $NEWLOCALE $NEWLOCALELIST fi fi done if [ -f $NEWLOCALELIST ]; then if [ $DONTBOTHERNEWLOCALE = enabled ]; then mv $NEWLOCALELIST $NEWLOCALELIST.temp sort -u $NEWLOCALELIST.temp $LOCALELIST $NEWLOCALELIST mv $NEWLOCALELIST $LOCALELIST rm $NEWLOCALELIST.temp else mv $NEWLOCALELIST $NEWLOCALELIST.temp sort -u $NEWLOCALELIST.temp $NEWLOCALELIST rm $NEWLOCALELIST.temp fi fi if [ -f $NEWLOCALELIST ] [ ! $DONTBOTHERNEWLOCALE = enabled ]; then echo Some new locales have appeared on your system: echo tr '\n' ' ' $NEWLOCALELIST echo echo echo They will not be touched until you reconfigure localepurge echo with the following command: echo echo dpkg-reconfigure localepurge echo fi # Getting rid of superfluous locale files in LOCALEDIR LOCALEDIR=/usr/share/locale if [ -d $LOCALEDIR ]; then localebefore=$(get_used_space $LOCALEDIR) test $VERBOSE echo localepurge: processing locale files ... for LOCALE in $(cd $LOCALEDIR; echo *); do if [ ! $(grep -x ^$LOCALE /etc/locale.nopurge) ] [ $(grep -x ^$LOCALE $LOCALELIST) ] [ -d $LOCALEDIR/$LOCALE/LC_MESSAGES ]; then for file in $LOCALEDIR/$LOCALE/*/* $LOCALEDIR/$LOCALE/*.po; do if [ -f $file ] || [ -h $file ]; then /bin/rm $VERBOSE $file fi done fi done if [ $SHOWFREEDSPACE = enabled ]; then localeafter=$(get_used_space $LOCALEDIR) ((localetot = localebefore - localeafter)) echo localepurge: Disk space freed in $LOCALEDIR: ${localetot}KB fi fi # Getting rid of localized man pages in $MANPAGEDIR MANPAGEDIR=/usr/share/man if [ -d $MANPAGEDIR ] [ $(grep -x ^MANDELETE /etc/locale.nopurge) ]; then manbefore=$(get_used_space $MANPAGEDIR) test $VERBOSE echo localepurge: processing man pages ... for LOCALE in $(ls --ignore=man[1-9]* $MANPAGEDIR); do if [ ! $(grep -x ^$LOCALE /etc/locale.nopurge) ] [ $(grep -x ^$LOCALE $LOCALELIST) ] [ -d $MANPAGEDIR/$LOCALE ]; then for file in $MANPAGEDIR/$LOCALE/man[1-9]/*; do if [ -f $file ] || [ -h $file ]; then /bin/rm $VERBOSE $file fi done fi
Bug#520255: gnome-user-guide: too big -- 50 MB is too much
Le lundi 06 avril 2009 à 14:48 +0200, Francesco Potorti` a écrit : I enhanced the localpurge script. Now it deletes .po files in /usr/share/locale, which were previously left alone, and deletes locale files under /usr/share/gnome/help. You shouldn’t forget /usr/share/omf to avoid inconsistencies. See my recommendations in #205214, and please send any patches to that bug. -- .''`. Debian 5.0 Lenny has been released! : :' : `. `' Last night, Darth Vader came down from planet Vulcan and told `-me that if you don't install Lenny, he'd melt your brain. signature.asc Description: Ceci est une partie de message numériquement signée