File kdm-kdmconf.diff of Package kdebase4-workspace

Index: kdm/kfrontend/genkdmconf.c
===================================================================
--- kdm/kfrontend/genkdmconf.c.orig
+++ kdm/kfrontend/genkdmconf.c
@@ -1049,6 +1049,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;
@@ -1087,9 +1107,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)
 {
@@ -3179,9 +3200,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,
@@ -3293,6 +3311,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,
@@ -3341,6 +3361,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;
 }
openSUSE Build Service is sponsored by