Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 378494 | Differences between
and this patch

Collapse All | Expand All

(-)a/profiling/org.eclipse.linuxtools.profiling.launch/src/org/eclipse/linuxtools/profiling/launch/RemoteProxyManager.java (-3 / +6 lines)
Lines 74-80 public class RemoteProxyManager implements IRemoteProxyManager { Link Here
74
74
75
	public IRemoteFileProxy getFileProxy(URI uri) throws CoreException {
75
	public IRemoteFileProxy getFileProxy(URI uri) throws CoreException {
76
		String scheme = uri.getScheme();
76
		String scheme = uri.getScheme();
77
		if (scheme != null && !LocalHost.equals(uri.getHost())) {
77
		String host = uri.getHost();
78
		if (scheme != null && host != null && !LocalHost.equals(host)) {
78
			IRemoteProxyManager manager = getRemoteManager(scheme);
79
			IRemoteProxyManager manager = getRemoteManager(scheme);
79
			if (manager != null)
80
			if (manager != null)
80
				return manager.getFileProxy(uri);
81
				return manager.getFileProxy(uri);
Lines 92-98 public class RemoteProxyManager implements IRemoteProxyManager { Link Here
92
93
93
	public IRemoteCommandLauncher getLauncher(URI uri) throws CoreException {
94
	public IRemoteCommandLauncher getLauncher(URI uri) throws CoreException {
94
		String scheme = uri.getScheme();
95
		String scheme = uri.getScheme();
95
		if (scheme != null && !LocalHost.equals(uri.getHost())) {
96
		String host = uri.getHost();
97
		if (scheme != null && host != null && !LocalHost.equals(host)) {
96
			IRemoteProxyManager manager = getRemoteManager(scheme);
98
			IRemoteProxyManager manager = getRemoteManager(scheme);
97
			if (manager != null)
99
			if (manager != null)
98
		       return manager.getLauncher(uri);
100
		       return manager.getLauncher(uri);
Lines 107-113 public class RemoteProxyManager implements IRemoteProxyManager { Link Here
107
109
108
	public String getOS(URI uri) throws CoreException {
110
	public String getOS(URI uri) throws CoreException {
109
		String scheme = uri.getScheme();
111
		String scheme = uri.getScheme();
110
		if (scheme != null && !LocalHost.equals(uri.getHost())) {
112
		String host = uri.getHost();
113
		if (scheme != null && host != null && !LocalHost.equals(host)) {
111
			IRemoteProxyManager manager = getRemoteManager(scheme);
114
			IRemoteProxyManager manager = getRemoteManager(scheme);
112
			if (manager != null)
115
			if (manager != null)
113
			  return manager.getOS(uri);
116
			  return manager.getOS(uri);
(-)a/profiling/org.eclipse.linuxtools.tools.launch.core/META-INF/MANIFEST.MF (-2 / +4 lines)
Lines 2-15 Manifest-Version: 1.0 Link Here
2
Bundle-ManifestVersion: 2
2
Bundle-ManifestVersion: 2
3
Bundle-Name: %bundleName
3
Bundle-Name: %bundleName
4
Bundle-SymbolicName: org.eclipse.linuxtools.tools.launch.core
4
Bundle-SymbolicName: org.eclipse.linuxtools.tools.launch.core
5
Bundle-Version: 1.0.0.qualifier
5
Bundle-Version: 1.1.0.qualifier
6
Bundle-Vendor: %provider
6
Bundle-Vendor: %provider
7
Bundle-Activator: org.eclipse.linuxtools.tools.launch.core.Activator
7
Bundle-Activator: org.eclipse.linuxtools.tools.launch.core.Activator
8
Bundle-Localization: plugin
8
Bundle-Localization: plugin
9
Require-Bundle: org.eclipse.core.runtime,
9
Require-Bundle: org.eclipse.core.runtime,
10
 org.eclipse.cdt.core,
10
 org.eclipse.cdt.core,
11
 org.eclipse.core.resources,
11
 org.eclipse.core.resources,
12
 org.eclipse.ui;bundle-version="3.7.0"
12
 org.eclipse.ui;bundle-version="3.7.0",
13
 org.eclipse.linuxtools.profiling.launch;bundle-version="0.10.0",
14
 org.eclipse.core.filesystem;bundle-version="1.3.100"
13
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
15
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
14
Bundle-ActivationPolicy: lazy
16
Bundle-ActivationPolicy: lazy
15
Export-Package: org.eclipse.linuxtools.tools.launch.core.factory,
17
Export-Package: org.eclipse.linuxtools.tools.launch.core.factory,
(-)a/profiling/org.eclipse.linuxtools.tools.launch.core/pom.xml (-1 / +1 lines)
Lines 18-24 Link Here
18
  </parent>
18
  </parent>
19
19
20
  <artifactId>org.eclipse.linuxtools.tools.launch.core</artifactId>
20
  <artifactId>org.eclipse.linuxtools.tools.launch.core</artifactId>
21
  <version>1.0.0-SNAPSHOT</version>
21
  <version>1.1.0-SNAPSHOT</version>
22
  <packaging>eclipse-plugin</packaging>
22
  <packaging>eclipse-plugin</packaging>
23
23
24
  <name>Linux Tools Tools Launcher Core Plug-in</name>
24
  <name>Linux Tools Tools Launcher Core Plug-in</name>
(-)a/profiling/org.eclipse.linuxtools.tools.launch.core/src/org/eclipse/linuxtools/tools/launch/core/factory/RuntimeProcessFactory.java (-12 / +204 lines)
Lines 15-26 import java.io.BufferedReader; Link Here
15
import java.io.File;
15
import java.io.File;
16
import java.io.IOException;
16
import java.io.IOException;
17
import java.io.InputStreamReader;
17
import java.io.InputStreamReader;
18
import java.net.URI;
18
import java.util.ArrayList;
19
import java.util.ArrayList;
19
import java.util.Arrays;
20
import java.util.Arrays;
20
import java.util.List;
21
import java.util.List;
21
import java.util.StringTokenizer;
22
import java.util.StringTokenizer;
22
23
24
import org.eclipse.core.filesystem.IFileStore;
23
import org.eclipse.core.resources.IProject;
25
import org.eclipse.core.resources.IProject;
26
import org.eclipse.core.runtime.CoreException;
27
import org.eclipse.core.runtime.IPath;
28
import org.eclipse.core.runtime.NullProgressMonitor;
29
import org.eclipse.core.runtime.Path;
30
import org.eclipse.linuxtools.profiling.launch.IRemoteCommandLauncher;
31
import org.eclipse.linuxtools.profiling.launch.IRemoteFileProxy;
32
import org.eclipse.linuxtools.profiling.launch.RemoteProxyManager;
24
33
25
/*
34
/*
26
 * Create process using Runtime.getRuntime().exec and prepends the
35
 * Create process using Runtime.getRuntime().exec and prepends the
Lines 42-61 public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { Link Here
42
		return cmdarray;
51
		return cmdarray;
43
	}
52
	}
44
53
54
	private String[] fillPathCommand(String[] cmdarray, IProject project) throws IOException {
55
		cmdarray[0] = whichCommand(cmdarray[0], project);
56
		return cmdarray;
57
	}
58
59
	/**
60
	 * @deprecated
61
	 *
62
	 * Use {@link RuntimeProcessFactory#fillPathCommand(String[], IProject)} instead.
63
	 */
64
	@Deprecated
45
	private String[] fillPathCommand(String[] cmdarray, String[] envp) throws IOException {
65
	private String[] fillPathCommand(String[] cmdarray, String[] envp) throws IOException {
46
		cmdarray[0] = whichCommand(cmdarray[0], envp);
66
		cmdarray[0] = whichCommand(cmdarray[0], envp);
47
		return cmdarray;
67
		return cmdarray;
48
	}
68
	}
49
	
69
	
70
	/**
71
	 * @deprecated
72
	 *
73
	 * Use {@link RuntimeProcessFactory#fillPathSudoCommand(String[], IProject)} instead.
74
	 */
75
	@Deprecated
50
	private String[] fillPathSudoCommand(String[] cmdarray, String[] envp) throws IOException {
76
	private String[] fillPathSudoCommand(String[] cmdarray, String[] envp) throws IOException {
51
		cmdarray[2] = whichCommand(cmdarray[2], envp);
77
		cmdarray[2] = whichCommand(cmdarray[2], envp);
52
		return cmdarray;
78
		return cmdarray;
53
	}
79
	}
54
80
55
	public String whichCommand(String command, IProject project) throws IOException {
81
	private String[] fillPathSudoCommand(String[] cmdarray, IProject project) throws IOException {
56
		return whichCommand(command, updateEnvironment(null, project));
82
		cmdarray[1] = whichCommand(cmdarray[1], project);
83
		return cmdarray;
57
	}
84
	}
58
85
86
	/**
87
	 * @deprecated
88
	 *
89
	 * Use {@link RuntimeProcessFactory#whichCommand(String, IProject)} instead.
90
	 */
91
	@Deprecated
59
	public String whichCommand(String command, String[] envp) throws IOException {
92
	public String whichCommand(String command, String[] envp) throws IOException {
60
		Process p = Runtime.getRuntime().exec(new String[] {WHICH_CMD, command}, envp);
93
		Process p = Runtime.getRuntime().exec(new String[] {WHICH_CMD, command}, envp);
61
		try {
94
		try {
Lines 72-77 public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { Link Here
72
		return command;
105
		return command;
73
	}
106
	}
74
107
108
	/**
109
	 * @since 1.1
110
	 */
111
	public String whichCommand(String command, IProject project) throws IOException {
112
		if (project != null) {
113
			String[] envp = updateEnvironment(null, project);
114
			try {
115
				IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(project);
116
				URI whichUri = URI.create(WHICH_CMD);
117
				IPath whichPath = new Path(proxy.toPath(whichUri));
118
				IRemoteCommandLauncher launcher = RemoteProxyManager.getInstance().getLauncher(project);
119
				Process pProxy = launcher.execute(whichPath, new String[]{command}, envp, null, new NullProgressMonitor());
120
				if (pProxy != null){
121
					BufferedReader error = new BufferedReader(new InputStreamReader(pProxy.getErrorStream()));
122
					if(error.readLine() != null){
123
						throw new IOException(error.readLine());
124
					}
125
					BufferedReader reader = new BufferedReader(new InputStreamReader(pProxy.getInputStream()));
126
					String readLine = reader.readLine();
127
					command = readLine;
128
				}
129
			} catch (CoreException e) {
130
				e.printStackTrace();
131
			}
132
		}
133
		return command;
134
	}
135
75
	public static RuntimeProcessFactory getFactory() {
136
	public static RuntimeProcessFactory getFactory() {
76
		if (instance == null)
137
		if (instance == null)
77
			instance = new RuntimeProcessFactory();
138
			instance = new RuntimeProcessFactory();
Lines 79-85 public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { Link Here
79
	}
140
	}
80
141
81
	public Process exec(String cmd, IProject project) throws IOException {
142
	public Process exec(String cmd, IProject project) throws IOException {
82
		return exec(cmd, null, null, project);
143
		return exec(cmd, null, (IFileStore)null, project);
83
	}
144
	}
84
145
85
	public Process exec(String[] cmdarray, IProject project) throws IOException {
146
	public Process exec(String[] cmdarray, IProject project) throws IOException {
Lines 87-104 public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { Link Here
87
	}
148
	}
88
149
89
	public Process exec(String[] cmdarray, String[] envp, IProject project) throws IOException {
150
	public Process exec(String[] cmdarray, String[] envp, IProject project) throws IOException {
90
		return exec(cmdarray, envp, null, project);
151
		return exec(cmdarray, envp, (IFileStore)null, project);
91
	}
152
	}
92
153
93
	public Process exec(String cmd, String[] envp, IProject project) throws IOException {
154
	public Process exec(String cmd, String[] envp, IProject project) throws IOException {
94
		return exec(cmd, envp, null, project);
155
		return exec(cmd, envp, (IFileStore)null, project);
95
	}
156
	}
96
157
158
	/**
159
	 * @deprecated
160
	 *
161
	 * Use {@link RuntimeProcessFactory#exec(String, String[], IFileStore, IProject)} instead.
162
	 */
163
	@Deprecated
97
	public Process exec(String cmd, String[] envp, File dir, IProject project)
164
	public Process exec(String cmd, String[] envp, File dir, IProject project)
98
		throws IOException {
165
		throws IOException {
99
		return exec(tokenizeCommand(cmd), envp, dir, project);
166
		return exec(tokenizeCommand(cmd), envp, dir, project);
100
	}
167
	}
101
168
169
	/**
170
	 * @since 1.1
171
	 */
172
	public Process exec(String cmd, String[] envp, IFileStore dir, IProject project)
173
		throws IOException {
174
		return exec(tokenizeCommand(cmd), envp, dir, project);
175
	}
176
177
	/**
178
	 * @deprecated
179
	 *
180
	 * Use {@link RuntimeProcessFactory#exec(String[], String[], IFileStore, IProject)} instead.
181
	 */
182
	@Deprecated
102
	public Process exec(String cmdarray[], String[] envp, File dir, IProject project)
183
	public Process exec(String cmdarray[], String[] envp, File dir, IProject project)
103
		throws IOException {
184
		throws IOException {
104
		envp = updateEnvironment(envp, project);
185
		envp = updateEnvironment(envp, project);
Lines 106-133 public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { Link Here
106
187
107
		return Runtime.getRuntime().exec(cmdarray, envp, dir);
188
		return Runtime.getRuntime().exec(cmdarray, envp, dir);
108
	}
189
	}
190
191
	/**
192
	 * @since 1.1
193
	 */
194
	public Process exec(String cmdarray[], String[] envp, IFileStore dir, IProject project)
195
		throws IOException {
196
197
		Process p = null;
198
		try {
199
			cmdarray = fillPathCommand(cmdarray, project);
200
201
			String command = cmdarray[0];
202
			URI uri = URI.create(command);
203
204
			IPath changeToDir = null;
205
			IPath path;
206
			IRemoteCommandLauncher launcher;
207
208
			if (project != null) {
209
				IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(project);
210
				path = new Path(proxy.toPath(uri));
211
				launcher = RemoteProxyManager.getInstance().getLauncher(project);
212
				envp = updateEnvironment(envp, project);
213
				if (dir != null)
214
					changeToDir = new Path(proxy.toPath(dir.toURI()));
215
			} else {
216
				path = new Path(uri.getPath());
217
				launcher = RemoteProxyManager.getInstance().getLauncher(uri);
218
				if (dir != null)
219
					changeToDir = new Path(dir.toURI().getPath());
220
			}
221
222
223
			List<String> cmdlist = new ArrayList<String>(Arrays.asList(cmdarray));
224
			cmdlist.remove(0);
225
			cmdlist.toArray(cmdarray);
226
			cmdarray = cmdlist.toArray(new String[0]);
227
228
			p = launcher.execute(path, cmdarray, envp, changeToDir , new NullProgressMonitor());
229
		} catch (CoreException e) {
230
			e.printStackTrace();
231
		}
232
233
		return p;
234
	}
109
	
235
	
110
	public Process sudoExec(String cmd, IProject project) throws IOException {
236
	public Process sudoExec(String cmd, IProject project) throws IOException {
111
		return sudoExec(cmd, null, null, project);
237
		return sudoExec(cmd, null, (IFileStore)null, project);
112
	}
238
	}
113
	
239
	
114
	public Process sudoExec(String cmd, String[] envp, IProject project) throws IOException {
240
	public Process sudoExec(String cmd, String[] envp, IProject project) throws IOException {
115
		return exec(cmd, envp, null, project);
241
		return exec(cmd, envp, (IFileStore)null, project);
116
	}
242
	}
117
	
243
244
	/**
245
	 * @deprecated
246
	 *
247
	 * Use {@link RuntimeProcessFactory#sudoExec(String, String[], IFileStore, IProject)} instead.
248
	 */
249
	@Deprecated
118
	public Process sudoExec(String cmd, String[] envp, File dir, IProject project)
250
	public Process sudoExec(String cmd, String[] envp, File dir, IProject project)
119
			throws IOException {
251
			throws IOException {
120
			return sudoExec(tokenizeCommand(cmd), envp, dir, project);
252
			return sudoExec(tokenizeCommand(cmd), envp, dir, project);
121
		}
253
	}
254
255
	/**
256
	 * @since 1.1
257
	 */
258
	public Process sudoExec(String cmd, String[] envp, IFileStore dir, IProject project)
259
			throws IOException {
260
			return sudoExec(tokenizeCommand(cmd), envp, dir, project);
261
	}
122
	
262
	
123
	public Process sudoExec(String[] cmdarray, IProject project) throws IOException {
263
	public Process sudoExec(String[] cmdarray, IProject project) throws IOException {
124
		return sudoExec(cmdarray, null, project);
264
		return sudoExec(cmdarray, null, project);
125
	}
265
	}
126
	
266
	
127
	public Process sudoExec(String[] cmdarray, String[] envp, IProject project) throws IOException {
267
	public Process sudoExec(String[] cmdarray, String[] envp, IProject project) throws IOException {
128
		return sudoExec(cmdarray, envp, null, project);
268
		return sudoExec(cmdarray, envp, (IFileStore)null, project);
129
	}
269
	}
130
	
270
271
	/**
272
	 * @deprecated
273
	 *
274
	 * Use {@link RuntimeProcessFactory#sudoExec(String[], String[], IFileStore, IProject)} instead.
275
	 */
276
	@Deprecated
131
	public Process sudoExec(String[] cmdarray, String[] envp, File dir, IProject project) throws IOException {
277
	public Process sudoExec(String[] cmdarray, String[] envp, File dir, IProject project) throws IOException {
132
		List<String> cmdList = Arrays.asList(cmdarray);
278
		List<String> cmdList = Arrays.asList(cmdarray);
133
		ArrayList<String> cmdArrayList = new ArrayList<String>(cmdList);
279
		ArrayList<String> cmdArrayList = new ArrayList<String>(cmdList);
Lines 142-145 public class RuntimeProcessFactory extends LinuxtoolsProcessFactory { Link Here
142
288
143
		return Runtime.getRuntime().exec(cmdArraySudo, envp, dir);
289
		return Runtime.getRuntime().exec(cmdArraySudo, envp, dir);
144
	}
290
	}
291
292
	/**
293
	 * @since 1.1
294
	 */
295
	public Process sudoExec(String[] cmdarray, String[] envp, IFileStore dir, IProject project) throws IOException {
296
		URI uri = URI.create("sudo"); //$NON-NLS-1$
297
298
		List<String> cmdList = Arrays.asList(cmdarray);
299
		ArrayList<String> cmdArrayList = new ArrayList<String>(cmdList);
300
		cmdArrayList.add(0, "-n"); //$NON-NLS-1$
301
302
		String[] cmdArraySudo = new String[cmdArrayList.size()];
303
		cmdArrayList.toArray(cmdArraySudo);
304
305
		Process p = null;
306
		try {
307
			cmdArraySudo = fillPathSudoCommand(cmdArraySudo, project);
308
			IRemoteCommandLauncher launcher;
309
			IPath changeToDir = null, path;
310
			if (project != null) {
311
				IRemoteFileProxy proxy = RemoteProxyManager.getInstance().getFileProxy(project);
312
				path = new Path(proxy.toPath(uri));
313
				launcher = RemoteProxyManager.getInstance().getLauncher(project);
314
				envp = updateEnvironment(envp, project);
315
316
				if (dir != null)
317
					changeToDir = new Path(proxy.toPath(dir.toURI()));
318
			} else {
319
				launcher = RemoteProxyManager.getInstance().getLauncher(uri);
320
				path = new Path(uri.getPath());
321
				if (dir != null)
322
					changeToDir = new Path(dir.toURI().getPath());
323
			}
324
325
			List<String> cmdlist = new ArrayList<String>(Arrays.asList(cmdArraySudo));
326
			cmdlist.remove(0);
327
			cmdlist.toArray(cmdArraySudo);
328
			cmdArraySudo = cmdlist.toArray(new String[0]);
329
330
			p = launcher.execute(path, cmdArraySudo, envp, changeToDir , new NullProgressMonitor());
331
		} catch (CoreException e) {
332
			e.printStackTrace();
333
		}
334
335
		return p;
336
337
	}
145
}
338
}
146
- 

Return to bug 378494