Lines 8-13
Link Here
|
8 |
LOCALEDIRS="/usr/share/locale /usr/local/share/locale /usr/kde/?.?/share/locale /opt/sun-jdk-*/jre/lib/locale /opt/sun-jre-bin-*/lib/locale /usr/lib/locale" |
8 |
LOCALEDIRS="/usr/share/locale /usr/local/share/locale /usr/kde/?.?/share/locale /opt/sun-jdk-*/jre/lib/locale /opt/sun-jre-bin-*/lib/locale /usr/lib/locale" |
9 |
MANPAGEDIRS="/usr/share/man /usr/man /usr/local/share/man /usr/kde/?.?/share/man /usr/kde/?.?/man /opt/sun-jdk-*/man /opt/sun-jre-bin-*/man" |
9 |
MANPAGEDIRS="/usr/share/man /usr/man /usr/local/share/man /usr/kde/?.?/share/man /usr/kde/?.?/man /opt/sun-jdk-*/man /opt/sun-jre-bin-*/man" |
10 |
LOCALELIST="/var/cache/localepurge/localelist" |
10 |
LOCALELIST="/var/cache/localepurge/localelist" |
|
|
11 |
CONFIGFILE="/etc/locale.nopurge" |
11 |
VERSION="0.5" |
12 |
VERSION="0.5" |
12 |
|
13 |
|
13 |
LOCALETOTAL=0 |
14 |
LOCALETOTAL=0 |
Lines 40-46
Link Here
|
40 |
echo "${HILITE}localepurge${NORMAL} for ${BOLD}Gentoo Linux${NORMAL} ${BRACKET}[${NORMAL} ${GOOD}${VERSION}${NORMAL} ${BRACKET}]${NORMAL}" |
41 |
echo "${HILITE}localepurge${NORMAL} for ${BOLD}Gentoo Linux${NORMAL} ${BRACKET}[${NORMAL} ${GOOD}${VERSION}${NORMAL} ${BRACKET}]${NORMAL}" |
41 |
echo -e " " "by bass@gentoo.org" |
42 |
echo -e " " "by bass@gentoo.org" |
42 |
echo |
43 |
echo |
43 |
einfo "Remember that you must edit /etc/locale.nopurge" |
44 |
einfo "Remember that you must edit ${CONFIGFILE}" |
44 |
echo |
45 |
echo |
45 |
einfo "Usage: `basename $0` [options]" |
46 |
einfo "Usage: `basename $0` [options]" |
46 |
echo |
47 |
echo |
Lines 56-64
Link Here
|
56 |
einfo "${BRACKET}[${NORMAL} ${GOOD}${VERSION}${NORMAL} ${BRACKET}]${NORMAL}" |
57 |
einfo "${BRACKET}[${NORMAL} ${GOOD}${VERSION}${NORMAL} ${BRACKET}]${NORMAL}" |
57 |
} |
58 |
} |
58 |
|
59 |
|
59 |
if [ "`grep -x ^SHOWFREEDSPACE /etc/locale.nopurge`" ]; then |
60 |
# Check options in CONFIGFILE |
60 |
SHOWFREEDSPACE=enabled |
61 |
|
61 |
fi |
62 |
grep -xq SHOWFREEDSPACE ${CONFIGFILE} && SHOWFREEDSPACE=enabled |
|
|
63 |
grep -xq VERBOSE ${CONFIGFILE} && VERBOSE=enabled |
64 |
grep -xq NOCOLOR ${CONFIGFILE} && |
65 |
unset GOOD WARN BAD NORMAL HILITE BRACKET BOLD |
62 |
|
66 |
|
63 |
# We need to loop through for no color first, otherwise options that exit |
67 |
# We need to loop through for no color first, otherwise options that exit |
64 |
# will make us ignore nocolor, so we might as well loop for debug first as well |
68 |
# will make us ignore nocolor, so we might as well loop for debug first as well |
Lines 69-75
Link Here
|
69 |
set -x |
73 |
set -x |
70 |
fi |
74 |
fi |
71 |
|
75 |
|
72 |
if [ "`grep -x ^NOCOLOR /etc/locale.nopurge`" ] || [ "$x" = "-nocolor" ] || [ "$x" = "-nc" ]; then |
76 |
if [ "$x" = "-nocolor" ] || [ "$x" = "-nc" ]; then |
73 |
unset GOOD WARN BAD NORMAL HILITE BRACKET BOLD |
77 |
unset GOOD WARN BAD NORMAL HILITE BRACKET BOLD |
74 |
fi |
78 |
fi |
75 |
|
79 |
|
Lines 80-86
Link Here
|
80 |
for x in $@ |
84 |
for x in $@ |
81 |
do |
85 |
do |
82 |
|
86 |
|
83 |
if [ "`grep -x ^VERBOSE /etc/locale.nopurge`" ] || [ "$x" = "-verbose" ] || [ "$x" = "-v" ]; then |
87 |
if [ "$x" = "-verbose" ] || [ "$x" = "-v" ]; then |
84 |
VERBOSE=enabled |
88 |
VERBOSE=enabled |
85 |
fi |
89 |
fi |
86 |
|
90 |
|
Lines 89-94
Link Here
|
89 |
exit 0 |
93 |
exit 0 |
90 |
fi |
94 |
fi |
91 |
|
95 |
|
|
|
96 |
if [ "$x" = "-p" ] || [ "$x" = "-pretend" ]; then |
97 |
PRETEND=enabled |
98 |
fi |
99 |
|
92 |
if [ "$x" = "-help" ] || [ "$x" = "-h" ]; then |
100 |
if [ "$x" = "-help" ] || [ "$x" = "-h" ]; then |
93 |
ayuda |
101 |
ayuda |
94 |
exit 0 |
102 |
exit 0 |
Lines 98-112
Link Here
|
98 |
|
106 |
|
99 |
# Do nothing and report why if no valid configuration file exists: |
107 |
# Do nothing and report why if no valid configuration file exists: |
100 |
|
108 |
|
101 |
if [ ! -f /etc/locale.nopurge ] |
109 |
if [ ! -f ${CONFIGFILE} ] |
102 |
then |
110 |
then |
103 |
eerror " No /etc/locale.nopurge file present, exiting ..." |
111 |
eerror " No ${CONFIGFILE} file present, exiting ..." |
104 |
exit 0 |
112 |
exit 0 |
105 |
else |
113 |
else |
106 |
if [ "`grep -x ^NEEDSCONFIGFIRST /etc/locale.nopurge`" ] |
114 |
if [ "`grep -x ^NEEDSCONFIGFIRST ${CONFIGFILE}`" ] |
107 |
then |
115 |
then |
108 |
echo "" |
116 |
echo "" |
109 |
einfo " You have to configure \"/etc/locale.nopurge\" " |
117 |
einfo " You have to configure \"${CONFIGFILE}\" " |
110 |
echo "" |
118 |
echo "" |
111 |
einfo " to make $0 actually start to function." |
119 |
einfo " to make $0 actually start to function." |
112 |
echo "" |
120 |
echo "" |
Lines 116-121
Link Here
|
116 |
fi |
124 |
fi |
117 |
fi |
125 |
fi |
118 |
|
126 |
|
|
|
127 |
# Prune the locale list using CONFIGFILE as a list of regex patterns: |
128 |
|
129 |
PURGELIST=`grep -xvf ${CONFIGFILE} "${LOCALELIST}"` |
130 |
|
119 |
# Getting rid of superfluous locale files in $LOCALEDIR: |
131 |
# Getting rid of superfluous locale files in $LOCALEDIR: |
120 |
|
132 |
|
121 |
purgelocale () { |
133 |
purgelocale () { |
Lines 130-149
Link Here
|
130 |
einfo "localepurge: processing locale files in ${LOCALEDIR} ..." |
142 |
einfo "localepurge: processing locale files in ${LOCALEDIR} ..." |
131 |
for LOCALE in `/bin/ls ${LOCALEDIR}` |
143 |
for LOCALE in `/bin/ls ${LOCALEDIR}` |
132 |
do |
144 |
do |
133 |
if [ ! "`grep -x ^${LOCALE} /etc/locale.nopurge`" ] && \ |
145 |
if echo "${PURGELIST}" | grep -xq ${LOCALE}; then |
134 |
[ "`grep -x ^${LOCALE} ${LOCALELIST}`" ]; then |
|
|
135 |
if [ -d ${LOCALEDIR}/${LOCALE}/LC_MESSAGES ]; then |
146 |
if [ -d ${LOCALEDIR}/${LOCALE}/LC_MESSAGES ]; then |
136 |
/bin/rm -vf `find ${LOCALEDIR}/${LOCALE} -type f` |
147 |
if [ "${PRETEND}" = "enabled" ]; then |
|
|
148 |
echo "${LOCALEDIR}/${LOCALE}" |
149 |
else |
150 |
/bin/rm -vf `find ${LOCALEDIR}/${LOCALE} -type f` |
151 |
fi |
137 |
fi |
152 |
fi |
138 |
fi |
153 |
fi |
139 |
done |
154 |
done |
140 |
else |
155 |
else |
141 |
for LOCALE in `/bin/ls ${LOCALEDIR}` |
156 |
for LOCALE in `/bin/ls ${LOCALEDIR}` |
142 |
do |
157 |
do |
143 |
if [ ! "`grep -x ^${LOCALE} /etc/locale.nopurge`" ] && \ |
158 |
if echo "${PURGELIST}" | grep -xq ${LOCALE}; then |
144 |
[ "`grep -x ^${LOCALE} ${LOCALELIST}`" ]; then |
|
|
145 |
if [ -d ${LOCALEDIR}/${LOCALE}/LC_MESSAGES ]; then |
159 |
if [ -d ${LOCALEDIR}/${LOCALE}/LC_MESSAGES ]; then |
146 |
/bin/rm -f `find ${LOCALEDIR}/${LOCALE} -type f` |
160 |
if [ "${PRETEND}" = "enabled" ]; then |
|
|
161 |
echo "${LOCALEDIR}/${LOCALE}" |
162 |
else |
163 |
/bin/rm -vf `find ${LOCALEDIR}/${LOCALE} -type f` |
164 |
fi |
147 |
fi |
165 |
fi |
148 |
fi |
166 |
fi |
149 |
done |
167 |
done |
Lines 164-170
Link Here
|
164 |
|
182 |
|
165 |
purgeman () { |
183 |
purgeman () { |
166 |
local MANPAGEDIR="$1" |
184 |
local MANPAGEDIR="$1" |
167 |
if [ -d $MANPAGEDIR ] && [ "`grep -x ^MANDELETE /etc/locale.nopurge`" ]; then |
185 |
if [ -d $MANPAGEDIR ] && [ "`grep -x ^MANDELETE ${CONFIGFILE}`" ]; then |
168 |
|
186 |
|
169 |
if [ "$SHOWFREEDSPACE" = "enabled" ]; then |
187 |
if [ "$SHOWFREEDSPACE" = "enabled" ]; then |
170 |
MANBEFORE=$(df -P $MANPAGEDIR | awk '{if ( NR==2 ) { print $3 }}') |
188 |
MANBEFORE=$(df -P $MANPAGEDIR | awk '{if ( NR==2 ) { print $3 }}') |
Lines 174-193
Link Here
|
174 |
einfo "localepurge: processing man pages in ${MANPAGEDIR} ..." |
192 |
einfo "localepurge: processing man pages in ${MANPAGEDIR} ..." |
175 |
for LOCALE in `/bin/ls ${MANPAGEDIR} | grep -v ^man[1-9]` |
193 |
for LOCALE in `/bin/ls ${MANPAGEDIR} | grep -v ^man[1-9]` |
176 |
do |
194 |
do |
177 |
if [ ! "`grep -x ^${LOCALE} /etc/locale.nopurge`" ] && \ |
195 |
if echo "${PURGELIST}" | grep -xq ${LOCALE}; then |
178 |
[ "`grep -x ^${LOCALE} ${LOCALELIST}`" ]; then |
|
|
179 |
if [ -d ${MANPAGEDIR}/${LOCALE} ]; then |
196 |
if [ -d ${MANPAGEDIR}/${LOCALE} ]; then |
180 |
/bin/rm -vf `find ${MANPAGEDIR}/${LOCALE} -type f` |
197 |
if [ "${PRETEND}" = "enabled" ]; then |
|
|
198 |
echo "${MANPAGEDIR}/${LOCALE}" |
199 |
else |
200 |
/bin/rm -f `find ${MANPAGEDIR}/${LOCALE} -type f` |
201 |
fi |
181 |
fi |
202 |
fi |
182 |
fi |
203 |
fi |
183 |
done |
204 |
done |
184 |
else |
205 |
else |
185 |
for LOCALE in `/bin/ls ${MANPAGEDIR} | grep -v ^man[1-9]` |
206 |
for LOCALE in `/bin/ls ${MANPAGEDIR} | grep -v ^man[1-9]` |
186 |
do |
207 |
do |
187 |
if [ ! "`grep -x ^${LOCALE} /etc/locale.nopurge`" ] && \ |
208 |
if echo "${PURGELIST}" | grep -xq ${LOCALE}; then |
188 |
[ "`grep -x ^${LOCALE} ${LOCALELIST}`" ]; then |
|
|
189 |
if [ -d ${MANPAGEDIR}/${LOCALE} ]; then |
209 |
if [ -d ${MANPAGEDIR}/${LOCALE} ]; then |
190 |
/bin/rm -f `find ${MANPAGEDIR}/${LOCALE} -type f` |
210 |
if [ "${PRETEND}" = "enabled" ]; then |
|
|
211 |
echo "${MANPAGEDIR}/${LOCALE}" |
212 |
else |
213 |
/bin/rm -f `find ${MANPAGEDIR}/${LOCALE} -type f` |
214 |
fi |
191 |
fi |
215 |
fi |
192 |
fi |
216 |
fi |
193 |
done |
217 |
done |
Lines 204-209
Link Here
|
204 |
fi |
228 |
fi |
205 |
} |
229 |
} |
206 |
|
230 |
|
|
|
231 |
[ "${PRETEND}" = "enabled" ] && |
232 |
ewarn "If not pretending, localepurge would clear the following directories:\n" |
233 |
|
207 |
for folder in ${LOCALEDIRS}; do |
234 |
for folder in ${LOCALEDIRS}; do |
208 |
purgelocale "$folder" |
235 |
purgelocale "$folder" |
209 |
done |
236 |
done |