summaryrefslogtreecommitdiff
path: root/system/localepurge/localepurge.diff
blob: c0174d5bf784fa21e334adc2996d340a6fa394ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
--- ../localepurge-orig/usr/sbin/localepurge	2013-06-15 18:46:01.000000000 +0200
+++ localepurge	2013-09-21 12:04:38.155721151 +0200
@@ -1,6 +1,6 @@
 #! /bin/bash
 
-# Deleting all locale files and localized man pages installed 
+# Deleting all locale files and localized man pages installed
 # on system which are *not* listed in /etc/locale.nopurge
 
 set -e
@@ -12,48 +12,35 @@
 fi
 
 if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
-   echo ""
-   echo "Verbose output is triggered with option '-v' or '-verbose'."
-   echo "Debugging output is triggered with option '-d' or '-debug'."
-   echo "To reconfigure it, run 'dpkg-reconfigure localepurge'."
-   echo "Documentation is either available via 'man localepurge'"
-   echo "or by reading the docs in /usr/share/doc/localepurge."
-   echo ""
-   if [ -f $NOPURGECONF ] && fgrep --quiet --line-regexp USE_DPKG $NOPURGECONF ; then
-       echo "NB: localepurge has been configured to use dpkg.  Therefore,"
-       echo "this script will not do anything."
-   fi
-   exit 0
+    echo ""
+    echo "Verbose output is triggered with option '-v' or '-verbose'."
+    echo "Debugging output is triggered with option '-d' or '-debug'."
+    echo "To reconfigure it, edit /etc/locale.nopurge file."
+    echo "Documentation is available via 'man 8 localepurge'."
+    echo ""
+    exit 0
 fi
 
-
 # Do nothing and report why if no valid configuration file exists:
 
-if [ ! -f $NOPURGECONF ]
-    then
-	echo " No $NOPURGECONF file present, exiting ..."
+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\" by editing"
+	echo
+	echo "	      /etc/locale.nopurge file"
+	echo
+	echo "	  to make $0 actually start to function."
+	echo
+	echo "	  Nothing to be done, exiting ..."
+	echo
 	exit 0
-    else
-	if fgrep --quiet --line-regexp USE_DPKG $NOPURGECONF
-            then
-            # Do nothing, dpkg does all the work for us.
-            exit 0
-	elif 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
 fi
 
-
 ################################################################
 ## Initialise variables
 
@@ -85,7 +72,6 @@
     VERBOSE=1
 fi
 
-
 ################################################################
 ## Manage the list of locales
 
@@ -97,57 +83,57 @@
 
 ((VERBOSE)) && echo "localepurge: checking for existence of $LOCALECACHEDIR..."
 if [ ! -d $LOCALECACHEDIR ]; then
-	mkdir -m 644 -p $LOCALECACHEDIR
+    mkdir -m 644 -p $LOCALECACHEDIR
 fi
 
 ((VERBOSE)) && echo "localepurge: checking for existence of $LOCALELIST..."
 if [ ! -f $LOCALELIST ]; then
-	touch $LOCALELIST && chmod 664 $LOCALELIST
+    touch $LOCALELIST && chmod 664 $LOCALELIST
 fi
 
 ((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"
+do
+    if [ -d /usr/share/locale/$NEWLOCALE/LC_MESSAGES ]; then
+	if [ ! "$(grep -cx $NEWLOCALE $LOCALELIST)" = "1" ]; then
+	    echo "$NEWLOCALE" >> "$NEWLOCALELIST"
+	fi
     fi
- fi
 done
 
 for NEWLOCALE in $(ls --ignore="man[1-9]*" /usr/share/man)
-do 
- if [ -d /usr/share/man/$NEWLOCALE/man1 ] || [ -d /usr/share/man/$NEWLOCALE/man8 ]; then
-    if [ ! "$(grep -cx $NEWLOCALE $LOCALELIST)" = "1" ]; then
-	echo "$NEWLOCALE" >> "$NEWLOCALELIST"
+do
+    if [ -d /usr/share/man/$NEWLOCALE/man1 ] || [ -d /usr/share/man/$NEWLOCALE/man8 ]; then
+	if [ ! "$(grep -cx $NEWLOCALE $LOCALELIST)" = "1" ]; then
+	    echo "$NEWLOCALE" >> "$NEWLOCALELIST"
+	fi
     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
+    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" 
+    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 "    /usr/bin/localepurge-config"
     echo
 fi
 
@@ -157,7 +143,7 @@
 ## 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
+    # below to change newlines into spaces
     echo $(grep --invert-match --extended-regexp '^[ \t]*(#|$)' $NOPURGECONF)
 )
 nopurgepat='@(C|'"${nopurge// /|}"')'
@@ -172,7 +158,7 @@
 )
 
 ################################################################
-## Define utility functions 
+## Define utility functions
 
 # Function for disk space calculation
 # Usage: get_used_space <dirname>
@@ -202,7 +188,7 @@
 	local flag
 	((VERBOSE)) && flag=-v
 	for file; do
-	    if [ -f "$file" ] || [ -h "$file" ]; then 
+	    if [ -f "$file" ] || [ -h "$file" ]; then
 		echo "$file"
 	    fi
 	done | xargs rm $flag
@@ -241,7 +227,6 @@
     fi
 }
 
-
 ################################################################
 ## Now, get the job done