LogoopenSUSE Build Service > Projects
Sign Up | Log In

View File kdm-kdmconf.diff of Package kdebase4-workspace (Project openSUSE:11.4)

Index: kdm/kfrontend/genkdmconf.c
===================================================================
--- kdm/kfrontend/genkdmconf.c.orig	2010-11-21 20:47:03.510842495 +0100
+++ kdm/kfrontend/genkdmconf.c	2010-11-21 20:47:03.623718730 +0100
@@ -1036,6 +1036,26 @@ copyFile(Entry *ce, int mode, int (*proc
 }
 
 static void
+cleanupFile( const char *tname, int mode )
+{
+    char *nname;
+    File file, file2;
+    char bn[PATH_MAX + 4];
+
+    ASPrintf( &nname, "%s/%s", newdir, tname );
+    sprintf( bn, "%s.bak", nname );
+
+    if (readFile( &file, nname ) && readFile( &file2, bn )) {
+        if ((file.eof - file.buf == file2.eof - file2.buf) && !strncmp( file.buf, file2.buf, file.eof - file.buf )) {
+            unlink( nname );
+            rename( bn, nname );
+            chmod( nname, mode );
+        }
+    }
+    free( nname );
+}
+
+static void
 doLinkFile(const char *name)
 {
     File file;
@@ -1074,9 +1094,10 @@ writeFile(const char *tname, int mode, c
     fputs_(cont, f);
     fclose_(f);
     addedFile(tname);
+    if (!no_backup)
+        cleanupFile(tname + sizeof(KDMCONF), mode);
 }
 
-
 static void
 handleBgCfg(Entry *ce, Section *cs)
 {
@@ -3166,9 +3187,6 @@ int main(int argc, char **argv)
                 memcmp(oldkde + olen - sizeof(SHR_CONF) + 1,
                        SHR_CONF, sizeof(SHR_CONF)))
             {
-                fprintf(stderr,
-                        "Warning: --old-kde does not end with " SHR_CONF ". "
-                        "Might wreak havoc.\n");
                 oldkdepfx = oldkde;
             } else
                 ASPrintf((char **)&oldkdepfx,
@@ -3280,6 +3298,8 @@ int main(int argc, char **argv)
     f = createFile("kdmrc", kdmrcmode);
     writeKdmrc(f);
     fclose_(f);
+    if (!no_backup)
+        cleanupFile( "kdmrc", kdmrcmode );
 
     f = createFile("README", 0644);
     fprintf_(f,
@@ -3328,6 +3348,8 @@ int main(int argc, char **argv)
 "\nTry 'genkdmconf --help' if you want to generate another configuration.\n"
 "\nYou may delete this README.\n");
     fclose_(f);
+    if (!no_backup)
+        cleanupFile( "README", 0644 );
 
     return 0;
 }