Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Rapicault2015-04-23 16:22:51 -0400
committerPascal Rapicault2015-04-24 10:56:04 -0400
commit77359c916106b323ab80d56d6231cc1987551713 (patch)
tree313cc0250720130f23c945c13ec4e3d619e89f7b
parentb281b11e5526f46c6890975d07e8ca7d8ee9f35e (diff)
downloadrt.equinox.p2-77359c916106b323ab80d56d6231cc1987551713.tar.gz
rt.equinox.p2-77359c916106b323ab80d56d6231cc1987551713.tar.xz
rt.equinox.p2-77359c916106b323ab80d56d6231cc1987551713.zip
Bug 462282 - Prevent (automatic) update to new Mac layoutI20150427-0800I20150426-2000
This is the first part of the fix. It consists in adding a new action that will be able to fail the installation. Change-Id: I24babd4df8202c94714528be723313b8eb4f9615 Signed-off-by: Pascal Rapicault <pascal@rapicorp.com>
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF4
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/p2.inf8
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/plugin.xml11
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Messages.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java78
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/messages.properties2
6 files changed, 104 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF b/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF
index 3ecd5aacf..898e2bf1d 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/MANIFEST.MF
@@ -22,5 +22,7 @@ Import-Package: org.eclipse.equinox.internal.p2.core.helpers,
org.eclipse.equinox.p2.query;version="2.0.0";resolution:=optional,
org.eclipse.equinox.p2.repository;version="[2.0.0,3.0.0)",
org.eclipse.equinox.p2.repository.artifact;version="[2.0.0,3.0.0)",
+ org.eclipse.osgi.service.environment;version="1.3.0",
org.eclipse.osgi.util;version="1.0.0",
- org.osgi.framework;version="1.3.0"
+ org.osgi.framework;version="1.3.0",
+ org.osgi.service.packageadmin;version="1.2.0"
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/p2.inf b/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/p2.inf
new file mode 100644
index 000000000..c7908b7a1
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/META-INF/p2.inf
@@ -0,0 +1,8 @@
+provides.0.namespace=org.eclipse.equinox.p2.iu
+provides.0.name=org.eclipse.equinox.p2.touchpoint.natives
+provides.0.version=1.1.100.v20140523-0116
+
+provides.1.namespace=org.eclipse.equinox.p2.iu
+provides.1.name=org.eclipse.equinox.p2.touchpoint.natives
+provides.1.version=1.2.0.$qualifier$
+
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/plugin.xml b/bundles/org.eclipse.equinox.p2.touchpoint.natives/plugin.xml
index 067b2d715..26f6da746 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/plugin.xml
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/plugin.xml
@@ -132,6 +132,17 @@
version="1.0.0">
</action>
</extension>
+ <extension
+ point="org.eclipse.equinox.p2.engine.actions">
+ <action
+ class="org.eclipse.equinox.internal.p2.touchpoint.natives.actions.BlockMacUpdate"
+ description="blockMacUpdate()"
+ name="blockMacUpdate"
+ touchpointType="org.eclipse.equinox.p2.native"
+ touchpointVersion="1.0.0"
+ version="1.0.0">
+ </action>
+ </extension>
<extension
id="nativePackageExtractor"
point="org.eclipse.core.runtime.applications">
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Messages.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Messages.java
index fd251a3b6..b0a3a9eff 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/Messages.java
@@ -40,6 +40,8 @@ public class Messages extends NLS {
public static String BackupStore_missing_backup_directory;
public static String BackupStore_not_a_directory;
public static String BackupStore_restore_closed_store;
+ public static String BlockMacUpdate_0;
+ public static String BlockMacUpdate_1;
public static String action_0_failed_file_1_doesNotExist;
public static String artifact_not_available;
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java
new file mode 100644
index 000000000..2104384cd
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/actions/BlockMacUpdate.java
@@ -0,0 +1,78 @@
+/*******************************************************************************
+ * Copyright (c) 2015 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Rapicorp, inc. - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.touchpoint.natives.actions;
+
+import java.util.Map;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.equinox.internal.p2.touchpoint.natives.Activator;
+import org.eclipse.equinox.internal.p2.touchpoint.natives.Messages;
+import org.eclipse.equinox.p2.engine.spi.ProvisioningAction;
+import org.eclipse.osgi.service.environment.EnvironmentInfo;
+import org.osgi.framework.*;
+import org.osgi.service.packageadmin.PackageAdmin;
+
+public class BlockMacUpdate extends ProvisioningAction {
+
+ @Override
+ public IStatus execute(Map<String, Object> parameters) {
+ if (!runningOldMacLayout())
+ return Status.OK_STATUS;
+ return new Status(IStatus.ERROR, Activator.ID, Messages.BlockMacUpdate_1);
+ }
+
+ private boolean runningOldMacLayout() {
+ if (!org.eclipse.osgi.service.environment.Constants.OS_MACOSX.equals(getOS()))
+ return false;
+ Version fwkAdminVersion = getFrameworkAdminVersion();
+ if (fwkAdminVersion == null)
+ return false;
+ if (fwkAdminVersion.compareTo(new Version("1.0.500.v201523")) < 0) //$NON-NLS-1$
+ return true;
+ return false;
+ }
+
+ private Version getFrameworkAdminVersion() {
+ ServiceReference<PackageAdmin> sr = Activator.getContext().getServiceReference(PackageAdmin.class);
+ if (sr == null)
+ return null;
+ PackageAdmin packageAdmin = Activator.getContext().getService(sr);
+ if (packageAdmin == null)
+ return null;
+ Activator.getContext().ungetService(sr);
+ Bundle[] bundles = packageAdmin.getBundles("org.eclipse.equinox.frameworkadmin.equinox", null); //$NON-NLS-1$
+ if (bundles == null)
+ return null;
+ //Return the first bundle that is not installed or uninstalled
+ for (int i = 0; i < bundles.length; i++) {
+ if ((bundles[i].getState() & (Bundle.INSTALLED | Bundle.UNINSTALLED)) == 0) {
+ return bundles[i].getVersion();
+ }
+ }
+ return null;
+ }
+
+ private String getOS() {
+ ServiceReference<EnvironmentInfo> sr = Activator.getContext().getServiceReference(EnvironmentInfo.class);
+ if (sr == null)
+ return null;
+ String value = Activator.getContext().getService(sr).getOS();
+ Activator.getContext().ungetService(sr);
+ return value;
+ }
+
+ @Override
+ public IStatus undo(Map<String, Object> parameters) {
+ // Nothing to do since we are not modifying any state.
+ return null;
+ }
+
+}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/messages.properties b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/messages.properties
index 2df1df727..304d40114 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.natives/src/org/eclipse/equinox/internal/p2/touchpoint/natives/messages.properties
@@ -29,6 +29,8 @@ BackupStore_manual_restore_needed=Manual restore of backup needed for: {0}
BackupStore_missing_backup_directory=Missing backup directory - can not restore: {0}
BackupStore_not_a_directory=File is not a directory: {0}
BackupStore_restore_closed_store=Can not perform restore on closed backup store
+BlockMacUpdate_0=Installation impossible
+BlockMacUpdate_1=The installation/update you are trying to perform can not completed because of structural changes to Eclipse. The installation/update will fail and will leave your existing eclipse installation intact. You need to retrieve a new version of Eclipse from http://download.eclipse.org/.
action_0_failed_file_1_doesNotExist=The action {0} failed - file {1} does not exist
artifact_not_available=The artifact for {0} is not available.

Back to the top