d55be1f
From d964680827a248e8a312c000c4c2443f96c8c459 Mon Sep 17 00:00:00 2001
d55be1f
From: Mat Booth <mat.booth@redhat.com>
d55be1f
Date: Fri, 27 Sep 2019 14:52:54 +0100
d55be1f
Subject: [PATCH] Force a clean on the restart after p2 operations
d55be1f
d55be1f
---
d55be1f
 .../META-INF/MANIFEST.MF                            |  2 +-
d55be1f
 .../bundles/org.eclipse.equinox.launcher/pom.xml    |  2 +-
d55be1f
 .../src/org/eclipse/equinox/launcher/Main.java      | 13 +++++++++++++
d55be1f
 .../internal/p2/ui/ProvisioningOperationRunner.java |  6 ++++++
d55be1f
 4 files changed, 21 insertions(+), 2 deletions(-)
d55be1f
d55be1f
diff --git a/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF b/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF
d55be1f
index 497e5d6fa..a118a0e4c 100644
d55be1f
--- a/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF
d55be1f
+++ b/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/META-INF/MANIFEST.MF
d55be1f
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
d55be1f
 Bundle-ManifestVersion: 2
d55be1f
 Bundle-Name: %pluginName
d55be1f
 Bundle-SymbolicName: org.eclipse.equinox.launcher;singleton:=true
d55be1f
-Bundle-Version: 1.5.600.qualifier
d55be1f
+Bundle-Version: 1.5.601.qualifier
d55be1f
 Main-Class: org.eclipse.equinox.launcher.Main
d55be1f
 Bundle-ClassPath: .
d55be1f
 Bundle-Vendor: %providerName
d55be1f
diff --git a/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/pom.xml b/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/pom.xml
d55be1f
index 43849b5b8..c5d2cdfea 100644
d55be1f
--- a/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/pom.xml
d55be1f
+++ b/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/pom.xml
d55be1f
@@ -19,6 +19,6 @@
d55be1f
   </parent>
d55be1f
   <groupId>org.eclipse.equinox</groupId>
d55be1f
   <artifactId>org.eclipse.equinox.launcher</artifactId>
d55be1f
-  <version>1.5.600-SNAPSHOT</version>
d55be1f
+  <version>1.5.601-SNAPSHOT</version>
d55be1f
   <packaging>eclipse-plugin</packaging>
d55be1f
 </project>
d55be1f
diff --git a/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java b/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
d55be1f
index d013ff7c2..65f4cfd8a 100644
d55be1f
--- a/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
d55be1f
+++ b/rt.equinox.framework/bundles/org.eclipse.equinox.launcher/src/org/eclipse/equinox/launcher/Main.java
d55be1f
@@ -560,6 +560,18 @@
d55be1f
 		setupVMProperties();
d55be1f
 		processConfiguration();
d55be1f
 
d55be1f
+		File oca = new File(getConfigurationLocation().toURI());
d55be1f
+		File ocaFile = new File(oca, "clean_on_restart");
d55be1f
+		if (ocaFile.exists()) {
d55be1f
+			System.err.println("Clean triggered."); //$NON-NLS-1$
d55be1f
+			ocaFile.delete();
d55be1f
+			commands = Arrays.copyOf(args, args.length + 1);
d55be1f
+			commands[commands.length-1] = CLEAN;
d55be1f
+			passThruArgs = Arrays.copyOf(passThruArgs, passThruArgs.length + 1);
d55be1f
+			passThruArgs[passThruArgs.length-1] = CLEAN;
d55be1f
+			setupVMProperties();
d55be1f
+		}
d55be1f
+		
d55be1f
 		if (protectBase && (System.getProperty(PROP_SHARED_CONFIG_AREA) == null)) {
d55be1f
 			System.err.println("This application is configured to run in a cascaded mode only."); //$NON-NLS-1$
d55be1f
 			System.setProperty(PROP_EXITCODE, Integer.toString(14));
d55be1f
diff --git a/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvisioningOperationRunner.java b/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvisioningOperationRunner.java
d55be1f
index a70b640ba..8a002ebc2 100644
d55be1f
--- a/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvisioningOperationRunner.java
d55be1f
+++ b/rt.equinox.p2/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ProvisioningOperationRunner.java
d55be1f
@@ -72,6 +72,12 @@ public class ProvisioningOperationRunner {
d55be1f
 	 * @param restartPolicy
d55be1f
 	 */
d55be1f
 	void requestRestart(final int restartPolicy) {
d55be1f
+		String oca = System.getProperty("osgi.configuration.area");
d55be1f
+		try {
d55be1f
+			java.io.File ocaCleanFile = new java.io.File(new java.net.URL(oca).toURI());
d55be1f
+			new java.io.File(ocaCleanFile, "clean_on_restart").createNewFile();
d55be1f
+		} catch (Exception e) { /* Eh, we tried... */ }
d55be1f
+
d55be1f
 		// Global override of restart (used in test cases).
d55be1f
 		if (suppressRestart)
d55be1f
 			return;
d55be1f
-- 
d55be1f
2.20.1
d55be1f