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

Collapse All | Expand All

(-)src/org/eclipse/update/internal/jarprocessor/Utils.java (-12 / +47 lines)
Lines 19-34 Link Here
19
 *
19
 *
20
 */
20
 */
21
public class Utils {
21
public class Utils {
22
	public static final String MARK_FILE_NAME = "META-INF/eclipse.inf"; //$NON-NLS-1$
23
	
24
	/*
25
	 * Properties found in outer pack.properties file
26
	 */
27
	//comma separated list of jars to exclude from sigining
22
	public static final String SIGN_EXCLUDES = "sign.excludes"; //$NON-NLS-1$
28
	public static final String SIGN_EXCLUDES = "sign.excludes"; //$NON-NLS-1$
29
	//comma separated list of jars to exlclude from packing
23
	public static final String PACK_EXCLUDES = "pack.excludes"; //$NON-NLS-1$
30
	public static final String PACK_EXCLUDES = "pack.excludes"; //$NON-NLS-1$
24
	public static final String MARK_FILE_NAME = "META-INF/eclipse.inf"; //$NON-NLS-1$
31
	//Suffix used when specifying arguments to use when running pack200 on a jar
32
	public static final String PACK_ARGS_SUFFIX = ".pack.args"; //$NON-NLS-1$
33
	
34
	/*
35
	 * Properties found in both pack.properties and eclipse.inf
36
	 */
37
	//	Default arguments to use when running pack200.
38
	// Affects all jars when specified in pack.properties, affects children when specified in eclipse.inf
39
	public static final String DEFAULT_PACK_ARGS = "pack200.default.args"; //$NON-NLS-1$
40
	
41
	/*
42
	 * Properties found in eclipse.inf file
43
	 */
44
	//This jar has been conditioned with pack200
25
	public static final String MARK_PROPERTY = "pack200.conditioned"; //$NON-NLS-1$
45
	public static final String MARK_PROPERTY = "pack200.conditioned"; //$NON-NLS-1$
46
	//Exclude this jar from processing
26
	public static final String MARK_EXCLUDE = "jarprocessor.exclude"; //$NON-NLS-1$
47
	public static final String MARK_EXCLUDE = "jarprocessor.exclude"; //$NON-NLS-1$
48
	//Exclude this jar from pack200
27
	public static final String MARK_EXCLUDE_PACK = "jarprocessor.exclude.pack"; //$NON-NLS-1$
49
	public static final String MARK_EXCLUDE_PACK = "jarprocessor.exclude.pack"; //$NON-NLS-1$
50
	//Exclude this jar from signing
28
	public static final String MARK_EXCLUDE_SIGN = "jarprocessor.exclude.sign"; //$NON-NLS-1$
51
	public static final String MARK_EXCLUDE_SIGN = "jarprocessor.exclude.sign"; //$NON-NLS-1$
29
	public static final String MARK_JARPROCESSOR_VERSION = "jarprocessor.version"; //$NON-NLS-1$
52
	//Exclude this jar's children from processing
53
	public static final String MARK_EXCLUDE_CHILDREN = "jarprocessor.exclude.children";
54
	//Exclude this jar's children from pack200
55
	public static final String MARK_EXCLUDE_CHILDREN_PACK = "jarprocessor.exclude.children.pack";
56
	//Exclude this jar's children from signing
57
	public static final String MARK_EXCLUDE_CHILDREN_SIGN = "jarprocessor.exclude.children.sign";
58
	//Arguments used in pack200 for this jar
30
	public static final String PACK_ARGS = "pack200.args"; //$NON-NLS-1$
59
	public static final String PACK_ARGS = "pack200.args"; //$NON-NLS-1$
31
60
	
32
	public static final String PACK200_PROPERTY = "org.eclipse.update.jarprocessor.pack200"; //$NON-NLS-1$
61
	public static final String PACK200_PROPERTY = "org.eclipse.update.jarprocessor.pack200"; //$NON-NLS-1$
33
	public static final String JRE = "@jre"; //$NON-NLS-1$
62
	public static final String JRE = "@jre"; //$NON-NLS-1$
34
	public static final String PATH = "@path"; //$NON-NLS-1$
63
	public static final String PATH = "@path"; //$NON-NLS-1$
Lines 185-195 Link Here
185
		}
214
		}
186
		return Collections.EMPTY_SET;
215
		return Collections.EMPTY_SET;
187
	}
216
	}
188
	
217
189
	public static String concat(String [] array){
218
	public static String concat(String[] array) {
190
		StringBuffer buffer = new StringBuffer();
219
		StringBuffer buffer = new StringBuffer();
191
		for (int i = 0; i < array.length; i++) {
220
		for (int i = 0; i < array.length; i++) {
192
			if( i > 0 )
221
			if (i > 0)
193
				buffer.append(' ');
222
				buffer.append(' ');
194
			buffer.append(array[i]);
223
			buffer.append(array[i]);
195
		}
224
		}
Lines 210-221 Link Here
210
	 * Get the properties from the eclipse.inf file from the given jar.  If the file is not a jar, null is returned.
239
	 * Get the properties from the eclipse.inf file from the given jar.  If the file is not a jar, null is returned.
211
	 * If the file is a jar, but does not contain an eclipse.inf file, an empty Properties object is returned.
240
	 * If the file is a jar, but does not contain an eclipse.inf file, an empty Properties object is returned.
212
	 * @param jarFile
241
	 * @param jarFile
213
	 * @return
242
	 * @return The eclipse.inf properties for the given jar file
214
	 */
243
	 */
215
	public static Properties getEclipseInf(File jarFile) {
244
	public static Properties getEclipseInf(File jarFile, boolean verbose) {
216
		if (jarFile == null || !jarFile.exists())
245
		if (jarFile == null || !jarFile.exists()) {
246
			if (verbose)
247
				System.out.println("Failed to obtain eclipse.inf due to missing jar file: " + jarFile);
217
			return null;
248
			return null;
218
249
		}
219
		JarFile jar = null;
250
		JarFile jar = null;
220
		try {
251
		try {
221
			jar = new JarFile(jarFile, false);
252
			jar = new JarFile(jarFile, false);
Lines 229-243 Link Here
229
			}
260
			}
230
			return new Properties();
261
			return new Properties();
231
		} catch (IOException e) {
262
		} catch (IOException e) {
263
			if (verbose) {
264
				System.out.println("Failed to obtain eclipse.inf due to IOException: " + jarFile);
265
				e.printStackTrace();
266
			}
232
			//not a jar
267
			//not a jar
268
			return null;
233
		} finally {
269
		} finally {
234
			close(jar);
270
			close(jar);
235
		}
271
		}
236
		return null;
237
	}
272
	}
238
273
239
	public static boolean shouldSkipJar(File input, boolean processAll, boolean verbose) {
274
	public static boolean shouldSkipJar(File input, boolean processAll, boolean verbose) {
240
		Properties inf = getEclipseInf(input);
275
		Properties inf = getEclipseInf(input, verbose);
241
		if (inf == null) {
276
		if (inf == null) {
242
			//not a jar, could be a pack.gz
277
			//not a jar, could be a pack.gz
243
			return false;
278
			return false;
(-)src/org/eclipse/update/internal/jarprocessor/PackUnpackStep.java (-10 / +8 lines)
Lines 12-17 Link Here
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.util.List;
15
import java.util.Properties;
16
import java.util.Properties;
16
import java.util.Set;
17
import java.util.Set;
17
18
Lines 40-58 Link Here
40
	}
41
	}
41
42
42
	/* (non-Javadoc)
43
	/* (non-Javadoc)
43
	 * @see org.eclipse.update.jarprocessor.IProcessStep#preProcess(java.io.File, java.io.File)
44
	 * @see org.eclipse.update.internal.jarprocessor.PackStep#postProcess(java.io.File, java.io.File, java.util.LinkedList)
44
	 */
45
	 */
45
	public File postProcess(File input, File workingDirectory) {
46
	public File postProcess(File input, File workingDirectory, List containers) {
46
		if (canPack() && packCommand != null) {
47
		if (canPack() && packCommand != null) {
47
			Properties inf = Utils.getEclipseInf(input);
48
			Properties inf = Utils.getEclipseInf(input, verbose);
48
			if (inf != null && inf.containsKey(Utils.MARK_EXCLUDE_PACK) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_PACK)).booleanValue()) {
49
			if (!shouldPack(input, containers, inf))
49
				if (verbose)
50
					System.out.println("Excluding " + input.getName() + " from " + getStepName()); //$NON-NLS-1$ //$NON-NLS-2$
51
				return null;
50
				return null;
52
			}
53
			File tempFile = new File(workingDirectory, "temp_" + input.getName()); //$NON-NLS-1$
51
			File tempFile = new File(workingDirectory, "temp_" + input.getName()); //$NON-NLS-1$
54
			try {
52
			try {
55
				String[] tmp = getCommand(input, tempFile, inf);
53
				String[] tmp = getCommand(input, tempFile, inf, containers);
56
				String[] cmd = new String[tmp.length + 1];
54
				String[] cmd = new String[tmp.length + 1];
57
				cmd[0] = tmp[0];
55
				cmd[0] = tmp[0];
58
				cmd[1] = "-r"; //$NON-NLS-1$
56
				cmd[1] = "-r"; //$NON-NLS-1$
Lines 78-86 Link Here
78
	}
76
	}
79
77
80
	/* (non-Javadoc)
78
	/* (non-Javadoc)
81
	 * @see org.eclipse.update.jarprocessor.IProcessStep#postProcess(java.io.File, java.io.File)
79
	 * @see org.eclipse.update.internal.jarprocessor.PackStep#preProcess(java.io.File, java.io.File, java.util.LinkedList)
82
	 */
80
	 */
83
	public File preProcess(File input, File workingDirectory) {
81
	public File preProcess(File input, File workingDirectory, List containers) {
84
		return null;
82
		return null;
85
	}
83
	}
86
84
(-)src/org/eclipse/update/internal/jarprocessor/PackStep.java (-21 / +87 lines)
Lines 12-24 Link Here
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.util.*;
15
import java.util.Collections;
16
import java.util.Iterator;
17
import java.util.List;
18
import java.util.Properties;
19
import java.util.Set;
16
20
17
public class PackStep extends CommandStep {
21
public class PackStep extends CommandStep {
18
22
19
	protected static String packCommand = null;
23
	protected static String packCommand = null;
20
	private static Boolean canPack = null;
24
	private static Boolean canPack = null;
21
25
26
	private String arguments = null;
22
	private Set exclusions = Collections.EMPTY_SET;
27
	private Set exclusions = Collections.EMPTY_SET;
23
28
24
	public static boolean canPack() {
29
	public static boolean canPack() {
Lines 65-85 Link Here
65
		return null;
70
		return null;
66
	}
71
	}
67
72
68
	public File preProcess(File input, File workingDirectory) {
73
	public File preProcess(File input, File workingDirectory, List containers) {
69
		return null;
74
		return null;
70
	}
75
	}
71
76
72
	public File postProcess(File input, File workingDirectory) {
77
	public File postProcess(File input, File workingDirectory, List containers) {
73
		if (canPack() && packCommand != null) {
78
		if (canPack() && packCommand != null) {
74
			Properties inf = Utils.getEclipseInf(input);
79
			Properties inf = Utils.getEclipseInf(input, verbose);
75
			if (inf != null && inf.containsKey(Utils.MARK_EXCLUDE_PACK) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_PACK)).booleanValue()) {
80
			if (!shouldPack(input, containers, inf))
76
				if(verbose)
77
					System.out.println("Excluding " + input.getName() + " from " + getStepName()); //$NON-NLS-1$ //$NON-NLS-2$
78
				return null;
81
				return null;
79
			}
80
			File outputFile = new File(workingDirectory, input.getName() + Utils.PACKED_SUFFIX);
82
			File outputFile = new File(workingDirectory, input.getName() + Utils.PACKED_SUFFIX);
81
			try {
83
			try {
82
				String[] cmd = getCommand(input, outputFile, inf);
84
				String[] cmd = getCommand(input, outputFile, inf, containers);
83
				int result = execute(cmd, verbose);
85
				int result = execute(cmd, verbose);
84
				if (result != 0 && verbose)
86
				if (result != 0 && verbose)
85
					System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$
87
					System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$
Lines 93-106 Link Here
93
		return null;
95
		return null;
94
	}
96
	}
95
97
96
	protected String[] getCommand(File input, File outputFile, Properties inf) throws IOException {
98
	protected boolean shouldPack(File input, List containers, Properties inf) {
97
		String[] cmd = null;
99
		//1: exclude by containers
98
		String arguments = null;
100
		// innermost jar is first on the list, it can override outer jars
99
		if (inf != null && inf.containsKey(Utils.PACK_ARGS)) {
101
		for (Iterator iterator = containers.iterator(); iterator.hasNext();) {
100
			arguments = inf.getProperty(Utils.PACK_ARGS);
102
			Properties container = (Properties) iterator.next();
101
		} else {
103
			if (container.containsKey(Utils.MARK_EXCLUDE_CHILDREN_PACK)) {
102
			arguments = getOptions().getProperty(input.getName() + ".pack.args"); //$NON-NLS-1$
104
				if (Boolean.valueOf(container.getProperty(Utils.MARK_EXCLUDE_CHILDREN_PACK)).booleanValue()) {
105
					if (verbose)
106
						System.out.println(input.getName() + "is excluded from pack200 by its containers.");
107
					return false;
108
				}
109
				break;
110
			}
103
		}
111
		}
112
113
		//2: excluded by self
114
		if (inf != null && inf.containsKey(Utils.MARK_EXCLUDE_PACK) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_PACK)).booleanValue()) {
115
			if (verbose)
116
				System.out.println("Excluding " + input.getName() + " from " + getStepName()); //$NON-NLS-1$ //$NON-NLS-2$
117
			return false;
118
		}
119
120
		return true;
121
	}
122
123
	protected String[] getCommand(File input, File outputFile, Properties inf, List containers) throws IOException {
124
		String[] cmd = null;
125
		String arguments = getArguments(input, inf, containers);
104
		if (arguments != null && arguments.length() > 0) {
126
		if (arguments != null && arguments.length() > 0) {
105
			String[] args = Utils.toStringArray(arguments, ","); //$NON-NLS-1$
127
			String[] args = Utils.toStringArray(arguments, ","); //$NON-NLS-1$
106
			cmd = new String[3 + args.length];
128
			cmd = new String[3 + args.length];
Lines 114-136 Link Here
114
		return cmd;
136
		return cmd;
115
	}
137
	}
116
138
139
	protected String getArguments(File input, Properties inf, List containers) {
140
		if (arguments != null)
141
			return arguments;
142
		//1: Explicitly marked in our .inf file
143
		if (inf != null && inf.containsKey(Utils.PACK_ARGS)) {
144
			arguments = inf.getProperty(Utils.PACK_ARGS);
145
			return arguments;
146
		}
147
148
		//2: Defaults set in one of our containing jars
149
		for (Iterator iterator = containers.iterator(); iterator.hasNext();) {
150
			Properties container = (Properties) iterator.next();
151
			if (container.containsKey(Utils.DEFAULT_PACK_ARGS)) {
152
				arguments = container.getProperty(Utils.DEFAULT_PACK_ARGS);
153
				return arguments;
154
			}
155
		}
156
157
		//3: Set by name in outside pack.properties file
158
		Properties options = getOptions();
159
		String argsKey = input.getName() + Utils.PACK_ARGS_SUFFIX;
160
		if (options.containsKey(argsKey)) {
161
			arguments = options.getProperty(argsKey);
162
			return arguments;
163
		}
164
165
		//4: Set by default in outside pack.properties file
166
		if (options.containsKey(Utils.DEFAULT_PACK_ARGS)) {
167
			arguments = options.getProperty(Utils.DEFAULT_PACK_ARGS);
168
			return arguments;
169
		}
170
171
		if (arguments == null)
172
			arguments = "";
173
		return arguments;
174
	}
175
117
	public String getStepName() {
176
	public String getStepName() {
118
		return "Pack"; //$NON-NLS-1$
177
		return "Pack"; //$NON-NLS-1$
119
	}
178
	}
120
	
179
121
	public void adjustInf(File input, Properties inf) {
180
	public void adjustInf(File input, Properties inf, List containers) {
122
		if (input == null || inf == null)
181
		if (input == null || inf == null)
123
			return;
182
			return;
124
183
125
		if (inf.containsKey(Utils.MARK_EXCLUDE_PACK) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_PACK)).booleanValue()) {
184
		//don't be verbose to check if we should mark the inf
185
		boolean v = verbose;
186
		verbose = false;
187
		if (!shouldPack(input, containers, inf)) {
188
			verbose = v;
126
			return;
189
			return;
127
		}
190
		}
128
191
192
		//mark as conditioned
129
		inf.put(Utils.MARK_PROPERTY, "true"); //$NON-NLS-1$
193
		inf.put(Utils.MARK_PROPERTY, "true"); //$NON-NLS-1$
194
195
		//record arguments used
130
		String arguments = inf.getProperty(Utils.PACK_ARGS);
196
		String arguments = inf.getProperty(Utils.PACK_ARGS);
131
		if (arguments == null) {
197
		if (arguments == null) {
132
			arguments = getOptions().getProperty(input.getName() + ".pack.args"); //$NON-NLS-1$
198
			arguments = getArguments(input, inf, containers);
133
			if (arguments != null)
199
			if (arguments != null && arguments.length() > 0)
134
				inf.put(Utils.PACK_ARGS, arguments);
200
				inf.put(Utils.PACK_ARGS, arguments);
135
		}
201
		}
136
	}
202
	}
(-)src/org/eclipse/update/internal/jarprocessor/Main.java (-5 / +24 lines)
Lines 11-16 Link Here
11
package org.eclipse.update.internal.jarprocessor;
11
package org.eclipse.update.internal.jarprocessor;
12
12
13
import java.io.*;
13
import java.io.*;
14
import java.util.Properties;
14
import java.util.zip.ZipException;
15
import java.util.zip.ZipException;
15
16
16
/**
17
/**
Lines 110-116 Link Here
110
	}
111
	}
111
112
112
	public static void runJarProcessor(Options options) {
113
	public static void runJarProcessor(Options options) {
113
		if (options.input.getName().endsWith(".zip")) { //$NON-NLS-1$
114
		if (options.input.isFile() && options.input.getName().endsWith(".zip")) { //$NON-NLS-1$
114
			ZipProcessor processor = new ZipProcessor();
115
			ZipProcessor processor = new ZipProcessor();
115
			processor.setWorkingDirectory(options.outputDir);
116
			processor.setWorkingDirectory(options.outputDir);
116
			processor.setSignCommand(options.signCommand);
117
			processor.setSignCommand(options.signCommand);
Lines 134-149 Link Here
134
			processor.setProcessAll(options.processAll);
135
			processor.setProcessAll(options.processAll);
135
			processor.setVerbose(options.verbose);
136
			processor.setVerbose(options.verbose);
136
137
138
			//load options file
139
			Properties properties = null;
140
			if(options.input.isDirectory()){
141
				File packProperties  = new File(options.input, "pack.properties");
142
				if(packProperties.exists() && packProperties.isFile()){
143
					InputStream in = null;
144
					try {
145
						in = new BufferedInputStream( new FileInputStream(packProperties));
146
						properties.load(in);
147
					} catch (IOException e) {
148
						if(options.verbose)
149
							e.printStackTrace();
150
					} finally {
151
						Utils.close(in);
152
					}
153
				}
154
			}
155
			
137
			if (options.repack || (options.pack && options.signCommand != null))
156
			if (options.repack || (options.pack && options.signCommand != null))
138
				processor.addProcessStep(new PackUnpackStep(null, options.verbose));
157
				processor.addProcessStep(new PackUnpackStep(properties, options.verbose));
139
158
140
			if (options.signCommand != null)
159
			if (options.signCommand != null)
141
				processor.addProcessStep(new SignCommandStep(null, options.signCommand, options.verbose));
160
				processor.addProcessStep(new SignCommandStep(properties, options.signCommand, options.verbose));
142
161
143
			if (options.pack)
162
			if (options.pack)
144
				processor.addProcessStep(new PackStep(null, options.verbose));
163
				processor.addProcessStep(new PackStep(properties, options.verbose));
145
			else if (options.unpack)
164
			else if (options.unpack)
146
				processor.addProcessStep(new UnpackStep(null, options.verbose));
165
				processor.addProcessStep(new UnpackStep(properties, options.verbose));
147
166
148
			try {
167
			try {
149
				processor.process(options.input, options.unpack ? Utils.PACK_GZ_FILTER : Utils.JAR_FILTER);
168
				processor.process(options.input, options.unpack ? Utils.PACK_GZ_FILTER : Utils.JAR_FILTER);
(-)src/org/eclipse/update/internal/jarprocessor/JarProcessor.java (-7 / +25 lines)
Lines 24-29 Link Here
24
	private int depth = -1;
24
	private int depth = -1;
25
	private boolean verbose = false;
25
	private boolean verbose = false;
26
	private boolean processAll = false;
26
	private boolean processAll = false;
27
	private LinkedList containingInfs = new LinkedList();
27
28
28
	static public JarProcessor getUnpackProcessor(Properties properties) {
29
	static public JarProcessor getUnpackProcessor(Properties properties) {
29
		if (!canPerformUnpack())
30
		if (!canPerformUnpack())
Lines 54-60 Link Here
54
	}
55
	}
55
56
56
	public void setWorkingDirectory(String dir) {
57
	public void setWorkingDirectory(String dir) {
57
		workingDirectory = dir;
58
		if(dir != null)
59
			workingDirectory = dir;
58
	}
60
	}
59
	
61
	
60
	public void setVerbose(boolean verbose) {
62
	public void setVerbose(boolean verbose) {
Lines 169-175 Link Here
169
		return result;
171
		return result;
170
	}
172
	}
171
173
172
	private void extractEntries(JarFile jar, File tempDir, Map data) throws IOException {
174
	private void extractEntries(JarFile jar, File tempDir, Map data, Properties inf) throws IOException {
175
		if(inf != null ) {
176
			//skip if excluding children
177
			if(inf.containsKey(Utils.MARK_EXCLUDE_CHILDREN)){
178
				String excludeChildren = inf.getProperty(Utils.MARK_EXCLUDE_CHILDREN);
179
				if( Boolean.valueOf(excludeChildren).booleanValue() )
180
					if(verbose){
181
						for(int i = 0; i <= depth; i++)
182
							System.out.print("  "); //$NON-NLS-1$
183
						System.out.println("Children of " + jar.getName() + "are excluded from processing.");
184
					}
185
					return;
186
			}
187
		}
188
		
173
		Enumeration entries = jar.entries();
189
		Enumeration entries = jar.entries();
174
		if (entries.hasMoreElements()) {
190
		if (entries.hasMoreElements()) {
175
			for (JarEntry entry = (JarEntry) entries.nextElement(); entry != null; entry = entries.hasMoreElements() ? (JarEntry) entries.nextElement() : null) {
191
			for (JarEntry entry = (JarEntry) entries.nextElement(); entry != null; entry = entries.hasMoreElements() ? (JarEntry) entries.nextElement() : null) {
Lines 201-210 Link Here
201
					data.put(name, newName);
217
					data.put(name, newName);
202
218
203
					//recurse
219
					//recurse
220
					containingInfs.addFirst(inf);
204
					String dir = getWorkingDirectory();
221
					String dir = getWorkingDirectory();
205
					setWorkingDirectory(parentDir.getCanonicalPath());
222
					setWorkingDirectory(parentDir.getCanonicalPath());
206
					processJar(extracted);
223
					processJar(extracted);
207
					setWorkingDirectory(dir);
224
					setWorkingDirectory(dir);
225
					containingInfs.removeFirst();
208
226
209
					//delete the extracted item leaving the recursion result
227
					//delete the extracted item leaving the recursion result
210
					if (!name.equals(newName))
228
					if (!name.equals(newName))
Lines 218-224 Link Here
218
		File result = null;
236
		File result = null;
219
		for (Iterator iter = steps.iterator(); iter.hasNext();) {
237
		for (Iterator iter = steps.iterator(); iter.hasNext();) {
220
			IProcessStep step = (IProcessStep) iter.next();
238
			IProcessStep step = (IProcessStep) iter.next();
221
			result = step.preProcess(input, tempDir);
239
			result = step.preProcess(input, tempDir, containingInfs);
222
			if (result != null)
240
			if (result != null)
223
				input = result;
241
				input = result;
224
		}
242
		}
Lines 229-235 Link Here
229
		File result = null;
247
		File result = null;
230
		for (Iterator iter = steps.iterator(); iter.hasNext();) {
248
		for (Iterator iter = steps.iterator(); iter.hasNext();) {
231
			IProcessStep step = (IProcessStep) iter.next();
249
			IProcessStep step = (IProcessStep) iter.next();
232
			result = step.postProcess(input, tempDir);
250
			result = step.postProcess(input, tempDir, containingInfs);
233
			if (result != null)
251
			if (result != null)
234
				input = result;
252
				input = result;
235
		}
253
		}
Lines 239-245 Link Here
239
	private void adjustInf(File input, Properties inf) {
257
	private void adjustInf(File input, Properties inf) {
240
		for (Iterator iter = steps.iterator(); iter.hasNext();) {
258
		for (Iterator iter = steps.iterator(); iter.hasNext();) {
241
			IProcessStep step = (IProcessStep) iter.next();
259
			IProcessStep step = (IProcessStep) iter.next();
242
			step.adjustInf(input, inf);
260
			step.adjustInf(input, inf, containingInfs);
243
		}
261
		}
244
	}
262
	}
245
263
Lines 284-292 Link Here
284
302
285
		JarFile jar = new JarFile(workingFile, false);
303
		JarFile jar = new JarFile(workingFile, false);
286
		Map replacements = new HashMap();
304
		Map replacements = new HashMap();
287
		extractEntries(jar, tempDir, replacements);
305
		Properties inf = Utils.getEclipseInf(workingFile, verbose);
306
		extractEntries(jar, tempDir, replacements, inf);
288
307
289
		Properties inf = Utils.getEclipseInf(workingFile);
290
		if (inf != null)
308
		if (inf != null)
291
			adjustInf(workingFile, inf);
309
			adjustInf(workingFile, inf);
292
310
(-)src/org/eclipse/update/internal/jarprocessor/CommandStep.java (-1 / +2 lines)
Lines 11-16 Link Here
11
package org.eclipse.update.internal.jarprocessor;
11
package org.eclipse.update.internal.jarprocessor;
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.util.List;
14
import java.util.Properties;
15
import java.util.Properties;
15
16
16
/**
17
/**
Lines 62-68 Link Here
62
		return options;
63
		return options;
63
	}
64
	}
64
	
65
	
65
	public void adjustInf(File input, Properties inf) {
66
	public void adjustInf(File input, Properties inf, List containers) {
66
		//nothing
67
		//nothing
67
	}
68
	}
68
}
69
}
(-)src/org/eclipse/update/internal/jarprocessor/UnpackStep.java (-2 / +3 lines)
Lines 12-17 Link Here
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.io.IOException;
14
import java.io.IOException;
15
import java.util.List;
15
import java.util.Properties;
16
import java.util.Properties;
16
17
17
/**
18
/**
Lines 71-77 Link Here
71
	/* (non-Javadoc)
72
	/* (non-Javadoc)
72
	 * @see org.eclipse.update.jarprocessor.IProcessStep#preProcess(java.io.File, java.io.File)
73
	 * @see org.eclipse.update.jarprocessor.IProcessStep#preProcess(java.io.File, java.io.File)
73
	 */
74
	 */
74
	public File preProcess(File input, File workingDirectory) {
75
	public File preProcess(File input, File workingDirectory, List containers) {
75
		if (canUnpack() && unpackCommand != null) {
76
		if (canUnpack() && unpackCommand != null) {
76
			String name = input.getName();
77
			String name = input.getName();
77
			if (name.endsWith(Utils.PACKED_SUFFIX)) {
78
			if (name.endsWith(Utils.PACKED_SUFFIX)) {
Lines 106-112 Link Here
106
	/* (non-Javadoc)
107
	/* (non-Javadoc)
107
	 * @see org.eclipse.update.jarprocessor.IProcessStep#postProcess(java.io.File, java.io.File)
108
	 * @see org.eclipse.update.jarprocessor.IProcessStep#postProcess(java.io.File, java.io.File)
108
	 */
109
	 */
109
	public File postProcess(File input, File workingDirectory) {
110
	public File postProcess(File input, File workingDirectory, List containers) {
110
		return null;
111
		return null;
111
	}
112
	}
112
113
(-)src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java (-12 / +44 lines)
Lines 10-18 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.update.internal.jarprocessor;
11
package org.eclipse.update.internal.jarprocessor;
12
12
13
import java.io.*;
13
import java.io.BufferedInputStream;
14
import java.util.*;
14
import java.io.BufferedOutputStream;
15
import java.util.jar.*;
15
import java.io.File;
16
import java.io.FileOutputStream;
17
import java.io.IOException;
18
import java.io.InputStream;
19
import java.util.Enumeration;
20
import java.util.Iterator;
21
import java.util.List;
22
import java.util.Properties;
23
import java.util.Set;
24
import java.util.jar.JarEntry;
25
import java.util.jar.JarFile;
26
import java.util.jar.JarOutputStream;
16
27
17
/**
28
/**
18
 * @author aniefer@ca.ibm.com
29
 * @author aniefer@ca.ibm.com
Lines 43-63 Link Here
43
	/* (non-Javadoc)
54
	/* (non-Javadoc)
44
	 * @see org.eclipse.update.jarprocessor.IProcessStep#preProcess(java.io.File, java.io.File)
55
	 * @see org.eclipse.update.jarprocessor.IProcessStep#preProcess(java.io.File, java.io.File)
45
	 */
56
	 */
46
	public File preProcess(File input, File workingDirectory) {
57
	public File preProcess(File input, File workingDirectory, List containers) {
47
		return null;
58
		return null;
48
	}
59
	}
49
60
50
	/* (non-Javadoc)
61
	/* (non-Javadoc)
51
	 * @see org.eclipse.update.jarprocessor.IProcessStep#postProcess(java.io.File, java.io.File)
62
	 * @see org.eclipse.update.jarprocessor.IProcessStep#postProcess(java.io.File, java.io.File)
52
	 */
63
	 */
53
	public File postProcess(File input, File workingDirectory) {
64
	public File postProcess(File input, File workingDirectory, List containers) {
54
		if (command != null) {
65
		if (command != null && shouldSign(input, containers)) {
55
			Properties inf = Utils.getEclipseInf(input);
56
			if (inf != null && inf.containsKey(Utils.MARK_EXCLUDE_SIGN) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_SIGN)).booleanValue()) {
57
				if(verbose)
58
					System.out.println("Excluding " + input.getName() + " from signing."); //$NON-NLS-1$ //$NON-NLS-2$
59
				return null;
60
			}
61
			try {
66
			try {
62
				String[] cmd = new String[] {command, input.getCanonicalPath()};
67
				String[] cmd = new String[] {command, input.getCanonicalPath()};
63
				int result = execute(cmd, verbose);
68
				int result = execute(cmd, verbose);
Lines 76-81 Link Here
76
		return null;
81
		return null;
77
	}
82
	}
78
83
84
	private boolean shouldSign(File input, List containers) {
85
		Properties inf = null;
86
87
		//1: Are we excluded from signing by our parents?
88
		//innermost jar is first on the list, it overrides outer jars
89
		for (Iterator iterator = containers.iterator(); iterator.hasNext();) {
90
			inf = (Properties) iterator.next();
91
			if (inf.containsKey(Utils.MARK_EXCLUDE_CHILDREN_SIGN)){
92
				if(Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_CHILDREN_SIGN)).booleanValue()) {
93
					if (verbose)
94
						System.out.println(input.getName() + "is excluded from signing by its containers."); //$NON-NLS-1$ //$NON-NLS-2$
95
					return false;
96
				}
97
				break;
98
			}
99
		}
100
101
		//2: Is this jar itself marked as exclude?
102
		inf = Utils.getEclipseInf(input, verbose);
103
		if (inf != null && inf.containsKey(Utils.MARK_EXCLUDE_SIGN) && Boolean.valueOf(inf.getProperty(Utils.MARK_EXCLUDE_SIGN)).booleanValue()) {
104
			if (verbose)
105
				System.out.println("Excluding " + input.getName() + " from signing."); //$NON-NLS-1$ //$NON-NLS-2$
106
			return false;
107
		}
108
		return true;
109
	}
110
79
	private void normalize(File input, File workingDirectory) {
111
	private void normalize(File input, File workingDirectory) {
80
		try {
112
		try {
81
			File tempJar = new File(workingDirectory, "temp_" + input.getName()); //$NON-NLS-1$
113
			File tempJar = new File(workingDirectory, "temp_" + input.getName()); //$NON-NLS-1$
(-)src/org/eclipse/update/internal/jarprocessor/IProcessStep.java (-3 / +7 lines)
Lines 11-16 Link Here
11
package org.eclipse.update.internal.jarprocessor;
11
package org.eclipse.update.internal.jarprocessor;
12
12
13
import java.io.File;
13
import java.io.File;
14
import java.util.List;
14
import java.util.Properties;
15
import java.util.Properties;
15
16
16
/**
17
/**
Lines 33-50 Link Here
33
	 *  return the file containing the result of the processing
34
	 *  return the file containing the result of the processing
34
	 * @param input
35
	 * @param input
35
	 * @param workingDirectory
36
	 * @param workingDirectory
37
	 * @param containers: inf properties for containing jars, innermost jar is first on the list
36
	 * @return
38
	 * @return
37
	 */
39
	 */
38
	public File preProcess(File input, File workingDirectory);
40
	public File preProcess(File input, File workingDirectory, List containers);
39
	
41
	
40
	/**
42
	/**
41
	 * Perform some processing on the input file after the JarProcessor returns from recursion
43
	 * Perform some processing on the input file after the JarProcessor returns from recursion
42
	 * return the file containing the result of the processing
44
	 * return the file containing the result of the processing
43
	 * @param input
45
	 * @param input
44
	 * @param workingDirectory
46
	 * @param workingDirectory
47
	 * @param containers: inf properties for containing jars, innermost jar is first on the list
45
	 * @return
48
	 * @return
46
	 */
49
	 */
47
	public File postProcess(File input, File workingDirectory);
50
	public File postProcess(File input, File workingDirectory, List containers);
48
	
51
	
49
	/**
52
	/**
50
	 * Return the name of this process step
53
	 * Return the name of this process step
Lines 56-61 Link Here
56
	 * Adjust any properties in the eclipse.inf as appropriate for this step
59
	 * Adjust any properties in the eclipse.inf as appropriate for this step
57
	 * @param input
60
	 * @param input
58
	 * @param inf
61
	 * @param inf
62
	 * @param containers: inf properties for containing jars, innermost jar is first on the list
59
	 */
63
	 */
60
	public void adjustInf(File input, Properties inf);
64
	public void adjustInf(File input, Properties inf, List containers);
61
}
65
}

Return to bug 159028