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 127375 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/update/internal/jarprocessor/Main.java (-10 / +16 lines)
Lines 25-30 Link Here
25
		public boolean pack = false;
25
		public boolean pack = false;
26
		public boolean repack = false;
26
		public boolean repack = false;
27
		public boolean unpack = false;
27
		public boolean unpack = false;
28
		public boolean verbose = false;
28
		public File input = null;
29
		public File input = null;
29
	}
30
	}
30
31
Lines 39-44 Link Here
39
		System.out.println("                with repack, sign and pack."); //$NON-NLS-1$
40
		System.out.println("                with repack, sign and pack."); //$NON-NLS-1$
40
		System.out.println();
41
		System.out.println();
41
		System.out.println("-outputDir <dir>  the output directory"); //$NON-NLS-1$
42
		System.out.println("-outputDir <dir>  the output directory"); //$NON-NLS-1$
43
		System.out.println("-verbose        verbose mode "); //$NON-NLS-1$
42
	}
44
	}
43
45
44
	public static Options processArguments(String[] args) {
46
	public static Options processArguments(String[] args) {
Lines 68-73 Link Here
68
					return null;
70
					return null;
69
				}
71
				}
70
				options.outputDir = args[++i];
72
				options.outputDir = args[++i];
73
			} else if (args[i].equals("-verbose")) { //$NON-NLS-1$
74
				options.verbose = true;
71
			}
75
			}
72
		}
76
		}
73
77
Lines 108-142 Link Here
108
			processor.setPack(options.pack);
112
			processor.setPack(options.pack);
109
			processor.setRepack(options.repack || (options.pack && options.signCommand != null));
113
			processor.setRepack(options.repack || (options.pack && options.signCommand != null));
110
			processor.setUnpack(options.unpack);
114
			processor.setUnpack(options.unpack);
115
			processor.setVerbose(options.verbose);
111
			try {
116
			try {
112
				processor.processZip(options.input);
117
				processor.processZip(options.input);
113
			} catch (ZipException e) {
118
			} catch (ZipException e) {
114
				// TODO Auto-generated catch block
119
				if (options.verbose)
115
				e.printStackTrace();
120
					e.printStackTrace();
116
			} catch (IOException e) {
121
			} catch (IOException e) {
117
				// TODO Auto-generated catch block
122
				if (options.verbose)
118
				e.printStackTrace();
123
					e.printStackTrace();
119
			}
124
			}
120
		} else {
125
		} else {
121
			JarProcessor processor = new JarProcessor();
126
			JarProcessor processor = new JarProcessor();
122
			processor.setWorkingDirectory(options.outputDir);
127
			processor.setWorkingDirectory(options.outputDir);
128
			processor.setVerbose(options.verbose);
123
129
124
			if (options.repack || (options.pack && options.signCommand != null))
130
			if (options.repack || (options.pack && options.signCommand != null))
125
				processor.addProcessStep(new PackUnpackStep(null));
131
				processor.addProcessStep(new PackUnpackStep(null, options.verbose));
126
132
127
			if (options.signCommand != null)
133
			if (options.signCommand != null)
128
				processor.addProcessStep(new SignCommandStep(null, options.signCommand));
134
				processor.addProcessStep(new SignCommandStep(null, options.signCommand, options.verbose));
129
135
130
			if (options.pack)
136
			if (options.pack)
131
				processor.addProcessStep(new PackStep(null));
137
				processor.addProcessStep(new PackStep(null, options.verbose));
132
			else if (options.unpack)
138
			else if (options.unpack)
133
				processor.addProcessStep(new UnpackStep(null));
139
				processor.addProcessStep(new UnpackStep(null, options.verbose));
134
140
135
			try {
141
			try {
136
				processor.process(options.input, options.unpack ? Utils.PACK_GZ_FILTER : Utils.JAR_FILTER);
142
				processor.process(options.input, options.unpack ? Utils.PACK_GZ_FILTER : Utils.JAR_FILTER);
137
			} catch (FileNotFoundException e) {
143
			} catch (FileNotFoundException e) {
138
				// TODO Auto-generated catch block
144
				if (options.verbose)
139
				e.printStackTrace();
145
					e.printStackTrace();
140
			}
146
			}
141
		}
147
		}
142
	}
148
	}
(-)src/org/eclipse/update/internal/jarprocessor/IProcessStep.java (-3 / +9 lines)
Lines 25-31 Link Here
25
	 * @param entryName
25
	 * @param entryName
26
	 * @return
26
	 * @return
27
	 */
27
	 */
28
	String recursionEffect(String entryName);
28
	public String recursionEffect(String entryName);
29
	
29
	
30
	/**
30
	/**
31
	 * Perform some processing on the input file before the JarProcessor considers the entries for recursion.
31
	 * Perform some processing on the input file before the JarProcessor considers the entries for recursion.
Lines 34-40 Link Here
34
	 * @param workingDirectory
34
	 * @param workingDirectory
35
	 * @return
35
	 * @return
36
	 */
36
	 */
37
	File preProcess(File input, File workingDirectory);
37
	public File preProcess(File input, File workingDirectory);
38
	
38
	
39
	/**
39
	/**
40
	 * Perform some processing on the input file after the JarProcessor returns from recursion
40
	 * Perform some processing on the input file after the JarProcessor returns from recursion
Lines 43-47 Link Here
43
	 * @param workingDirectory
43
	 * @param workingDirectory
44
	 * @return
44
	 * @return
45
	 */
45
	 */
46
	File postProcess(File input, File workingDirectory);
46
	public File postProcess(File input, File workingDirectory);
47
	
48
	/**
49
	 * Return the name of this process step
50
	 * @return
51
	 */
52
	public String getStepName();
47
}
53
}
(-)src/org/eclipse/update/internal/jarprocessor/PackUnpackStep.java (-5 / +16 lines)
Lines 21-34 Link Here
21
 */
21
 */
22
public class PackUnpackStep extends PackStep {
22
public class PackUnpackStep extends PackStep {
23
	private Set exclusions = null;
23
	private Set exclusions = null;
24
	
24
25
	public PackUnpackStep(Properties options) {
25
	public PackUnpackStep(Properties options) {
26
		super(options);
26
		super(options);
27
		exclusions = Utils.getPackExclusions(options);
27
		exclusions = Utils.getPackExclusions(options);
28
	}
28
	}
29
29
30
	public PackUnpackStep(Properties options, boolean verbose) {
31
		super(options, verbose);
32
		exclusions = Utils.getPackExclusions(options);
33
	}
34
30
	public String recursionEffect(String entryName) {
35
	public String recursionEffect(String entryName) {
31
		if (canPack() && entryName.endsWith(".jar") &&  !exclusions.contains(entryName)) { //$NON-NLS-1$
36
		if (canPack() && entryName.endsWith(".jar") && !exclusions.contains(entryName)) { //$NON-NLS-1$
32
			return entryName;
37
			return entryName;
33
		}
38
		}
34
		return null;
39
		return null;
Lines 47-62 Link Here
47
				cmd[1] = "-r"; //$NON-NLS-1$
52
				cmd[1] = "-r"; //$NON-NLS-1$
48
				System.arraycopy(tmp, 1, cmd, 2, tmp.length - 1);
53
				System.arraycopy(tmp, 1, cmd, 2, tmp.length - 1);
49
54
50
				int result = execute(cmd);
55
				int result = execute(cmd, verbose);
51
				if (result == 0 && tempFile.exists()) {
56
				if (result == 0 && tempFile.exists()) {
52
					File finalFile = new File(workingDirectory, input.getName());
57
					File finalFile = new File(workingDirectory, input.getName());
53
					if(finalFile.exists())
58
					if (finalFile.exists())
54
						finalFile.delete();
59
						finalFile.delete();
55
					tempFile.renameTo(finalFile);
60
					tempFile.renameTo(finalFile);
56
					return finalFile;
61
					return finalFile;
62
				} else if (verbose) {
63
					System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$
57
				}
64
				}
58
			} catch (IOException e) {
65
			} catch (IOException e) {
59
				//didn't work
66
				if (verbose)
67
					e.printStackTrace();
60
				return null;
68
				return null;
61
			}
69
			}
62
		}
70
		}
Lines 70-73 Link Here
70
		return null;
78
		return null;
71
	}
79
	}
72
80
81
	public String getStepName() {
82
		return "Repack"; //$NON-NLS-1$
83
	}
73
}
84
}
(-)src/org/eclipse/update/internal/jarprocessor/ZipProcessor.java (-6 / +20 lines)
Lines 34-39 Link Here
34
	private boolean signing = false;
34
	private boolean signing = false;
35
	private boolean repacking = false;
35
	private boolean repacking = false;
36
	private boolean unpacking = false;
36
	private boolean unpacking = false;
37
	private boolean verbose = false;
37
38
38
	public void setWorkingDirectory(String dir) {
39
	public void setWorkingDirectory(String dir) {
39
		workingDirectory = dir;
40
		workingDirectory = dir;
Lines 62-74 Link Here
62
		this.unpacking = unpack;
63
		this.unpacking = unpack;
63
	}
64
	}
64
65
66
	public void setVerbose(boolean verbose) {
67
		this.verbose = verbose;
68
	}
69
65
	public void processZip(File zipFile) throws ZipException, IOException {
70
	public void processZip(File zipFile) throws ZipException, IOException {
71
		if (verbose)
72
			System.out.println("Processing " + zipFile.getPath()); //$NON-NLS-1$
66
		ZipFile zip = new ZipFile(zipFile);
73
		ZipFile zip = new ZipFile(zipFile);
67
		initialize(zip);
74
		initialize(zip);
68
75
69
		String extension = unpacking ? "pack.gz" : ".jar"; //$NON-NLS-1$ //$NON-NLS-2$
76
		String extension = unpacking ? "pack.gz" : ".jar"; //$NON-NLS-1$ //$NON-NLS-2$
70
		File tempDir = new File(getWorkingDirectory(), "temp_" + zipFile.getName()); //$NON-NLS-1$
77
		File tempDir = new File(getWorkingDirectory(), "temp_" + zipFile.getName()); //$NON-NLS-1$
71
		JarProcessor processor = new JarProcessor();
78
		JarProcessor processor = new JarProcessor();
79
		processor.setVerbose(verbose);
72
		processor.setWorkingDirectory(tempDir.getCanonicalPath());
80
		processor.setWorkingDirectory(tempDir.getCanonicalPath());
73
		if (unpacking) {
81
		if (unpacking) {
74
			processor.addProcessStep(unpackStep);
82
			processor.addProcessStep(unpackStep);
Lines 97-102 Link Here
97
					parent = extractedFile.getParentFile();
105
					parent = extractedFile.getParentFile();
98
					if (!parent.exists())
106
					if (!parent.exists())
99
						parent.mkdirs();
107
						parent.mkdirs();
108
					if (verbose)
109
						System.out.println("Extracting " + entry.getName()); //$NON-NLS-1$
100
					FileOutputStream extracted = new FileOutputStream(extractedFile);
110
					FileOutputStream extracted = new FileOutputStream(extractedFile);
101
					Utils.transferStreams(entryStream, extracted, true);
111
					Utils.transferStreams(entryStream, extracted, true);
102
112
Lines 127-132 Link Here
127
						}
137
						}
128
					}
138
					}
129
					entryStream = new FileInputStream(extractedFile);
139
					entryStream = new FileInputStream(extractedFile);
140
					if (verbose) {
141
						System.out.println("Adding " + entry.getName() + " to " + outputFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$
142
						System.out.println();
143
					}
130
				}
144
				}
131
				ZipEntry newEntry = new ZipEntry(name);
145
				ZipEntry newEntry = new ZipEntry(name);
132
				zipOut.putNextEntry(newEntry);
146
				zipOut.putNextEntry(newEntry);
Lines 158-165 Link Here
158
				stream = zip.getInputStream(entry);
172
				stream = zip.getInputStream(entry);
159
				properties.load(stream);
173
				properties.load(stream);
160
			} catch (IOException e) {
174
			} catch (IOException e) {
161
				// TODO Auto-generated catch block
175
				if (verbose)
162
				e.printStackTrace();
176
					e.printStackTrace();
163
			} finally {
177
			} finally {
164
				Utils.close(stream);
178
				Utils.close(stream);
165
			}
179
			}
Lines 168-176 Link Here
168
		packExclusions = Utils.getPackExclusions(properties);
182
		packExclusions = Utils.getPackExclusions(properties);
169
		signExclusions = Utils.getSignExclusions(properties);
183
		signExclusions = Utils.getSignExclusions(properties);
170
184
171
		packUnpackStep = new PackUnpackStep(properties);
185
		packUnpackStep = new PackUnpackStep(properties, verbose);
172
		packStep = new PackStep(properties);
186
		packStep = new PackStep(properties, verbose);
173
		signStep = new SignCommandStep(properties, command);
187
		signStep = new SignCommandStep(properties, command, verbose);
174
		unpackStep = new UnpackStep(properties);
188
		unpackStep = new UnpackStep(properties, verbose);
175
	}
189
	}
176
}
190
}
(-)src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java (-5 / +20 lines)
Lines 22-28 Link Here
22
	private Set exclusions = null;
22
	private Set exclusions = null;
23
23
24
	public SignCommandStep(Properties options, String command) {
24
	public SignCommandStep(Properties options, String command) {
25
		super(options, command, ".jar"); //$NON-NLS-1$
25
		super(options, command, ".jar", false); //$NON-NLS-1$
26
		exclusions = Utils.getSignExclusions(options);
27
	}
28
29
	public SignCommandStep(Properties options, String command, boolean verbose) {
30
		super(options, command, ".jar", verbose); //$NON-NLS-1$
26
		exclusions = Utils.getSignExclusions(options);
31
		exclusions = Utils.getSignExclusions(options);
27
	}
32
	}
28
33
Lines 49-62 Link Here
49
		if (command != null) {
54
		if (command != null) {
50
			try {
55
			try {
51
				String[] cmd = new String[] {command, input.getCanonicalPath()};
56
				String[] cmd = new String[] {command, input.getCanonicalPath()};
52
				int result = execute(cmd);
57
				int result = execute(cmd, verbose);
53
				if (result == 0) {
58
				if (result == 0) {
54
					normalize(input, workingDirectory);
59
					normalize(input, workingDirectory);
55
					return input;
60
					return input;
61
				} else if (verbose) {
62
					System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$
56
				}
63
				}
57
			} catch (IOException e) {
64
			} catch (IOException e) {
58
				//boo
65
				if (verbose) {
59
				e.printStackTrace();
66
					e.printStackTrace();
67
				}
60
			}
68
			}
61
		}
69
		}
62
		return null;
70
		return null;
Lines 88-94 Link Here
88
			input.delete();
96
			input.delete();
89
			tempJar.renameTo(input);
97
			tempJar.renameTo(input);
90
		} catch (IOException e) {
98
		} catch (IOException e) {
91
			//boo
99
			if (verbose) {
100
				System.out.println("Error normalizing jar " + input.getName()); //$NON-NLS-1$
101
				e.printStackTrace();
102
			}
92
		}
103
		}
93
	}
104
	}
105
106
	public String getStepName() {
107
		return "Sign"; //$NON-NLS-1$
108
	}
94
}
109
}
(-)src/org/eclipse/update/internal/jarprocessor/Utils.java (+10 lines)
Lines 175-178 Link Here
175
		}
175
		}
176
		return Collections.EMPTY_SET;
176
		return Collections.EMPTY_SET;
177
	}
177
	}
178
	
179
	public static String concat(String [] array){
180
		StringBuffer buffer = new StringBuffer();
181
		for (int i = 0; i < array.length; i++) {
182
			if( i > 0 )
183
				buffer.append(' ');
184
			buffer.append(array[i]);
185
		}
186
		return buffer.toString();
187
	}
178
}
188
}
(-)src/org/eclipse/update/internal/jarprocessor/CommandStep.java (-5 / +20 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.update.internal.jarprocessor;
11
package org.eclipse.update.internal.jarprocessor;
12
12
13
import java.io.IOException;
14
import java.util.Properties;
13
import java.util.Properties;
15
14
16
/**
15
/**
Lines 21-41 Link Here
21
	protected String command = null;
20
	protected String command = null;
22
	protected String extension = null;
21
	protected String extension = null;
23
	private  Properties options = null;
22
	private  Properties options = null;
23
	protected boolean verbose = false;
24
	
24
	
25
	public CommandStep(Properties options, String command, String extension) {
25
	public CommandStep(Properties options, String command, String extension, boolean verbose) {
26
		this.command = command;
26
		this.command = command;
27
		this.extension = extension;
27
		this.extension = extension;
28
		this.options = options;
28
		this.options = options;
29
		this.verbose = verbose;
29
	}
30
	}
30
31
31
	protected static int execute(String[] cmd) throws IOException {
32
	protected static int execute(String[] cmd) {
33
		return execute(cmd, false);
34
	}
35
	
36
	protected static int execute(String[] cmd, boolean verbose) {
32
		Runtime runtime = Runtime.getRuntime();
37
		Runtime runtime = Runtime.getRuntime();
33
		Process proc = runtime.exec(cmd);
38
		Process proc = null;
39
		try {
40
			proc = runtime.exec(cmd);
41
		} catch (Exception e) {
42
			if(verbose) {
43
				System.out.println("Error executing command " + Utils.concat(cmd)); //$NON-NLS-1$
44
				e.printStackTrace();
45
			}
46
			return -1;
47
		}
34
		try {
48
		try {
35
			int result = proc.waitFor();
49
			int result = proc.waitFor();
36
			return result;
50
			return result;
37
		} catch (InterruptedException e) {
51
		} catch (InterruptedException e) {
38
			//ignore
52
			if(verbose)
53
				e.printStackTrace();
39
		}
54
		}
40
		return -1;
55
		return -1;
41
	}
56
	}
(-)src/org/eclipse/update/internal/jarprocessor/UnpackStep.java (-12 / +19 lines)
Lines 38-52 Link Here
38
		for (int i = 0; i < locations.length; i++) {
38
		for (int i = 0; i < locations.length; i++) {
39
			if (locations[i] == null)
39
			if (locations[i] == null)
40
				continue;
40
				continue;
41
			try {
41
			result = execute(new String[] {locations[i], "-V"}); //$NON-NLS-1$
42
				result = execute(new String[] {locations[i], "-V"}); //$NON-NLS-1$
42
			if (result == 0) {
43
				if (result == 0) {
43
				unpackCommand = locations[i];
44
					unpackCommand = locations[i];
44
				canUnpack = Boolean.TRUE;
45
					canUnpack = Boolean.TRUE;
45
				return true;
46
					return true;
47
				}
48
			} catch (IOException e) {
49
				//no good
50
			}
46
			}
51
		}
47
		}
52
48
Lines 55-61 Link Here
55
	}
51
	}
56
52
57
	public UnpackStep(Properties options) {
53
	public UnpackStep(Properties options) {
58
		super(options, null, null);
54
		super(options, null, null, false);
55
	}
56
57
	public UnpackStep(Properties options, boolean verbose) {
58
		super(options, null, null, verbose);
59
	}
59
	}
60
60
61
	/* (non-Javadoc)
61
	/* (non-Javadoc)
Lines 89-97 Link Here
89
					} else {
89
					} else {
90
						cmd = new String[] {unpackCommand, input.getCanonicalPath(), unpacked.getCanonicalPath()};
90
						cmd = new String[] {unpackCommand, input.getCanonicalPath(), unpacked.getCanonicalPath()};
91
					}
91
					}
92
					execute(cmd);
92
					int result = execute(cmd, verbose);
93
					if (result != 0 && verbose)
94
						System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$
93
				} catch (IOException e) {
95
				} catch (IOException e) {
94
					//didn't work
96
					if (verbose)
97
						e.printStackTrace();
95
					return null;
98
					return null;
96
				}
99
				}
97
				return unpacked;
100
				return unpacked;
Lines 106-109 Link Here
106
	public File postProcess(File input, File workingDirectory) {
109
	public File postProcess(File input, File workingDirectory) {
107
		return null;
110
		return null;
108
	}
111
	}
112
113
	public String getStepName() {
114
		return "Unpack"; //$NON-NLS-1$
115
	}
109
}
116
}
(-)src/org/eclipse/update/internal/jarprocessor/JarProcessor.java (-3 / +20 lines)
Lines 22-27 Link Here
22
	private List steps = new ArrayList();
22
	private List steps = new ArrayList();
23
	private String workingDirectory = ""; //$NON-NLS-1$
23
	private String workingDirectory = ""; //$NON-NLS-1$
24
	private int depth = -1;
24
	private int depth = -1;
25
	private boolean verbose = false;
25
26
26
	static public JarProcessor getUnpackProcessor(Properties properties) {
27
	static public JarProcessor getUnpackProcessor(Properties properties) {
27
		if (!canPerformUnpack())
28
		if (!canPerformUnpack())
Lines 54-59 Link Here
54
	public void setWorkingDirectory(String dir) {
55
	public void setWorkingDirectory(String dir) {
55
		workingDirectory = dir;
56
		workingDirectory = dir;
56
	}
57
	}
58
	
59
	public void setVerbose(boolean verbose) {
60
		this.verbose = verbose;
61
	}
57
62
58
	public void addProcessStep(IProcessStep step) {
63
	public void addProcessStep(IProcessStep step) {
59
		steps.add(step);
64
		steps.add(step);
Lines 74-80 Link Here
74
			files = new File[] {input};
79
			files = new File[] {input};
75
		}
80
		}
76
		for (int i = 0; i < files.length; i++) {
81
		for (int i = 0; i < files.length; i++) {
77
			System.out.println("Processing " + files[i].getName()); //$NON-NLS-1$
78
			if (files[i].isDirectory()) {
82
			if (files[i].isDirectory()) {
79
				String dir = getWorkingDirectory();
83
				String dir = getWorkingDirectory();
80
				setWorkingDirectory(dir + "/" + files[i].getName()); //$NON-NLS-1$
84
				setWorkingDirectory(dir + "/" + files[i].getName()); //$NON-NLS-1$
Lines 84-91 Link Here
84
				try {
88
				try {
85
					processJar(files[i]);
89
					processJar(files[i]);
86
				} catch (IOException e) {
90
				} catch (IOException e) {
87
					// TODO Auto-generated catch block
91
					if(verbose)
88
					e.printStackTrace();
92
						e.printStackTrace();
89
				}
93
				}
90
			}
94
			}
91
		}
95
		}
Lines 154-159 Link Here
154
				String name = entry.getName();
158
				String name = entry.getName();
155
				String newName = recursionEffect(name);
159
				String newName = recursionEffect(name);
156
				if (newName != null) {
160
				if (newName != null) {
161
					if(verbose){
162
						for(int i = 0; i <= depth; i++)
163
							System.out.print("  "); //$NON-NLS-1$
164
						System.out.println("Processing nested file: " + name); //$NON-NLS-1$
165
					}
157
					//extract entry to temp directory
166
					//extract entry to temp directory
158
					File extracted = new File(tempDir, name);
167
					File extracted = new File(tempDir, name);
159
					File parentDir = extracted.getParentFile();
168
					File parentDir = extracted.getParentFile();
Lines 216-221 Link Here
216
		if (!workingDir.exists())
225
		if (!workingDir.exists())
217
			workingDir.mkdirs();
226
			workingDir.mkdirs();
218
227
228
		if(depth == 0 && verbose) {
229
			System.out.print("Running "); //$NON-NLS-1$ 
230
			for (Iterator iter = steps.iterator(); iter.hasNext();) {
231
				IProcessStep step = (IProcessStep) iter.next();
232
				System.out.print(step.getStepName() + " "); //$NON-NLS-1$
233
			}
234
			System.out.println("on " + input.getPath()); //$NON-NLS-1$
235
		}
219
		//pre
236
		//pre
220
		File workingFile = preProcess(input, workingDir);
237
		File workingFile = preProcess(input, workingDir);
221
238
(-)src/org/eclipse/update/internal/jarprocessor/PackStep.java (-12 / +20 lines)
Lines 36-50 Link Here
36
		for (int i = 0; i < locations.length; i++) {
36
		for (int i = 0; i < locations.length; i++) {
37
			if (locations[i] == null)
37
			if (locations[i] == null)
38
				continue;
38
				continue;
39
			try {
39
			result = execute(new String[] {locations[i], "-V"}); //$NON-NLS-1$
40
				result = execute(new String[] {locations[i], "-V"}); //$NON-NLS-1$
40
			if (result == 0) {
41
				if (result == 0) {
41
				packCommand = locations[i];
42
					packCommand = locations[i];
42
				canPack = Boolean.TRUE;
43
					canPack = Boolean.TRUE;
43
				return true;
44
					return true;
45
				}
46
			} catch (IOException e) {
47
				//no good
48
			}
44
			}
49
		}
45
		}
50
46
Lines 53-59 Link Here
53
	}
49
	}
54
50
55
	public PackStep(Properties options) {
51
	public PackStep(Properties options) {
56
		super(options, null, null);
52
		super(options, null, null, false);
53
		exclusions = Utils.getPackExclusions(options);
54
	}
55
56
	public PackStep(Properties options, boolean verbose) {
57
		super(options, null, null, verbose);
57
		exclusions = Utils.getPackExclusions(options);
58
		exclusions = Utils.getPackExclusions(options);
58
	}
59
	}
59
60
Lines 73-81 Link Here
73
			File outputFile = new File(workingDirectory, input.getName() + Utils.PACKED_SUFFIX);
74
			File outputFile = new File(workingDirectory, input.getName() + Utils.PACKED_SUFFIX);
74
			try {
75
			try {
75
				String[] cmd = getCommand(input, outputFile);
76
				String[] cmd = getCommand(input, outputFile);
76
				execute(cmd);
77
				int result = execute(cmd, verbose);
78
				if (result != 0 && verbose)
79
					System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$
77
			} catch (IOException e) {
80
			} catch (IOException e) {
78
				//didn't work
81
				if (verbose)
82
					e.printStackTrace();
79
				return null;
83
				return null;
80
			}
84
			}
81
			return outputFile;
85
			return outputFile;
Lines 98-101 Link Here
98
		}
102
		}
99
		return cmd;
103
		return cmd;
100
	}
104
	}
105
106
	public String getStepName() {
107
		return "Pack"; //$NON-NLS-1$
108
	}
101
}
109
}
(-)src/org/eclipse/update/internal/provisional/SiteOptimizerApplication.java (+2 lines)
Lines 63-68 Link Here
63
	public final static String DIGEST_BUILDER = "-digestBuilder"; //$NON-NLS-1$
63
	public final static String DIGEST_BUILDER = "-digestBuilder"; //$NON-NLS-1$
64
	public final static String INPUT = "input"; //$NON-NLS-1$
64
	public final static String INPUT = "input"; //$NON-NLS-1$
65
	public final static String OUTPUT_DIR = "-outputDir"; //$NON-NLS-1$
65
	public final static String OUTPUT_DIR = "-outputDir"; //$NON-NLS-1$
66
	public final static String VERBOSE = "-verbose"; //$NON-NLS-1$
66
	
67
	
67
	public final static String JAR_PROCESSOR_PACK = "-pack"; //$NON-NLS-1$
68
	public final static String JAR_PROCESSOR_PACK = "-pack"; //$NON-NLS-1$
68
	public final static String JAR_PROCESSOR_UNPACK = "-unpack"; //$NON-NLS-1$
69
	public final static String JAR_PROCESSOR_UNPACK = "-unpack"; //$NON-NLS-1$
Lines 123-128 Link Here
123
		options.pack = params.containsKey(JAR_PROCESSOR_PACK);
124
		options.pack = params.containsKey(JAR_PROCESSOR_PACK);
124
		options.unpack = params.containsKey(JAR_PROCESSOR_UNPACK);
125
		options.unpack = params.containsKey(JAR_PROCESSOR_UNPACK);
125
		options.repack = params.containsKey(JAR_PROCESSOR_REPACK);
126
		options.repack = params.containsKey(JAR_PROCESSOR_REPACK);
127
		options.verbose = params.containsKey(VERBOSE);
126
		options.signCommand = (String) params.get(JAR_PROCESSOR_SIGN);
128
		options.signCommand = (String) params.get(JAR_PROCESSOR_SIGN);
127
		options.outputDir = (String) params.get(OUTPUT_DIR);
129
		options.outputDir = (String) params.get(OUTPUT_DIR);
128
		
130
		

Return to bug 127375