Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Kaegi2009-04-27 20:27:10 -0400
committerSimon Kaegi2009-04-27 20:27:10 -0400
commita5f1821479c7771d3c19cd180cb0e2c40720e443 (patch)
tree587b72c93976b86e98ea5bd80930b370baff02ab /bundles/org.eclipse.equinox.p2.touchpoint.eclipse
parent013c8def6717dff92895e16839a852557d038233 (diff)
downloadrt.equinox.p2-a5f1821479c7771d3c19cd180cb0e2c40720e443.tar.gz
rt.equinox.p2-a5f1821479c7771d3c19cd180cb0e2c40720e443.tar.xz
rt.equinox.p2-a5f1821479c7771d3c19cd180cb0e2c40720e443.zip
Bug 273955 Cannot install TPTP features from Galileo update site in Eclipse 3.5.
We still need a chmod action in the eclipse touchpoint to support @artifact
Diffstat (limited to 'bundles/org.eclipse.equinox.p2.touchpoint.eclipse')
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/plugin.xml10
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java1
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java150
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/Messages.java2
-rw-r--r--bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/messages.properties48
6 files changed, 189 insertions, 24 deletions
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/plugin.xml b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/plugin.xml
index 6aa98b435..d5d246e69 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/plugin.xml
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/plugin.xml
@@ -58,6 +58,16 @@
<extension
point="org.eclipse.equinox.p2.engine.actions">
<action
+ class="org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.ChmodAction"
+ name="chmod"
+ touchpointType="org.eclipse.equinox.p2.osgi"
+ touchpointVersion="1.0.0"
+ version="1.0.0">
+ </action>
+ </extension>
+ <extension
+ point="org.eclipse.equinox.p2.engine.actions">
+ <action
class="org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions.CollectAction"
name="collect"
touchpointType="org.eclipse.equinox.p2.osgi"
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
index 830be978b..d45104f5a 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/EclipseTouchpoint.java
@@ -31,7 +31,7 @@ public class EclipseTouchpoint extends Touchpoint {
public static final String PARM_IU = "iu"; //$NON-NLS-1$
private static final String NATIVE_TOUCHPOINT_ID = "org.eclipse.equinox.p2.touchpoint.natives"; //$NON-NLS-1$
- private static List NATIVE_ACTIONS = Arrays.asList(new String[] {"chmod", "ln", "mkdir", "rmdir"}); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
+ private static List NATIVE_ACTIONS = Arrays.asList(new String[] {"ln", "mkdir", "rmdir"}); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$//$NON-NLS-4$
private static final String VALIDATE_PROFILE = "org.eclipse.equinox.internal.p2.touchpoint.eclipse.validateProfile"; //$NON-NLS-1$
private static Map manipulators = new WeakHashMap();
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java
index 40ffba090..ab9e86968 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ActionConstants.java
@@ -45,4 +45,5 @@ public class ActionConstants {
public static final String PARM_REPOSITORY_TYPE = "type"; //$NON-NLS-1$
public static final String PARM_REPOSITORY_ENABLEMENT = "enabled"; //$NON-NLS-1$
public static final String PARM_REPOSITORY_NICKNAME = "name"; //$NON-NLS-1$
+ public static final Object PARM_OPTIONS = "options"; //$NON-NLS-1$
}
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java
new file mode 100644
index 000000000..641e13f76
--- /dev/null
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/ChmodAction.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2008 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:
+ * Red Hat Incorporated - initial API and implementation
+ * IBM Corporation - ongoing development
+ * Cloudsmith Inc - ongoing development
+ *******************************************************************************/
+package org.eclipse.equinox.internal.p2.touchpoint.eclipse.actions;
+
+import java.io.*;
+import java.util.ArrayList;
+import java.util.Map;
+import org.eclipse.core.runtime.*;
+import org.eclipse.equinox.internal.p2.touchpoint.eclipse.EclipseTouchpoint;
+import org.eclipse.equinox.internal.p2.touchpoint.eclipse.Util;
+import org.eclipse.equinox.internal.provisional.p2.engine.IProfile;
+import org.eclipse.equinox.internal.provisional.p2.engine.ProvisioningAction;
+import org.eclipse.equinox.internal.provisional.p2.metadata.IArtifactKey;
+import org.eclipse.equinox.internal.provisional.p2.metadata.IInstallableUnit;
+import org.eclipse.osgi.util.NLS;
+
+// This basically a copy of the chmod action in the native touchpoint only it provides @artifact support.
+// We should just use the native touchpoint copy when we have a replacement for the use of @artifact in parameters
+public class ChmodAction extends ProvisioningAction {
+ private static final String ACTION_CHMOD = "chmod"; //$NON-NLS-1$
+
+ public IStatus execute(Map parameters) {
+ String targetDir = (String) parameters.get(ActionConstants.PARM_TARGET_DIR);
+ if (targetDir == null)
+ return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_TARGET_DIR, ACTION_CHMOD));
+ if (targetDir.equals(ActionConstants.PARM_ARTIFACT)) {
+ try {
+ targetDir = resolveArtifactParam(parameters);
+ } catch (CoreException e) {
+ return e.getStatus();
+ }
+
+ File dir = new File(targetDir);
+ if (!dir.isDirectory()) {
+ return Util.createError(NLS.bind(Messages.artifact_not_directory, dir));
+ }
+ }
+
+ String targetFile = (String) parameters.get(ActionConstants.PARM_TARGET_FILE);
+ if (targetFile == null)
+ return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_TARGET_FILE, ACTION_CHMOD));
+ String permissions = (String) parameters.get(ActionConstants.PARM_PERMISSIONS);
+ if (permissions == null)
+ return Util.createError(NLS.bind(Messages.parameter_not_set, ActionConstants.PARM_PERMISSIONS, ACTION_CHMOD));
+ String optionsString = (String) parameters.get(ActionConstants.PARM_OPTIONS);
+
+ // Check that file exist
+ File probe = new File(targetDir + IPath.SEPARATOR + targetFile);
+ if (!probe.exists())
+ return Util.createError(NLS.bind(Messages.action_0_failed_file_1_doesNotExist, ACTION_CHMOD, probe.toString()));
+
+ String options[] = null;
+ if (optionsString != null) {
+ ArrayList collect = new ArrayList();
+ String r = optionsString.trim();
+ while (r.length() > 0) {
+ int spaceIdx = r.indexOf(' ');
+ if (spaceIdx < 0) {
+ collect.add(r);
+ r = ""; //$NON-NLS-1$
+ } else {
+ collect.add(r.substring(0, spaceIdx));
+ r = r.substring(spaceIdx + 1);
+ r = r.trim();
+ }
+ }
+ if (collect.size() > 0) {
+ options = new String[collect.size()];
+ collect.toArray(options);
+ }
+ }
+
+ chmod(targetDir, targetFile, permissions, options);
+ return Status.OK_STATUS;
+ }
+
+ public IStatus undo(Map parameters) {
+ //TODO: implement undo ??
+ return Status.OK_STATUS;
+ }
+
+ public void chmod(String targetDir, String targetFile, String perms, String[] options) {
+ Runtime r = Runtime.getRuntime();
+ try {
+ // Note: 3 is from chmod, permissions, and target
+ String[] args = new String[3 + (options == null ? 0 : options.length)];
+ int i = 0;
+ args[i++] = "chmod"; //$NON-NLS-1$
+ if (options != null) {
+ for (int j = 0; j < options.length; j++)
+ args[i++] = options[j];
+ }
+ args[i++] = perms;
+ args[i] = targetDir + IPath.SEPARATOR + targetFile;
+ Process process = r.exec(args);
+ readOffStream(process.getErrorStream());
+ readOffStream(process.getInputStream());
+ try {
+ process.waitFor();
+ } catch (InterruptedException e) {
+ // mark thread interrupted and continue
+ Thread.currentThread().interrupt();
+ }
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+
+ private void readOffStream(InputStream inputStream) {
+ BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream));
+ try {
+ while (reader.readLine() != null) {
+ // do nothing
+ }
+ } catch (IOException e) {
+ // ignore
+ } finally {
+ try {
+ reader.close();
+ } catch (IOException e) {
+ // ignore
+ }
+ }
+ }
+
+ private static String resolveArtifactParam(Map parameters) throws CoreException {
+ IProfile profile = (IProfile) parameters.get(ActionConstants.PARM_PROFILE);
+ IInstallableUnit iu = (IInstallableUnit) parameters.get(EclipseTouchpoint.PARM_IU);
+ IArtifactKey[] artifacts = iu.getArtifacts();
+ if (artifacts == null || artifacts.length == 0)
+ throw new CoreException(Util.createError(NLS.bind(Messages.iu_contains_no_arifacts, iu)));
+
+ IArtifactKey artifactKey = artifacts[0];
+
+ File fileLocation = Util.getArtifactFile(artifactKey, profile);
+ if (fileLocation == null || !fileLocation.exists())
+ throw new CoreException(Util.createError(NLS.bind(Messages.artifact_file_not_found, artifactKey)));
+ return fileLocation.getAbsolutePath();
+ }
+} \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/Messages.java b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/Messages.java
index 4f44c6a47..7e8bddf77 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/Messages.java
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/Messages.java
@@ -22,10 +22,12 @@ public class Messages extends NLS {
public static String failed_bundleinfo;
public static String cannot_configure_source_bundle;
public static String error_parsing_startlevel;
+ public static String artifact_not_directory;
public static String no_bundle_pool;
public static String error_processing_vmargs;
public static String invalid_byte_format;
public static String unable_to_open_file;
+ public static String action_0_failed_file_1_doesNotExist;
static {
// load message values from bundle file and assign to fields below
diff --git a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/messages.properties b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/messages.properties
index 4392524be..438f22b73 100644
--- a/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/messages.properties
+++ b/bundles/org.eclipse.equinox.p2.touchpoint.eclipse/src/org/eclipse/equinox/internal/p2/touchpoint/eclipse/actions/messages.properties
@@ -1,23 +1,25 @@
-###############################################################################
-# Copyright (c) 2008 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:
-# IBM Corporation - initial API and implementation
-###############################################################################
-
-artifact_file_not_found=The artifact file for {0} was not found.
-parameter_not_set=The \"{0}\" parameter was not set in the \"{1}\" action.
-iu_contains_no_arifacts=Installable unit contains no artifacts: {0}.
-no_matching_artifact=No matching artifact found for: {0}.
-missing_manifest=The manifest is missing for: {0}.
-failed_bundleinfo=Failed to create bundleInfo for: {0}.
-cannot_configure_source_bundle=Cannot configure {0} as a source bundle.
-error_parsing_startlevel=Error parsing start level: {0} for bundle: {1}.
-no_bundle_pool=No bundle pool defined for profile: {0}.
-error_processing_vmargs=An error occurred while processing the JVM argument.
-invalid_byte_format=Invalid format for byte argument: {0}.
-unable_to_open_file=Unable to open file: {0}.
+###############################################################################
+# Copyright (c) 2008 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:
+# IBM Corporation - initial API and implementation
+###############################################################################
+
+artifact_file_not_found=The artifact file for {0} was not found.
+artifact_not_directory=The artifact {0} is not a directory.
+parameter_not_set=The \"{0}\" parameter was not set in the \"{1}\" action.
+iu_contains_no_arifacts=Installable unit contains no artifacts: {0}.
+no_matching_artifact=No matching artifact found for: {0}.
+missing_manifest=The manifest is missing for: {0}.
+failed_bundleinfo=Failed to create bundleInfo for: {0}.
+cannot_configure_source_bundle=Cannot configure {0} as a source bundle.
+error_parsing_startlevel=Error parsing start level: {0} for bundle: {1}.
+no_bundle_pool=No bundle pool defined for profile: {0}.
+error_processing_vmargs=An error occurred while processing the JVM argument.
+invalid_byte_format=Invalid format for byte argument: {0}.
+unable_to_open_file=Unable to open file: {0}.
+action_0_failed_file_1_doesNotExist=The action {0} failed - file {1} does not exist.

Back to the top