Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 39181 Details for
Bug 127375
Add update site performance enhancement utility
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Site Optimizer + verbose
127375.txt (text/plain), 34.93 KB, created by
Andrew Niefer
on 2006-04-21 12:05:45 EDT
(
hide
)
Description:
Site Optimizer + verbose
Filename:
MIME Type:
Creator:
Andrew Niefer
Created:
2006-04-21 12:05:45 EDT
Size:
34.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.update.core >Index: src/org/eclipse/update/internal/jarprocessor/Main.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/Main.java,v >retrieving revision 1.1 >diff -u -r1.1 Main.java >--- src/org/eclipse/update/internal/jarprocessor/Main.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/Main.java 21 Apr 2006 15:50:30 -0000 >@@ -25,6 +25,7 @@ > public boolean pack = false; > public boolean repack = false; > public boolean unpack = false; >+ public boolean verbose = false; > public File input = null; > } > >@@ -39,6 +40,7 @@ > System.out.println(" with repack, sign and pack."); //$NON-NLS-1$ > System.out.println(); > System.out.println("-outputDir <dir> the output directory"); //$NON-NLS-1$ >+ System.out.println("-verbose verbose mode "); //$NON-NLS-1$ > } > > public static Options processArguments(String[] args) { >@@ -68,28 +70,31 @@ > return null; > } > options.outputDir = args[++i]; >+ } else if (args[i].equals("-verbose")) { //$NON-NLS-1$ >+ options.verbose = true; > } > } > > options.input = new File(args[i]); > > String problemMessage = null; >+ String inputName = options.input.getName(); > if (options.unpack) { > if (!JarProcessor.canPerformUnpack()) { > problemMessage = "The unpack200 command cannot be found."; //$NON-NLS-1$ >- } else if (options.input.isFile() && !args[i].endsWith(".zip") && !args[i].endsWith(".pack.gz")) { //$NON-NLS-1$ //$NON-NLS-2$ >+ } else if (options.input.isFile() && !inputName.endsWith(".zip") && !inputName.endsWith(".pack.gz")) { //$NON-NLS-1$ //$NON-NLS-2$ > problemMessage = "Input file is not a pack.gz file."; //$NON-NLS-1$ >- } else if (options.pack || options.repack || options.signCommand != null) { >+ } else if (options.pack || options.repack || options.signCommand != null) { > problemMessage = "Pack, repack or sign cannot be specified with unpack."; //$NON-NLS-1$ > } > } else { >- if (options.input.isFile() && !args[i].endsWith(".zip") && !args[i].endsWith(".jar")) { //$NON-NLS-1$ //$NON-NLS-2$ >+ if (options.input.isFile() && !inputName.endsWith(".zip") && !inputName.endsWith(".jar")) { //$NON-NLS-1$ //$NON-NLS-2$ > problemMessage = "Input file is not a jar file."; //$NON-NLS-1$ >- } else if ((options.pack || options.repack) && !JarProcessor.canPerformPack()) { >+ } else if ((options.pack || options.repack) && !JarProcessor.canPerformPack()) { > problemMessage = "The pack200 command can not be found."; //$NON-NLS-1$ > } > } >- if(problemMessage != null){ >+ if (problemMessage != null) { > System.out.println(problemMessage); > System.out.println(); > printUsage(); >@@ -99,15 +104,7 @@ > return options; > } > >- /** >- * @param args >- * @throws FileNotFoundException >- */ >- public static void main(String[] args) { >- Options options = processArguments(args); >- if (options == null) >- return; >- >+ public static void runJarProcessor(Options options) { > if (options.input.getName().endsWith(".zip")) { //$NON-NLS-1$ > ZipProcessor processor = new ZipProcessor(); > processor.setWorkingDirectory(options.outputDir); >@@ -115,37 +112,50 @@ > processor.setPack(options.pack); > processor.setRepack(options.repack || (options.pack && options.signCommand != null)); > processor.setUnpack(options.unpack); >+ processor.setVerbose(options.verbose); > try { > processor.processZip(options.input); > } catch (ZipException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >+ if (options.verbose) >+ e.printStackTrace(); > } catch (IOException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >+ if (options.verbose) >+ e.printStackTrace(); > } > } else { > JarProcessor processor = new JarProcessor(); > processor.setWorkingDirectory(options.outputDir); >+ processor.setVerbose(options.verbose); > > if (options.repack || (options.pack && options.signCommand != null)) >- processor.addProcessStep(new PackUnpackStep(null)); >+ processor.addProcessStep(new PackUnpackStep(null, options.verbose)); > > if (options.signCommand != null) >- processor.addProcessStep(new SignCommandStep(null, options.signCommand)); >+ processor.addProcessStep(new SignCommandStep(null, options.signCommand, options.verbose)); > > if (options.pack) >- processor.addProcessStep(new PackStep(null)); >+ processor.addProcessStep(new PackStep(null, options.verbose)); > else if (options.unpack) >- processor.addProcessStep(new UnpackStep(null)); >+ processor.addProcessStep(new UnpackStep(null, options.verbose)); > > try { > processor.process(options.input, options.unpack ? Utils.PACK_GZ_FILTER : Utils.JAR_FILTER); > } catch (FileNotFoundException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >+ if (options.verbose) >+ e.printStackTrace(); > } > } > } > >+ /** >+ * @param args >+ * @throws FileNotFoundException >+ */ >+ public static void main(String[] args) { >+ Options options = processArguments(args); >+ if (options == null) >+ return; >+ runJarProcessor(options); >+ } >+ > } >Index: src/org/eclipse/update/internal/jarprocessor/IProcessStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/IProcessStep.java,v >retrieving revision 1.1 >diff -u -r1.1 IProcessStep.java >--- src/org/eclipse/update/internal/jarprocessor/IProcessStep.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/IProcessStep.java 21 Apr 2006 15:50:30 -0000 >@@ -25,7 +25,7 @@ > * @param entryName > * @return > */ >- String recursionEffect(String entryName); >+ public String recursionEffect(String entryName); > > /** > * Perform some processing on the input file before the JarProcessor considers the entries for recursion. >@@ -34,7 +34,7 @@ > * @param workingDirectory > * @return > */ >- File preProcess(File input, File workingDirectory); >+ public File preProcess(File input, File workingDirectory); > > /** > * Perform some processing on the input file after the JarProcessor returns from recursion >@@ -43,5 +43,11 @@ > * @param workingDirectory > * @return > */ >- File postProcess(File input, File workingDirectory); >+ public File postProcess(File input, File workingDirectory); >+ >+ /** >+ * Return the name of this process step >+ * @return >+ */ >+ public String getStepName(); > } >Index: src/org/eclipse/update/internal/jarprocessor/PackUnpackStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/PackUnpackStep.java,v >retrieving revision 1.1 >diff -u -r1.1 PackUnpackStep.java >--- src/org/eclipse/update/internal/jarprocessor/PackUnpackStep.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/PackUnpackStep.java 21 Apr 2006 15:50:30 -0000 >@@ -21,14 +21,19 @@ > */ > public class PackUnpackStep extends PackStep { > private Set exclusions = null; >- >+ > public PackUnpackStep(Properties options) { > super(options); > exclusions = Utils.getPackExclusions(options); > } > >+ public PackUnpackStep(Properties options, boolean verbose) { >+ super(options, verbose); >+ exclusions = Utils.getPackExclusions(options); >+ } >+ > public String recursionEffect(String entryName) { >- if (canPack() && entryName.endsWith(".jar") && !exclusions.contains(entryName)) { //$NON-NLS-1$ >+ if (canPack() && entryName.endsWith(".jar") && !exclusions.contains(entryName)) { //$NON-NLS-1$ > return entryName; > } > return null; >@@ -47,16 +52,19 @@ > cmd[1] = "-r"; //$NON-NLS-1$ > System.arraycopy(tmp, 1, cmd, 2, tmp.length - 1); > >- int result = execute(cmd); >+ int result = execute(cmd, verbose); > if (result == 0 && tempFile.exists()) { > File finalFile = new File(workingDirectory, input.getName()); >- if(finalFile.exists()) >+ if (finalFile.exists()) > finalFile.delete(); > tempFile.renameTo(finalFile); > return finalFile; >+ } else if (verbose) { >+ System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$ > } > } catch (IOException e) { >- //didn't work >+ if (verbose) >+ e.printStackTrace(); > return null; > } > } >@@ -70,4 +78,7 @@ > return null; > } > >+ public String getStepName() { >+ return "Repack"; //$NON-NLS-1$ >+ } > } >Index: src/org/eclipse/update/internal/jarprocessor/CommandStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/CommandStep.java,v >retrieving revision 1.1 >diff -u -r1.1 CommandStep.java >--- src/org/eclipse/update/internal/jarprocessor/CommandStep.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/CommandStep.java 21 Apr 2006 15:50:30 -0000 >@@ -10,7 +10,6 @@ > *******************************************************************************/ > package org.eclipse.update.internal.jarprocessor; > >-import java.io.IOException; > import java.util.Properties; > > /** >@@ -21,21 +20,37 @@ > protected String command = null; > protected String extension = null; > private Properties options = null; >+ protected boolean verbose = false; > >- public CommandStep(Properties options, String command, String extension) { >+ public CommandStep(Properties options, String command, String extension, boolean verbose) { > this.command = command; > this.extension = extension; > this.options = options; >+ this.verbose = verbose; > } > >- protected static int execute(String[] cmd) throws IOException { >+ protected static int execute(String[] cmd) { >+ return execute(cmd, false); >+ } >+ >+ protected static int execute(String[] cmd, boolean verbose) { > Runtime runtime = Runtime.getRuntime(); >- Process proc = runtime.exec(cmd); >+ Process proc = null; >+ try { >+ proc = runtime.exec(cmd); >+ } catch (Exception e) { >+ if(verbose) { >+ System.out.println("Error executing command " + Utils.concat(cmd)); //$NON-NLS-1$ >+ e.printStackTrace(); >+ } >+ return -1; >+ } > try { > int result = proc.waitFor(); > return result; > } catch (InterruptedException e) { >- //ignore >+ if(verbose) >+ e.printStackTrace(); > } > return -1; > } >Index: src/org/eclipse/update/internal/jarprocessor/UnpackStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/UnpackStep.java,v >retrieving revision 1.1 >diff -u -r1.1 UnpackStep.java >--- src/org/eclipse/update/internal/jarprocessor/UnpackStep.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/UnpackStep.java 21 Apr 2006 15:50:30 -0000 >@@ -38,15 +38,11 @@ > for (int i = 0; i < locations.length; i++) { > if (locations[i] == null) > continue; >- try { >- result = execute(new String[] {locations[i], "-V"}); //$NON-NLS-1$ >- if (result == 0) { >- unpackCommand = locations[i]; >- canUnpack = Boolean.TRUE; >- return true; >- } >- } catch (IOException e) { >- //no good >+ result = execute(new String[] {locations[i], "-V"}); //$NON-NLS-1$ >+ if (result == 0) { >+ unpackCommand = locations[i]; >+ canUnpack = Boolean.TRUE; >+ return true; > } > } > >@@ -55,7 +51,11 @@ > } > > public UnpackStep(Properties options) { >- super(options, null, null); >+ super(options, null, null, false); >+ } >+ >+ public UnpackStep(Properties options, boolean verbose) { >+ super(options, null, null, verbose); > } > > /* (non-Javadoc) >@@ -89,9 +89,12 @@ > } else { > cmd = new String[] {unpackCommand, input.getCanonicalPath(), unpacked.getCanonicalPath()}; > } >- execute(cmd); >+ int result = execute(cmd, verbose); >+ if (result != 0 && verbose) >+ System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$ > } catch (IOException e) { >- //didn't work >+ if (verbose) >+ e.printStackTrace(); > return null; > } > return unpacked; >@@ -106,4 +109,8 @@ > public File postProcess(File input, File workingDirectory) { > return null; > } >+ >+ public String getStepName() { >+ return "Unpack"; //$NON-NLS-1$ >+ } > } >Index: src/org/eclipse/update/internal/jarprocessor/JarProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/JarProcessor.java,v >retrieving revision 1.1 >diff -u -r1.1 JarProcessor.java >--- src/org/eclipse/update/internal/jarprocessor/JarProcessor.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/JarProcessor.java 21 Apr 2006 15:50:30 -0000 >@@ -22,6 +22,7 @@ > private List steps = new ArrayList(); > private String workingDirectory = ""; //$NON-NLS-1$ > private int depth = -1; >+ private boolean verbose = false; > > static public JarProcessor getUnpackProcessor(Properties properties) { > if (!canPerformUnpack()) >@@ -54,6 +55,10 @@ > public void setWorkingDirectory(String dir) { > workingDirectory = dir; > } >+ >+ public void setVerbose(boolean verbose) { >+ this.verbose = verbose; >+ } > > public void addProcessStep(IProcessStep step) { > steps.add(step); >@@ -74,7 +79,6 @@ > files = new File[] {input}; > } > for (int i = 0; i < files.length; i++) { >- System.out.println("Processing " + files[i].getName()); //$NON-NLS-1$ > if (files[i].isDirectory()) { > String dir = getWorkingDirectory(); > setWorkingDirectory(dir + "/" + files[i].getName()); //$NON-NLS-1$ >@@ -84,8 +88,8 @@ > try { > processJar(files[i]); > } catch (IOException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >+ if(verbose) >+ e.printStackTrace(); > } > } > } >@@ -154,6 +158,11 @@ > String name = entry.getName(); > String newName = recursionEffect(name); > if (newName != null) { >+ if(verbose){ >+ for(int i = 0; i <= depth; i++) >+ System.out.print(" "); //$NON-NLS-1$ >+ System.out.println("Processing nested file: " + name); //$NON-NLS-1$ >+ } > //extract entry to temp directory > File extracted = new File(tempDir, name); > File parentDir = extracted.getParentFile(); >@@ -216,6 +225,14 @@ > if (!workingDir.exists()) > workingDir.mkdirs(); > >+ if(depth == 0 && verbose) { >+ System.out.print("Running "); //$NON-NLS-1$ >+ for (Iterator iter = steps.iterator(); iter.hasNext();) { >+ IProcessStep step = (IProcessStep) iter.next(); >+ System.out.print(step.getStepName() + " "); //$NON-NLS-1$ >+ } >+ System.out.println("on " + input.getPath()); //$NON-NLS-1$ >+ } > //pre > File workingFile = preProcess(input, workingDir); > >Index: src/org/eclipse/update/internal/jarprocessor/PackStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/PackStep.java,v >retrieving revision 1.1 >diff -u -r1.1 PackStep.java >--- src/org/eclipse/update/internal/jarprocessor/PackStep.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/PackStep.java 21 Apr 2006 15:50:30 -0000 >@@ -36,15 +36,11 @@ > for (int i = 0; i < locations.length; i++) { > if (locations[i] == null) > continue; >- try { >- result = execute(new String[] {locations[i], "-V"}); //$NON-NLS-1$ >- if (result == 0) { >- packCommand = locations[i]; >- canPack = Boolean.TRUE; >- return true; >- } >- } catch (IOException e) { >- //no good >+ result = execute(new String[] {locations[i], "-V"}); //$NON-NLS-1$ >+ if (result == 0) { >+ packCommand = locations[i]; >+ canPack = Boolean.TRUE; >+ return true; > } > } > >@@ -53,7 +49,12 @@ > } > > public PackStep(Properties options) { >- super(options, null, null); >+ super(options, null, null, false); >+ exclusions = Utils.getPackExclusions(options); >+ } >+ >+ public PackStep(Properties options, boolean verbose) { >+ super(options, null, null, verbose); > exclusions = Utils.getPackExclusions(options); > } > >@@ -73,9 +74,12 @@ > File outputFile = new File(workingDirectory, input.getName() + Utils.PACKED_SUFFIX); > try { > String[] cmd = getCommand(input, outputFile); >- execute(cmd); >+ int result = execute(cmd, verbose); >+ if (result != 0 && verbose) >+ System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$ > } catch (IOException e) { >- //didn't work >+ if (verbose) >+ e.printStackTrace(); > return null; > } > return outputFile; >@@ -98,4 +102,8 @@ > } > return cmd; > } >+ >+ public String getStepName() { >+ return "Pack"; //$NON-NLS-1$ >+ } > } >Index: src/org/eclipse/update/internal/jarprocessor/ZipProcessor.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/ZipProcessor.java,v >retrieving revision 1.1 >diff -u -r1.1 ZipProcessor.java >--- src/org/eclipse/update/internal/jarprocessor/ZipProcessor.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/ZipProcessor.java 21 Apr 2006 15:50:30 -0000 >@@ -34,6 +34,7 @@ > private boolean signing = false; > private boolean repacking = false; > private boolean unpacking = false; >+ private boolean verbose = false; > > public void setWorkingDirectory(String dir) { > workingDirectory = dir; >@@ -62,13 +63,20 @@ > this.unpacking = unpack; > } > >+ public void setVerbose(boolean verbose) { >+ this.verbose = verbose; >+ } >+ > public void processZip(File zipFile) throws ZipException, IOException { >+ if (verbose) >+ System.out.println("Processing " + zipFile.getPath()); //$NON-NLS-1$ > ZipFile zip = new ZipFile(zipFile); > initialize(zip); > > String extension = unpacking ? "pack.gz" : ".jar"; //$NON-NLS-1$ //$NON-NLS-2$ > File tempDir = new File(getWorkingDirectory(), "temp_" + zipFile.getName()); //$NON-NLS-1$ > JarProcessor processor = new JarProcessor(); >+ processor.setVerbose(verbose); > processor.setWorkingDirectory(tempDir.getCanonicalPath()); > if (unpacking) { > processor.addProcessStep(unpackStep); >@@ -97,6 +105,8 @@ > parent = extractedFile.getParentFile(); > if (!parent.exists()) > parent.mkdirs(); >+ if (verbose) >+ System.out.println("Extracting " + entry.getName()); //$NON-NLS-1$ > FileOutputStream extracted = new FileOutputStream(extractedFile); > Utils.transferStreams(entryStream, extracted, true); > >@@ -127,6 +137,10 @@ > } > } > entryStream = new FileInputStream(extractedFile); >+ if (verbose) { >+ System.out.println("Adding " + entry.getName() + " to " + outputFile.getPath()); //$NON-NLS-1$ //$NON-NLS-2$ >+ System.out.println(); >+ } > } > ZipEntry newEntry = new ZipEntry(name); > zipOut.putNextEntry(newEntry); >@@ -158,8 +172,8 @@ > stream = zip.getInputStream(entry); > properties.load(stream); > } catch (IOException e) { >- // TODO Auto-generated catch block >- e.printStackTrace(); >+ if (verbose) >+ e.printStackTrace(); > } finally { > Utils.close(stream); > } >@@ -168,9 +182,9 @@ > packExclusions = Utils.getPackExclusions(properties); > signExclusions = Utils.getSignExclusions(properties); > >- packUnpackStep = new PackUnpackStep(properties); >- packStep = new PackStep(properties); >- signStep = new SignCommandStep(properties, command); >- unpackStep = new UnpackStep(properties); >+ packUnpackStep = new PackUnpackStep(properties, verbose); >+ packStep = new PackStep(properties, verbose); >+ signStep = new SignCommandStep(properties, command, verbose); >+ unpackStep = new UnpackStep(properties, verbose); > } > } >Index: src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java,v >retrieving revision 1.1 >diff -u -r1.1 SignCommandStep.java >--- src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/SignCommandStep.java 21 Apr 2006 15:50:30 -0000 >@@ -22,7 +22,12 @@ > private Set exclusions = null; > > public SignCommandStep(Properties options, String command) { >- super(options, command, ".jar"); //$NON-NLS-1$ >+ super(options, command, ".jar", false); //$NON-NLS-1$ >+ exclusions = Utils.getSignExclusions(options); >+ } >+ >+ public SignCommandStep(Properties options, String command, boolean verbose) { >+ super(options, command, ".jar", verbose); //$NON-NLS-1$ > exclusions = Utils.getSignExclusions(options); > } > >@@ -49,14 +54,17 @@ > if (command != null) { > try { > String[] cmd = new String[] {command, input.getCanonicalPath()}; >- int result = execute(cmd); >+ int result = execute(cmd, verbose); > if (result == 0) { > normalize(input, workingDirectory); > return input; >+ } else if (verbose) { >+ System.out.println("Error: " + result + " was returned from command: " + Utils.concat(cmd)); //$NON-NLS-1$ //$NON-NLS-2$ > } > } catch (IOException e) { >- //boo >- e.printStackTrace(); >+ if (verbose) { >+ e.printStackTrace(); >+ } > } > } > return null; >@@ -65,7 +73,7 @@ > private void normalize(File input, File workingDirectory) { > try { > File tempJar = new File(workingDirectory, "temp_" + input.getName()); //$NON-NLS-1$ >- JarFile jar = new JarFile(input); >+ JarFile jar = new JarFile(input, false); > JarOutputStream jarOut = new JarOutputStream(new BufferedOutputStream(new FileOutputStream(tempJar))); > InputStream in = null; > try { >@@ -88,7 +96,14 @@ > input.delete(); > tempJar.renameTo(input); > } catch (IOException e) { >- //boo >+ if (verbose) { >+ System.out.println("Error normalizing jar " + input.getName()); //$NON-NLS-1$ >+ e.printStackTrace(); >+ } > } > } >+ >+ public String getStepName() { >+ return "Sign"; //$NON-NLS-1$ >+ } > } >Index: src/org/eclipse/update/internal/jarprocessor/Utils.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/jarprocessor/Utils.java,v >retrieving revision 1.1 >diff -u -r1.1 Utils.java >--- src/org/eclipse/update/internal/jarprocessor/Utils.java 12 Apr 2006 16:55:46 -0000 1.1 >+++ src/org/eclipse/update/internal/jarprocessor/Utils.java 21 Apr 2006 15:50:30 -0000 >@@ -175,4 +175,14 @@ > } > return Collections.EMPTY_SET; > } >+ >+ public static String concat(String [] array){ >+ StringBuffer buffer = new StringBuffer(); >+ for (int i = 0; i < array.length; i++) { >+ if( i > 0 ) >+ buffer.append(' '); >+ buffer.append(array[i]); >+ } >+ return buffer.toString(); >+ } > } >Index: src/org/eclipse/update/internal/core/FeaturePackagedFactory.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeaturePackagedFactory.java,v >retrieving revision 1.28 >diff -u -r1.28 FeaturePackagedFactory.java >--- src/org/eclipse/update/internal/core/FeaturePackagedFactory.java 11 Apr 2006 16:37:57 -0000 1.28 >+++ src/org/eclipse/update/internal/core/FeaturePackagedFactory.java 21 Apr 2006 15:50:30 -0000 >@@ -35,7 +35,7 @@ > > > try { >- IFeatureContentProvider contentProvider = new FeaturePackagedContentProvider(url); >+ IFeatureContentProvider contentProvider = new FeaturePackagedContentProvider(url, site); > ContentReference manifest = contentProvider.getFeatureManifestReference(null/*IProgressMonitor*/); > featureStream = manifest.getInputStream(); > feature = (Feature)parseFeature(featureStream); >Index: src/org/eclipse/update/internal/core/messages.properties >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/messages.properties,v >retrieving revision 1.98 >diff -u -r1.98 messages.properties >--- src/org/eclipse/update/internal/core/messages.properties 17 Mar 2006 06:02:59 -0000 1.98 >+++ src/org/eclipse/update/internal/core/messages.properties 21 Apr 2006 15:50:30 -0000 >@@ -336,7 +336,11 @@ > SiteFilePluginContentConsumer_unableToDelete=Unable to delete {0} > SiteFilePackedPluginContentConsumer_unableToDelete=Unable to delete {0} > >- >+JarProcessor_unpackNotFound = The unpack200 command cannot be found. >+JarProcessor_noPackUnpack = Pack, repack or sign cannot be specified with unpack. >+JarProcessor_packNotFound = The pack200 command cannot be found. >+SiteOptimizer_inputNotSpecified = No input file was specified; >+SiteOptimizer_inputFileNotFound = The input file \"{0}\" was not found. > > HttpResponse_rangeExpected = Server does not support ranges. > HttpResponse_wrongRange = Server returned wrong range. >Index: src/org/eclipse/update/internal/core/FeaturePackagedContentProvider.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/FeaturePackagedContentProvider.java,v >retrieving revision 1.49 >diff -u -r1.49 FeaturePackagedContentProvider.java >--- src/org/eclipse/update/internal/core/FeaturePackagedContentProvider.java 12 Apr 2006 16:55:46 -0000 1.49 >+++ src/org/eclipse/update/internal/core/FeaturePackagedContentProvider.java 21 Apr 2006 15:50:30 -0000 >@@ -17,6 +17,7 @@ > import org.eclipse.osgi.util.NLS; > import org.eclipse.update.core.*; > import org.eclipse.update.internal.jarprocessor.JarProcessor; >+import org.eclipse.update.internal.jarprocessor.Utils; > import org.eclipse.update.internal.security.JarVerifier; > import org.eclipse.update.internal.verifier.CertVerifier; > >@@ -41,8 +42,11 @@ > /* > * Constructor > */ >- public FeaturePackagedContentProvider(URL url) { >+ public FeaturePackagedContentProvider(URL url, ISite site) { > super(url); >+ if (site instanceof ExtendedSite) { >+ this.siteModel = (ExtendedSite) site; >+ } > } > > /* >@@ -64,13 +68,6 @@ > return jarVerifier; > } > >- public void setFeature(IFeature feature) { >- super.setFeature(feature); >- ISite featureSite = feature.getSite(); >- if(featureSite instanceof ExtendedSite){ >- siteModel = (ExtendedSite) featureSite; >- } >- } > /* > * @see IFeatureContentProvider#getFeatureManifestReference() > */ >@@ -227,8 +224,14 @@ > JarProcessor processor = JarProcessor.getUnpackProcessor(null); > processor.setWorkingDirectory(tempFile.getParent()); > >- File packedFile = new File(tempFile.toString() + ".pack.gz"); //$NON-NLS-1$ >+ File packedFile = new File(tempFile.toString() + Utils.PACKED_SUFFIX); > tempFile.renameTo(packedFile); >+ >+ if (monitor != null) { >+ monitor.saveState(); >+ monitor.subTask(Messages.JarContentReference_Unpacking + " " + reference.getIdentifier() + Utils.PACKED_SUFFIX); //$NON-NLS-1$ >+ monitor.showCopyDetails(false); >+ } > //unpacking the jar will strip the ".pack.gz" and leave us back with the original filename > processor.processJar(packedFile); > >@@ -237,6 +240,8 @@ > } finally { > LockManager.returnLock(packed); > LockManager.returnLock(key); >+ if(monitor != null) >+ monitor.restoreState(); > } > } > } >Index: src/org/eclipse/update/internal/core/Messages.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/src/org/eclipse/update/internal/core/Messages.java,v >retrieving revision 1.6 >diff -u -r1.6 Messages.java >--- src/org/eclipse/update/internal/core/Messages.java 17 Mar 2006 06:02:59 -0000 1.6 >+++ src/org/eclipse/update/internal/core/Messages.java 21 Apr 2006 15:50:30 -0000 >@@ -335,6 +335,13 @@ > public static String HttpResponse_wrongRange; > public static String DefaultSiteParser_mirrors; > public static String FeatureExecutableContentProvider_UnableToRetriveArchiveContentRef; >+ >+ public static String JarProcessor_unpackNotFound; >+ public static String JarProcessor_noPackUnpack; >+ public static String JarProcessor_packNotFound; >+ >+ public static String SiteOptimizer_inputNotSpecified; >+ public static String SiteOptimizer_inputFileNotFound; > > static { > NLS.initializeMessages(BUNDLE_NAME, Messages.class); >Index: plugin.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/plugin.xml,v >retrieving revision 1.55 >diff -u -r1.55 plugin.xml >--- plugin.xml 29 Mar 2006 23:37:07 -0000 1.55 >+++ plugin.xml 21 Apr 2006 15:50:30 -0000 >@@ -72,6 +72,15 @@ > </run> > </application> > </extension> >+ <extension >+ id="siteOptimizer" >+ point="org.eclipse.core.runtime.applications"> >+ <application> >+ <run >+ class="org.eclipse.update.internal.provisional.SiteOptimizerApplication"> >+ </run> >+ </application> >+ </extension> > <extension > id="updateCoreProductProvider" > name="%productProviderName" >Index: src/org/eclipse/update/internal/provisional/SiteOptimizerApplication.java >=================================================================== >RCS file: src/org/eclipse/update/internal/provisional/SiteOptimizerApplication.java >diff -N src/org/eclipse/update/internal/provisional/SiteOptimizerApplication.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/update/internal/provisional/SiteOptimizerApplication.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,140 @@ >+/******************************************************************************* >+ * Copyright (c) 2006 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 - Initial API and implementation >+ *******************************************************************************/ >+package org.eclipse.update.internal.provisional; >+ >+import java.io.File; >+import java.util.HashMap; >+import java.util.Map; >+import org.eclipse.core.runtime.IPlatformRunnable; >+import org.eclipse.core.runtime.Platform; >+import org.eclipse.osgi.util.NLS; >+import org.eclipse.update.internal.core.Messages; >+import org.eclipse.update.internal.jarprocessor.JarProcessor; >+import org.eclipse.update.internal.jarprocessor.Main; >+ >+/** >+ * The application class used to perform update site optimizations. >+ * <p> >+ * <b>Note:</b> This class/interface is part of an interim API that is still under development and expected to >+ * change significantly before reaching stability. It is being made available at this early stage to solicit feedback >+ * from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken >+ * (repeatedly) as the API evolves. >+ * </p> >+ * @since 3.2 >+ */ >+public class SiteOptimizerApplication implements IPlatformRunnable { >+ public final static Integer EXIT_ERROR = new Integer(1); >+ >+ public final static String JAR_PROCESSOR = "-jarProcessor"; //$NON-NLS-1$ >+ public final static String DIGEST_BUILDER = "-digestBuilder"; //$NON-NLS-1$ >+ public final static String INPUT = "input"; //$NON-NLS-1$ >+ public final static String OUTPUT_DIR = "-outputDir"; //$NON-NLS-1$ >+ public final static String VERBOSE = "-verbose"; //$NON-NLS-1$ >+ >+ public final static String JAR_PROCESSOR_PACK = "-pack"; //$NON-NLS-1$ >+ public final static String JAR_PROCESSOR_UNPACK = "-unpack"; //$NON-NLS-1$ >+ public final static String JAR_PROCESSOR_REPACK = "-repack"; //$NON-NLS-1$ >+ public final static String JAR_PROCESSOR_SIGN = "-sign"; //$NON-NLS-1$ >+ >+ >+ /** >+ * Parses the command line in the form: >+ * [-key [value]]* [inputvalue] >+ * If the last argument does not start with a "-" then it is taken as the input value and not the value for a preceding -key >+ * @param args >+ * @return >+ */ >+ private Map parseCmdLine(String [] args) { >+ Map cmds = new HashMap(); >+ for (int i = 0; i < args.length; i++) { >+ if(i == args.length - 1 && !args[i].startsWith("-")) { //$NON-NLS-1$ >+ cmds.put(INPUT, args[i]); >+ } else { >+ String key = args[i]; >+ String val = null; >+ if( i < args.length - 2 && !args[i + 1].startsWith("-")){ //$NON-NLS-1$ >+ val = args[++i]; >+ } >+ cmds.put(key, val); >+ } >+ } >+ return cmds; >+ } >+ >+ private boolean runJarProcessor(Map params) { >+ Main.Options options = new Main.Options(); >+ options.pack = params.containsKey(JAR_PROCESSOR_PACK); >+ options.unpack = params.containsKey(JAR_PROCESSOR_UNPACK); >+ options.repack = params.containsKey(JAR_PROCESSOR_REPACK); >+ options.verbose = params.containsKey(VERBOSE); >+ options.signCommand = (String) params.get(JAR_PROCESSOR_SIGN); >+ options.outputDir = (String) params.get(OUTPUT_DIR); >+ >+ String problem = null; >+ >+ String input = (String) params.get(INPUT); >+ if(input == null) >+ problem = Messages.SiteOptimizer_inputNotSpecified; >+ else { >+ File inputFile = new File(input); >+ if(inputFile.exists()) >+ options.input = inputFile; >+ else >+ problem = NLS.bind(Messages.SiteOptimizer_inputFileNotFound, new String[] {input}); >+ } >+ >+ if (options.unpack) { >+ if (!JarProcessor.canPerformUnpack()) { >+ problem = Messages.JarProcessor_unpackNotFound; >+ } else if (options.pack || options.repack || options.signCommand != null) { >+ problem = Messages.JarProcessor_noPackUnpack; >+ } >+ } else if ((options.pack || options.repack) && !JarProcessor.canPerformPack()) { >+ problem = Messages.JarProcessor_packNotFound; >+ } >+ >+ if(problem != null) { >+ System.out.println(problem); >+ return false; >+ } >+ >+ Main.runJarProcessor(options); >+ return true; >+ } >+ >+ private boolean runDigestBuilder(Map params) { >+ //TODO >+ return true; >+ } >+ >+ /* (non-Javadoc) >+ * @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object) >+ */ >+ public Object run(Object args) throws Exception { >+ Platform.endSplash(); >+ if (args == null) >+ return EXIT_ERROR; >+ if (args instanceof String[]) { >+ Map params = parseCmdLine((String[]) args); >+ if(params.containsKey(JAR_PROCESSOR)){ >+ if(!runJarProcessor(params)) >+ return EXIT_ERROR; >+ } >+ >+ if(params.containsKey(DIGEST_BUILDER)){ >+ if(!runDigestBuilder(params)) >+ return EXIT_ERROR; >+ } >+ } >+ return IPlatformRunnable.EXIT_OK; >+ } >+ >+}
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 127375
:
37769
|
37820
|
38035
|
38421
|
38861
|
39181
|
39196