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 71927 Details for
Bug 193568
[JarProcessor] Need tool to verify pack.gz files
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]
initial implementation
193568.txt (text/plain), 8.07 KB, created by
Andrew Niefer
on 2007-06-20 12:49:08 EDT
(
hide
)
Description:
initial implementation
Filename:
MIME Type:
Creator:
Andrew Niefer
Created:
2007-06-20 12:49:08 EDT
Size:
8.07 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.update.core >Index: customBuildCallbacks.xml >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.update.core/customBuildCallbacks.xml,v >retrieving revision 1.2 >diff -u -r1.2 customBuildCallbacks.xml >--- customBuildCallbacks.xml 13 Apr 2007 21:35:21 -0000 1.2 >+++ customBuildCallbacks.xml 20 Jun 2007 16:48:41 -0000 >@@ -81,7 +81,7 @@ > <delete file="${dest}/jarprocessor.jar" failonerror="false"/> > <jar destfile="${dest}/jarprocessor.jar"> > <fileset dir="${target.folder}"> >- <include name="org/eclipse/update/internal/jarprocessor/*"/> >+ <include name="org/eclipse/update/internal/jarprocessor/**"/> > <exclude name="**/jarprocessor.jardesc"/> > </fileset> > <fileset dir="${basedir}" includes="about.html" /> >Index: jarprocessor/org/eclipse/update/internal/jarprocessor/verifier/VerifyStep.java >=================================================================== >RCS file: jarprocessor/org/eclipse/update/internal/jarprocessor/verifier/VerifyStep.java >diff -N jarprocessor/org/eclipse/update/internal/jarprocessor/verifier/VerifyStep.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ jarprocessor/org/eclipse/update/internal/jarprocessor/verifier/VerifyStep.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,79 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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.jarprocessor.verifier; >+ >+import java.io.File; >+import java.io.IOException; >+import java.util.List; >+import java.util.Properties; >+ >+import org.eclipse.update.internal.jarprocessor.CommandStep; >+import org.eclipse.update.internal.jarprocessor.Utils; >+ >+public class VerifyStep extends CommandStep { >+ >+ static String verifyCommand = "jarsigner"; >+ static Boolean canVerify = null; >+ >+ public static boolean canVerify() { >+ if (canVerify != null) >+ return canVerify.booleanValue(); >+ >+ String javaHome = System.getProperty("java.home"); //$NON-NLS-1$ >+ String command = javaHome + "/../bin/jarsigner"; >+ int result = execute(new String[] {command}); //$NON-NLS-1$ ; >+ if (result < 0) { >+ command = "jarsigner"; >+ result = execute(new String[] {command}); //$NON-NLS-1$ ; >+ if (result < 0) { >+ canVerify = Boolean.FALSE; >+ return false; >+ } >+ } >+ verifyCommand = command; >+ canVerify = Boolean.TRUE; >+ return true; >+ } >+ >+ public VerifyStep(Properties options, boolean verbose) { >+ super(options, verifyCommand, ".jar", verbose); >+ } >+ >+ public String getStepName() { >+ return "Verify"; >+ } >+ >+ public File postProcess(File input, File workingDirectory, List containers) { >+ if (canVerify() && verifyCommand != null) { >+ try { >+ System.out.print("Verifying " + input.getName() + ": "); >+ String[] cmd = new String[] {verifyCommand, "-verify", input.getCanonicalPath()}; >+ int result = execute(cmd, true); >+ 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) { >+ if (verbose) >+ e.printStackTrace(); >+ return null; >+ } >+ return input; >+ } >+ return null; >+ } >+ >+ public File preProcess(File input, File workingDirectory, List containers) { >+ return null; >+ } >+ >+ public String recursionEffect(String entryName) { >+ return null; >+ } >+ >+} >Index: jarprocessor/org/eclipse/update/internal/jarprocessor/verifier/Verifier.java >=================================================================== >RCS file: jarprocessor/org/eclipse/update/internal/jarprocessor/verifier/Verifier.java >diff -N jarprocessor/org/eclipse/update/internal/jarprocessor/verifier/Verifier.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ jarprocessor/org/eclipse/update/internal/jarprocessor/verifier/Verifier.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,106 @@ >+/******************************************************************************* >+ * Copyright (c) 2007 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.jarprocessor.verifier; >+ >+import java.io.File; >+import java.io.FileNotFoundException; >+import java.io.IOException; >+import java.util.Properties; >+ >+import org.eclipse.update.internal.jarprocessor.JarProcessor; >+import org.eclipse.update.internal.jarprocessor.JarProcessorExecutor; >+import org.eclipse.update.internal.jarprocessor.UnpackStep; >+import org.eclipse.update.internal.jarprocessor.Utils; >+ >+public class Verifier extends JarProcessorExecutor { >+ >+ private static void printUsage() { >+ System.out.println("This tool verifies that unpacking a pack.gz file with the jarprocessor results in a valid jar file."); //$NON-NLS-1$ >+ System.out.println("Usage: java -cp jarprocessor.jar org.eclipse.update.internal.jarprocessor.verifier.Verifier -dir <workingDirectory> input [input]"); //$NON-NLS-1$ >+ System.out.println(""); //$NON-NLS-1$ >+ System.out.println("-dir : specifies a working directory where pack.gz files can be temporarily unpacked"); //$NON-NLS-1$ >+ System.out.println("input : a list of directories and/or pack.gz files to verify."); //$NON-NLS-1$ >+ >+ } >+ >+ public static void main(String[] args) { >+ if (!VerifyStep.canVerify()) { >+ System.out.println("Can't find jarsigner. Please adjust your system path or use a jdk."); >+ printUsage(); >+ return; >+ } >+ >+ String workingDirectory = null; >+ String [] input; >+ >+ if(args.length == 0) { >+ workingDirectory = "."; >+ input = new String[] {"."}; >+ }else { >+ int idx = 0; >+ if(args[0] == "-help"){ >+ printUsage(); >+ return; >+ } >+ if (args[idx] == "-dir") { >+ workingDirectory = args[++idx]; >+ idx++; >+ } else { >+ workingDirectory = "temp"; >+ } >+ >+ input = new String[args.length - idx]; >+ System.arraycopy(args, idx, input, 0, args.length - idx); >+ } >+ >+ File workingDir = new File(workingDirectory); >+ boolean clear = false; >+ if( workingDir.exists()) { >+ workingDir = new File( workingDir, "jarprocessor.verifier.temp"); >+ clear = true; >+ } >+ >+ Verifier verifier = new Verifier(); >+ verifier.verify(workingDir, input); >+ >+ if(clear) >+ workingDir.deleteOnExit(); >+ } >+ >+ public void verify(final File workingDirectory, String[] input) { >+ Properties options = new Properties(); >+ >+ JarProcessor unpacker = new JarProcessor(); >+ unpacker.addProcessStep(new UnpackStep(options, false)); >+ unpacker.setWorkingDirectory(workingDirectory.getAbsolutePath()); >+ >+ /* There is no need to use a full processor to do the verification unless we want to verify nested jars as well. >+ * So for now, use a custom processor to just call the verify step directly. >+ */ >+ final VerifyStep verifyStep = new VerifyStep(options, false); >+ JarProcessor verifier = new JarProcessor() { >+ public File processJar(File input) throws IOException { >+ return verifyStep.postProcess(input, workingDirectory, null); >+ } >+ }; >+ >+ for (int i = 0; i < input.length; i++) { >+ File inputFile = new File(input[i]); >+ if (inputFile.exists()) { >+ try { >+ process(inputFile, Utils.PACK_GZ_FILTER, true, unpacker, verifier); >+ } catch (FileNotFoundException e) { >+ e.printStackTrace(); >+ } >+ } >+ } >+ Utils.clear(workingDirectory); >+ } >+}
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 193568
: 71927 |
71930