From 96531299178bd241015a50cf8f3d9c878633b05a Mon Sep 17 00:00:00 2001 From: qouyang Date: Mon, 17 Jul 2006 07:31:21 +0000 Subject: [PATCH] [Wizard- Far Install/Create] Change Manifest file name to "FrameworkArchiveManifest.xml". Modify Md5 format in FrameworkArchiveMainfest.xml file. Add Md5 verification when install FAR. Fix the bug of Far installation can't work with Sun JDK 1.5.0_04 version. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@1029 6f19259b-4bc3-4df7-8a09-765794883524 --- .../src/org/tianocore/frameworkwizard/far/Far.java | 6 ++++++ .../src/org/tianocore/frameworkwizard/far/FarMd5.java | 2 +- .../org/tianocore/frameworkwizard/far/Mainfest.java | 10 +++++++--- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java index 57116334f2..9b0c5930cb 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Far.java @@ -226,6 +226,12 @@ public class Far { byte[] totalBuffer = new byte[(int) tempFile.length()]; FileInputStream fis = new FileInputStream(tempFile); fis.read(totalBuffer); + // + // Check Md5 + // + if (!ffItem.getMd5Value().equalsIgnoreCase(FarMd5.md5(totalBuffer))){ + throw new Exception (ffItem.getRelativeFilename() + " Md5 is invaild!"); + } outputStream.write(totalBuffer); fis.close(); tempFile.delete(); diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarMd5.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarMd5.java index c7b97c5431..0269fcf6cd 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarMd5.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/FarMd5.java @@ -32,7 +32,7 @@ public class FarMd5 { static public String md5(byte[] buffer) throws Exception { MessageDigest md = MessageDigest.getInstance("MD5"); byte[] md5 = md.digest(buffer); - return new String(String.format("%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s", md5[0], md5[1], md5[2], md5[3], md5[4], + return new String(String.format("%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", md5[0], md5[1], md5[2], md5[3], md5[4], md5[5], md5[6], md5[7], md5[8], md5[9], md5[10], md5[11], md5[12], md5[13], md5[14], md5[15])); diff --git a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java index 459530763b..22305727f4 100644 --- a/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java +++ b/Tools/Source/FrameworkWizard/src/org/tianocore/frameworkwizard/far/Mainfest.java @@ -56,7 +56,7 @@ public class Mainfest implements ManifestInterface { // / // / Mainfest file element name // / - final static String mfFileName = "FarMainfest.MF"; + final static String mfFileName = "FrameworkArhciveMainfest.xml"; // // Header @@ -129,7 +129,7 @@ public class Mainfest implements ManifestInterface { // // Mainfest file // - File mfFile = null; + public File mfFile = null; public FarHeader getHeader() { return fhInfo; @@ -678,7 +678,7 @@ public class Mainfest implements ManifestInterface { Source source = new DOMSource(this.mainfestDoc); // // Prepare the output file, get the Mainifest file name from - // /. + // . // this.mfFile = new File(Workspace.getCurrentWorkspace() + File.separatorChar + mfFileName); // @@ -686,6 +686,10 @@ public class Mainfest implements ManifestInterface { // Result result = new StreamResult(this.mfFile); xformer.transform(source, result); + // + // Close result. Flush file by manual for Jdk1.5.0_04. + // + ((StreamResult) result).getOutputStream().close(); } public void pkgToFarPkgNode(Element parentNode, FarPackage pkgItem) {