Author: barbier
Date: 2006-04-04 18:45:40 +0000 (Tue, 04 Apr 2006)
New Revision: 1319

Modified:
   glibc-package/trunk/debian/debhelper.in/locales.postinst
   glibc-package/trunk/debian/local/usr_sbin/update-locale
Log:
Fix minor glitches with update-locale


Modified: glibc-package/trunk/debian/debhelper.in/locales.postinst
===================================================================
--- glibc-package/trunk/debian/debhelper.in/locales.postinst    2006-04-04 
02:19:29 UTC (rev 1318)
+++ glibc-package/trunk/debian/debhelper.in/locales.postinst    2006-04-04 
18:45:40 UTC (rev 1319)
@@ -16,7 +16,7 @@
     fi
     for i in LANG LANGUAGE LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY 
LC_MESSAGES LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT 
LC_IDENTIFICATION LC_ALL
     do
-        if [ -n "$exist" ]; then
+        if [ -z "$exist" ]; then
             if grep "^ *$i=" $OLDEE >> $EE; then
                 found=1
             fi
@@ -89,12 +89,10 @@
 
     # Set default LANG environment variable
     if [ -e $EE ]; then
-        sed -e '/^ *LANG=/d' $EE > $EE.tmp || true
-        #  $EE has to be updated if $SELECTED is empty or 'None'
-        mv -f $EE.tmp $EE
+        /usr/sbin/update-locale --remove LANG
     fi
     if [ -n "$SELECTED" ] && [ "$SELECTED" != "None" ]; then
-        update-locale "LANG=$SELECTED"
+        /usr/sbin/update-locale "LANG=$SELECTED"
     fi
 fi
 

Modified: glibc-package/trunk/debian/local/usr_sbin/update-locale
===================================================================
--- glibc-package/trunk/debian/local/usr_sbin/update-locale     2006-04-04 
02:19:29 UTC (rev 1318)
+++ glibc-package/trunk/debian/local/usr_sbin/update-locale     2006-04-04 
18:45:40 UTC (rev 1319)
@@ -2,7 +2,6 @@
 
 use strict;
 use Getopt::Long;
-use File::Temp;
 
 my $progname     = "update-locale";
 my $locale_file  = "/etc/default/locale";
@@ -40,8 +39,11 @@
 #  Process command-line arguments
 my %arg = ();
 my $content = '';
+my $mode = 0644;
 if (-r $locale_file)
 {
+       #  Keep file mode
+       $mode = (stat($locale_file))[2] & 07777;
        #  Read current values
        open(IN, "<", $locale_file)
                or die "$progname: Unable to read $locale_file: $!\n";
@@ -97,7 +99,7 @@
                $language =~ s/[.:_].*//;
                my $msg = '';
                my $var = '';
-               for (qw(LC_MESSAGES LANG LC_ALL))
+               for (qw(LANG LC_MESSAGES LC_ALL))
                {
                        if (defined $arg{$_})
                        {
@@ -106,20 +108,19 @@
                        }
                }
                die "*** $progname: Error: LANGUAGE ($arg{LANGUAGE}) is not 
compatible with $var ($msg)\n"
-                       if ($msg !~ m/^$language/);
+                       if ($msg !~ m/^$language/ && $var ne ''
+                           && $msg ne 'C' && $msg ne 'POSIX'
+                           && $language ne 'C' && $language ne 'POSIX');
        }
 }
 
 #  Write locale file
-my ($fh, $filename) = File::Temp::tempfile();
-open(OUT, ">", $filename)
-       or die "$progname: Unable to write $filename: $!\n";
+open(OUT, ">", $locale_file)
+       or die "$progname: Unable to write $locale_file: $!\n";
 print OUT $content;
 close(OUT)
-       or die "$progname: Unable to close $filename: $!\n";
-chmod 0644, $filename
-       or die "$progname: Unable to chmod $filename: $!\n";
-rename $filename, $locale_file
-       or die "$progname: Unable to rename $filename into $locale_file: $!\n";
+       or die "$progname: Unable to close $locale_file: $!\n";
+chmod($mode, $locale_file)
+       or die "$progname: Unable to chmod $locale_file: $!\n";
 
 1;


-- 
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]

Reply via email to