eclipse/eclipse-launcher-addplatfor...

145 lines
4.7 KiB
Diff

Index: library/eclipse.c
===================================================================
RCS file: /cvsroot/eclipse/platform-launcher/library/eclipse.c,v
retrieving revision 1.71
diff -u -r1.71 eclipse.c
--- library/eclipse.c 25 Apr 2006 14:31:50 -0000 1.71
+++ library/eclipse.c 14 May 2007 11:14:30 -0000
@@ -512,6 +512,8 @@
/* Get the command to start the Java VM. */
vmCommandArgs = getVMCommand( argc, argv );
+ addPlatformToTildeDotEclipse();
+
/* While the Java VM should be restarted */
vmCommand = vmCommandArgs;
while (vmCommand != NULL)
Index: library/gtk/eclipseGtk.c
===================================================================
RCS file: /cvsroot/eclipse/platform-launcher/library/gtk/eclipseGtk.c,v
retrieving revision 1.27
diff -u -r1.27 eclipseGtk.c
--- library/gtk/eclipseGtk.c 27 Mar 2006 18:25:42 -0000 1.27
+++ library/gtk/eclipseGtk.c 14 May 2007 11:14:30 -0000
@@ -335,3 +335,120 @@
gtk_main_quit();
return FALSE;
}
+
+/* Add the platform to ~/.eclipse/org.eclipse.platform_3.2.0/configuration/org.eclipse.update/platform.xml */
+void addPlatformToTildeDotEclipse()
+{
+ gchar *platform_xml, *touched, *dot_eclipse;
+ gchar *rcp321_position;
+ gchar *platform_xml_contents;
+ GError *error = NULL;
+
+ platform_xml = g_strconcat(g_get_home_dir(), "/.eclipse/org.eclipse.platform_3.2.0/configuration/org.eclipse.update/platform.xml", NULL);
+ dot_eclipse = g_strconcat(g_get_home_dir(), "/.eclipse", NULL);
+ touched = g_strconcat(g_get_home_dir(), "/.eclipse/.homedirmodified-fedora", NULL);
+
+
+ if (!g_file_test(dot_eclipse, G_FILE_TEST_EXISTS))
+ {
+ /* If .eclipse doesn't exist, Eclipse has yet to be started.
+ * We don't have worry about doing anything now and in the future
+ * so add the appropriate file to ~/.eclipse. */
+ if (g_mkdir(g_strconcat(g_get_home_dir(), "/.eclipse", NULL), 511) < 0)
+ {
+ g_print("Error creating ~/.eclipse/.");
+ g_free(platform_xml);
+ g_free(dot_eclipse);
+ g_free(touched);
+ return;
+
+ }
+ if (g_file_set_contents(touched, "\0", -1, &error) == FALSE)
+ {
+ g_print("Error touching ~/.eclipse/.homedirmodified-fedora.");
+ g_print(g_strconcat(error->message, "\n\0", NULL));
+ g_free(error);
+ g_free(platform_xml);
+ g_free(dot_eclipse);
+ g_free(touched);
+ return;
+ }
+
+ }
+ else if (g_file_test(platform_xml, G_FILE_TEST_EXISTS))
+ {
+ /* platform_xml exists, workaround these two bugs:
+ * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=238107
+ * https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=238109
+ *
+ * remove the unwanted feature if its in platform.xml */
+
+ if (g_file_get_contents(platform_xml, &platform_xml_contents, NULL, &error) == FALSE)
+ {
+ g_print("Error reading platform.xml in ~/.eclipse.\
+ You should remove ~/.eclipse before restarting Eclipse:\0");
+ g_print(g_strconcat(error->message, "\n\0", NULL));
+ g_free(error);
+ g_free(platform_xml);
+ g_free(touched);
+ return;
+ }
+
+ gchar *unwanted_feature = "<feature id=\"org.eclipse.rcp\" version=\"3.2.1.r321_v20060801-clWbqCmjexIWDqg\" url=\"features/org.eclipse.rcp_3.2.1.r321_v20060801-clWbqCmjexIWDqg/\">\n</feature>\0";
+ rcp321_position = g_strrstr(platform_xml_contents, unwanted_feature);
+
+ if (rcp321_position != NULL)
+ {
+ int i;
+ for (i = 0; i < strlen(unwanted_feature); i++) {
+ rcp321_position[i] = ' ';
+ }
+ }
+
+ if (g_file_set_contents(platform_xml, platform_xml_contents, -1, &error) == FALSE)
+ {
+ g_print("Error writing platform.xml in ~/.eclipse.\
+ You should remove ~/.eclipse before restarting Eclipse:\0");
+ g_print(g_strconcat(error->message, "\n\0", NULL));
+ g_free(error);
+ g_free(touched);
+ g_free(dot_eclipse);
+ g_free(platform_xml);
+ g_free(platform_xml_contents);
+ return;
+ }
+
+ g_free(platform_xml_contents);
+ }
+
+ g_free(dot_eclipse);
+ if (g_file_test(touched, G_FILE_TEST_EXISTS))
+ {
+ /* touched exists, we don't need to do anything */
+ g_free(platform_xml);
+ g_free(touched);
+ return;
+ }
+
+ /* At this point platform_xml exists and touched does not exist. */
+ if (g_file_test(platform_xml, G_FILE_TEST_EXISTS))
+ {
+ if (g_remove(platform_xml) < 0)
+ {
+ g_print("Error writing platform.xml in ~/.eclipse.\
+ You should remove ~/.eclipse before restarting Eclipse:\0");
+ g_free(platform_xml);
+ g_free(touched);
+ return;
+ }
+ }
+ if (g_file_set_contents(touched, "\0", -1, &error) == FALSE)
+ {
+ g_print("Error touching ~/.eclipse/.homedirmodified-fedora.");
+ g_print(g_strconcat(error->message, "\n\0", NULL));
+ g_free(error);
+ }
+ g_free(platform_xml);
+ g_free(touched);
+ return;
+}