From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by spool.mail.gandi.net (Postfix) with ESMTPS id E4E8FD8018D for ; Tue, 28 Nov 2023 01:04:05 +0000 (UTC) DKIM-Signature: a=rsa-sha256; bh=QsSqmfZCdh2f9S81lzZpRJqTQhzXugeir5Qt+H2f6jg=; c=relaxed/simple; d=groups.io; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References:MIME-Version:Precedence:List-Subscribe:List-Help:Sender:List-Id:Mailing-List:Delivered-To:Reply-To:List-Unsubscribe-Post:List-Unsubscribe:Content-Transfer-Encoding; s=20140610; t=1701133444; v=1; b=H/4aiTMLWP0wprZikPCRIw/+bYc3FlB7ffFWt72V6XtZQojWFUwASN1BWhK71/v49AZN7VL/ zZme96J8VljRfivGezeAnBlwx/h2zjW++f9zne5RsUhBJrQCGdxv4Djb6syXReoyL8dFM7YG1ls riiEloYrBh7/rxZ2MNLPhlVE= X-Received: by 127.0.0.2 with SMTP id MczYYY7687511xf6VUcBPGRp; Mon, 27 Nov 2023 17:04:04 -0800 X-Received: from mgamail.intel.com (mgamail.intel.com [134.134.136.20]) by mx.groups.io with SMTP id smtpd.web11.5492.1701133441440565922 for ; Mon, 27 Nov 2023 17:04:02 -0800 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="383208390" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="383208390" X-Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 17:04:00 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10907"; a="859243510" X-IronPort-AV: E=Sophos;i="6.04,232,1695711600"; d="scan'208";a="859243510" X-Received: from nldesimo-desk.amr.corp.intel.com ([10.241.240.67]) by fmsmga003-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Nov 2023 17:03:59 -0800 From: "Nate DeSimone" To: devel@edk2.groups.io Cc: Chasel Chiu , Liming Gao , Eric Dong Subject: [edk2-devel] [edk2-platforms][PATCH v1] MinPlatformPkg: Update PatchFv Tools for Python 3.x Date: Mon, 27 Nov 2023 17:03:37 -0800 Message-Id: <20231128010339.1954-2-nathaniel.l.desimone@intel.com> In-Reply-To: <20231128010339.1954-1-nathaniel.l.desimone@intel.com> References: <20231128010339.1954-1-nathaniel.l.desimone@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Subscribe: List-Help: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,nathaniel.l.desimone@intel.com List-Unsubscribe-Post: List-Unsubscribe=One-Click List-Unsubscribe: X-Gm-Message-State: 5VbYiE0j1RClvfILYncZRtrTx7686176AA= Content-Transfer-Encoding: 8bit X-GND-Status: LEGIT Authentication-Results: spool.mail.gandi.net; dkim=pass header.d=groups.io header.s=20140610 header.b="H/4aiTML"; spf=pass (spool.mail.gandi.net: domain of bounce@groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce@groups.io; dmarc=fail reason="SPF not aligned (relaxed), DKIM not aligned (relaxed)" header.from=intel.com (policy=none) PatchFv tools now run on Python 3.x Cc: Chasel Chiu Cc: Liming Gao Cc: Eric Dong Signed-off-by: Nate DeSimone --- .../MinPlatformPkg/Tools/PatchFv/PatchBfv.py | 35 ++++---- .../Tools/PatchFv/PatchBinFv.py | 69 ++++++++-------- .../Tools/PatchFv/RebaseBinFv.py | 82 +++++++++---------- 3 files changed, 92 insertions(+), 94 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBfv.py b/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBfv.py index 1312bfc328..f05480b91f 100644 --- a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBfv.py +++ b/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBfv.py @@ -1,6 +1,6 @@ ## @ PatchBfv.py # -# Copyright (c) 2017, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -11,8 +11,7 @@ import sys import time import shutil import struct -import binascii -from ctypes import * +from ctypes import * class FileChecker: def __init__(self): @@ -21,17 +20,17 @@ class FileChecker: self.pcd = ["", "", ""] def PrintPcd(self): - print "PCD: " + self.pcd[0] + "|" + self.pcd[1] + "(" + self.pcd[2] + ")" + print("PCD: {0}|{1}({2})".format(*(self.pcd))) def ProcessReport(self): try : file = open(self.reportFile) except Exception: - print "fail to open " + self.reportFile + print("fail to open " + self.reportFile) return try: file.seek(0) - print "checking - " + self.pcd[0] + print("checking - " + self.pcd[0]) ValuePair = self.GetPcdFromReport (file, self.pcd[0]) self.pcd[1] = ValuePair[0] self.pcd[2] = ValuePair[1] @@ -42,12 +41,12 @@ class FileChecker: def PatchFd(self): fileName = self.fdName - print "patching BFV - " + fileName + print("patching BFV - " + fileName) try : file = open(fileName, "rb") except Exception: - print "fail to open " + fileName + print("fail to open " + fileName) return try: buffer = file.read() @@ -57,7 +56,7 @@ class FileChecker: offset = -4 l = struct.pack("L", int(self.pcd[1],16)) - print " [" + hex(offset) + "] " + binascii.hexlify(data[-4:]) + " <= " + binascii.hexlify(l) + print(" [" + hex(offset) + "] " + bytes(data[-4:]).hex() + " <= " + bytes(l).hex()) data[-4:] = l file = open(fileName, "wb") @@ -77,36 +76,36 @@ class FileChecker: newline = line[:-1] - if (cmp (newline, TargetPkg) == 0): + if newline == TargetPkg: FoundPkg = True continue - if (cmp (newline, "") == 0) or ((cmp (newline[0], " ") != 0) and (cmp (newline[0], "0") != 0)): + if newline == "" or (newline[0] != " " and newline[0] != "0"): FoundPkg = False if (FoundPkg == True) : newline = newline.strip() splitLine = newline.split(" ", 2) - if (cmp (splitLine[0], "*F") == 0) or (cmp (splitLine[0], "*P") == 0) : - if (cmp (splitLine[1], TargetPcd) == 0): - print "found - " + TargetPkg + "." + TargetPcd + if splitLine[0] == "*F" or splitLine[0] == "*P": + if splitLine[1] == TargetPcd: + print("found - " + TargetPkg + "." + TargetPcd) splitLine = splitLine[2].strip()[1:].strip().split(" ", 1) - if (cmp (splitLine[0], "FIXED") == 0) or (cmp (splitLine[0], "PATCH") == 0): + if splitLine[0] == "FIXED" or splitLine[0] == "PATCH": SplitLine = splitLine[1].strip()[1:].split(")", 1) Type = SplitLine[0] Value = SplitLine[1].strip()[1:].strip().split()[0] - print " Type - (" + Type + "), Value - (" + Value + ")" + print(" Type - (" + Type + "), Value - (" + Value + ")") return [Value, Type] return ["", ""] - + def main(): global FileChecker fileChecker = FileChecker() if (len(sys.argv) != 4) : - print "usage: PatchBfv " + print("usage: PatchBfv ") return 0 fileChecker.fdName = sys.argv[1] diff --git a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBinFv.py b/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBinFv.py index b98c951b45..78576a3029 100644 --- a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBinFv.py +++ b/Platform/Intel/MinPlatformPkg/Tools/PatchFv/PatchBinFv.py @@ -1,6 +1,6 @@ ## @ PatchBinFv.py # -# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # ## @@ -11,7 +11,6 @@ import sys import time import shutil import struct -import binascii from ctypes import * class FileChecker: @@ -30,20 +29,20 @@ class FileChecker: def IsSyncSection(self, line): name = self.GetSectionName(line) for sectionName in self.SyncSectionList: - if (cmp (sectionName, name) == 0) : + if sectionName == name: return True return False def PrintPcdList(self, pcdList): for pcd in pcdList: - print "PCD: " + pcd[0] + "|" + pcd[1] + "|" + pcd[2] + " <== " + pcd[3] + "(" + pcd[4] + ")" + print(("PCD: {0} | {1} | {2} <== {3}({4})".format(*pcd))) def GetInfFileGuid(self, fileName): guid = "" try : file = open(fileName) except Exception: - print "fail to open " + fileName + print("fail to open " + fileName) return try: while 1: @@ -53,7 +52,7 @@ class FileChecker: newline = line[:-1] - if cmp (line[:11], " FILE_GUID") == 0: + if line[:11] == " FILE_GUID": splitLine = line.split("=") templine = splitLine[1] guid = templine[1:1+36] @@ -66,7 +65,7 @@ class FileChecker: try : file = open(fileName) except Exception: - print "fail to open " + fileName + print("fail to open " + fileName) return try: while 1: @@ -76,23 +75,23 @@ class FileChecker: newline = line[:-1] - if cmp (line[0], "#") == 0: + if line[0] == "#": continue - if cmp (line[0], "[") == 0: + if line[0] == "[": SyncToDest = self.IsSyncSection(line) PatchOffset = False - if (cmp (self.GetSectionName(line), "PatchPcd") == 0) : + if (self.GetSectionName(line) == "PatchPcd"): PatchOffset = True continue if SyncToDest == True : line = line.strip() - if (cmp (line, "") == 0) : + if line == "": continue - if (cmp (line[0], "#") == 0) : + if line[0] == "#": continue splitLine = line.split(" ") @@ -108,9 +107,9 @@ class FileChecker: def ProcessFvInf(self, fvName): sourceFileName = os.path.join(self.sourceRoot,fvName,self.target,fvName+".inf") - print "\nprocessing - " + sourceFileName + print("\nprocessing - " + sourceFileName) fileGuid = self.GetInfFileGuid (sourceFileName) - print "FV NAME GUID - " + fileGuid + print("FV NAME GUID - " + fileGuid) self.InfPcdList = [] self.ParseInfFile(sourceFileName) @@ -122,12 +121,12 @@ class FileChecker: try : file = open(self.reportFile) except Exception: - print "fail to open " + self.reportFile + print("fail to open " + self.reportFile) return try: for pcd in self.InfPcdList: file.seek(0) - print "checking - " + pcd[0] + print("checking - " + pcd[0]) ValuePair = self.GetPcdFromReport (file, pcd[0]) pcd[3] = ValuePair[0] pcd[4] = ValuePair[1] @@ -138,12 +137,12 @@ class FileChecker: def PatchFv(self, fvName): sourceFileName = os.path.join(self.sourceRoot,fvName,self.target,fvName+".Fv") - print "patching - " + sourceFileName + print("patching - " + sourceFileName) try : file = open(sourceFileName, "rb") except Exception: - print "fail to open " + sourceFileName + print("fail to open " + sourceFileName) return try: buffer = file.read() @@ -152,21 +151,21 @@ class FileChecker: for pcd in self.InfPcdList: offset = int(pcd[2], 16) - if (cmp (pcd[4], "BOOLEAN") == 0) or (cmp (pcd[4], "UINT8") == 0): + if (pcd[4] == "BOOLEAN") or (pcd[4] == "UINT8"): b = struct.pack("B", int(pcd[3],16)) - print " [" + hex(offset) + "] " + binascii.hexlify(data[offset:offset+1]) + " <= " + binascii.hexlify(b) + print(" [" + hex(offset) + "] " + bytes(data[offset:offset+1]).hex() + " <= " + bytes(b).hex()) data[offset:offset+1] = b - elif (cmp (pcd[4], "UINT16") == 0): + elif (pcd[4] == "UINT16"): h = struct.pack("H", int(pcd[3],16)) - print " [" + hex(offset) + "] " + binascii.hexlify(data[offset:offset+2]) + " <= " + binascii.hexlify(h) + print(" [" + hex(offset) + "] " + bytes(data[offset:offset+2]).hex() + " <= " + bytes(h).hex()) data[offset:offset+2] = h - elif (cmp (pcd[4], "UINT32") == 0): + elif (pcd[4] == "UINT32"): l = struct.pack("I", int(pcd[3],16)) - print " [" + hex(offset) + "] " + binascii.hexlify(data[offset:offset+4]) + " <= " + binascii.hexlify(l) + print(" [" + hex(offset) + "] " + bytes(data[offset:offset+4]).hex() + " <= " + bytes(l).hex()) data[offset:offset+4] = l - elif (cmp (pcd[4], "UINT64") == 0): + elif (pcd[4] == "UINT64"): q = struct.pack("Q", int(pcd[3],16)) - print " [" + hex(offset) + "] " + binascii.hexlify(data[offset:offset+8]) + " <= " + binascii.hexlify(q) + print(" [" + hex(offset) + "] " + bytes(data[offset:offset+8]).hex() + " <= " + bytes(q).hex()) data[offset:offset+8] = q file = open(sourceFileName, "wb") file.write(data) @@ -185,36 +184,36 @@ class FileChecker: newline = line[:-1] - if (cmp (newline, TargetPkg) == 0): + if (newline == TargetPkg): FoundPkg = True continue - if (cmp (newline, "") == 0) or ((cmp (newline[0], " ") != 0) and (cmp (newline[0], "0") != 0)): + if (newline == "") or ((newline[0] != " ") and (newline[0] != "0")): FoundPkg = False if (FoundPkg == True) : newline = newline.strip() splitLine = newline.split(" ", 2) - if (cmp (splitLine[0], "*F") == 0) or (cmp (splitLine[0], "*P") == 0): - if (cmp (splitLine[1], TargetPcd) == 0): - print "found - " + TargetPkg + "." + TargetPcd + if (splitLine[0] == "*F") or (splitLine[0] == "*P"): + if (splitLine[1] == TargetPcd): + print("found - " + TargetPkg + "." + TargetPcd) splitLine = splitLine[2].strip()[1:].strip().split(" ", 1) - if (cmp (splitLine[0], "FIXED") == 0) or (cmp (splitLine[0], "PATCH") == 0): + if (splitLine[0] == "FIXED") or (splitLine[0] == "PATCH"): SplitLine = splitLine[1].strip()[1:].split(")", 1) Type = SplitLine[0] Value = SplitLine[1].strip()[1:].strip().split()[0] - print " Type - (" + Type + "), Value - (" + Value + ")" + print(" Type - (" + Type + "), Value - (" + Value + ")") return [Value, Type] return ["", ""] - + def main(): global FileChecker fileChecker = FileChecker() if (len(sys.argv) != 5) : - print "usage: PatchBinFv " + print("usage: PatchBinFv ") return 0 fileChecker.target = sys.argv[1] diff --git a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/RebaseBinFv.py b/Platform/Intel/MinPlatformPkg/Tools/PatchFv/RebaseBinFv.py index 149630e4ef..2cea491f41 100644 --- a/Platform/Intel/MinPlatformPkg/Tools/PatchFv/RebaseBinFv.py +++ b/Platform/Intel/MinPlatformPkg/Tools/PatchFv/RebaseBinFv.py @@ -1,6 +1,6 @@ ## @ PatchBinFv.py # -# Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.
+# Copyright (c) 2017 - 2023, Intel Corporation. All rights reserved.
# SPDX-License-Identifier: BSD-2-Clause-Patent # @@ -10,8 +10,8 @@ import sys import time import shutil import struct -import binascii -from ctypes import * +from ctypes import * +from functools import reduce class GUID(Structure): _fields_ = [ @@ -380,9 +380,9 @@ class PeTeImage: def __init__(self, offset, data): self.Offset = offset tehdr = EFI_TE_IMAGE_HEADER.from_buffer (data, 0) - if tehdr.Signature == 'VZ': # TE image + if tehdr.Signature == b'VZ': # TE image self.TeHdr = tehdr - elif tehdr.Signature == 'MZ': # PE32 image + elif tehdr.Signature == b'MZ': # PE32 image self.TeHdr = None self.DosHdr = EFI_IMAGE_DOS_HEADER.from_buffer (data, 0) self.PeHdr = EFI_IMAGE_NT_HEADERS32.from_buffer (data, self.DosHdr.e_lfanew) @@ -397,7 +397,7 @@ class PeTeImage: self.RelocList = [] def IsTeImage(self): - return self.TeHdr is not None + return self.TeHdr is not None def ParseReloc(self): if self.IsTeImage(): @@ -415,7 +415,7 @@ class PeTeImage: offset += sizeof(blkhdr) # Read relocation type,offset pairs rlen = blkhdr.BlockSize - sizeof(PE_RELOC_BLOCK_HEADER) - rnum = rlen/sizeof(c_uint16) + rnum = rlen // sizeof(c_uint16) rdata = (c_uint16 * rnum).from_buffer(self.Data, offset) for each in rdata: roff = each & 0xfff @@ -532,21 +532,21 @@ class FileChecker: def IsSyncSection(self, line): name = self.GetSectionName(line) for sectionName in self.SyncSectionList: - if (cmp (sectionName, name) == 0) : + if sectionName == name: return True return False def PrintRebasePcd(self, pcd): - print "PCD: " + pcd[0] + "|" + pcd[3] + " <== " + pcd[1] + "(" + pcd[2] + ")" + print("PCD: {0} | {3} <== {1}({2})".format(*pcd)) def RebaseFv(self, fvName, rebasePcd): sourceFileName = os.path.join(self.sourceRoot,fvName,self.target,fvName+".Fv") - print "rebasing(FV) - " + sourceFileName + print("rebasing(FV) - " + sourceFileName) try : file = open(sourceFileName, "rb") except Exception: - print "fail to open " + sourceFileName + print("fail to open " + sourceFileName) return try: buffer = file.read() @@ -554,15 +554,15 @@ class FileChecker: file.close() FvHeader = EFI_FIRMWARE_VOLUME_HEADER.from_buffer (data, 0) - print "HeaderLength - " + hex(FvHeader.HeaderLength) - print "ExtHeaderOffset - " + hex(FvHeader.ExtHeaderOffset) + print("HeaderLength - " + hex(FvHeader.HeaderLength)) + print("ExtHeaderOffset - " + hex(FvHeader.ExtHeaderOffset)) if (FvHeader.ExtHeaderOffset == 0): Offset = FvHeader.HeaderLength else: FvExHeader = EFI_FIRMWARE_VOLUME_EXT_HEADER.from_buffer(data, FvHeader.ExtHeaderOffset) - print " FvName - %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" % (FvExHeader.FvName.Guid1, FvExHeader.FvName.Guid2, FvExHeader.FvName.Guid3, FvExHeader.FvName.Guid4[0], FvExHeader.FvName.Guid4[1], FvExHeader.FvName.Guid4[2], FvExHeader.FvName.Guid4[3], FvExHeader.FvName.Guid4[4], FvExHeader.FvName.Guid4[5], FvExHeader.FvName.Guid4[6], FvExHeader.FvName.Guid4[7]) - print " ExtHeaderSize - " + hex(FvExHeader.ExtHeaderSize) + print(" FvName - %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" % (FvExHeader.FvName.Guid1, FvExHeader.FvName.Guid2, FvExHeader.FvName.Guid3, FvExHeader.FvName.Guid4[0], FvExHeader.FvName.Guid4[1], FvExHeader.FvName.Guid4[2], FvExHeader.FvName.Guid4[3], FvExHeader.FvName.Guid4[4], FvExHeader.FvName.Guid4[5], FvExHeader.FvName.Guid4[6], FvExHeader.FvName.Guid4[7])) + print(" ExtHeaderSize - " + hex(FvExHeader.ExtHeaderSize)) Offset = FvHeader.ExtHeaderOffset + FvExHeader.ExtHeaderSize Offset = (Offset + 0x7) & ~0x7 @@ -576,20 +576,20 @@ class FileChecker: if (FfsHeader.Type == 0xFF) or (FfsHeader.Type == EFI_FV_FILETYPE_FFS_PAD) : Offset = (FfsOffset + FfsSize + 7) & ~0x7 continue - print "Ffs - %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" % (FfsHeader.Name.Guid1, FfsHeader.Name.Guid2, FfsHeader.Name.Guid3, FfsHeader.Name.Guid4[0], FfsHeader.Name.Guid4[1], FfsHeader.Name.Guid4[2], FfsHeader.Name.Guid4[3], FfsHeader.Name.Guid4[4], FfsHeader.Name.Guid4[5], FfsHeader.Name.Guid4[6], FfsHeader.Name.Guid4[7]) + print("Ffs - %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x" % (FfsHeader.Name.Guid1, FfsHeader.Name.Guid2, FfsHeader.Name.Guid3, FfsHeader.Name.Guid4[0], FfsHeader.Name.Guid4[1], FfsHeader.Name.Guid4[2], FfsHeader.Name.Guid4[3], FfsHeader.Name.Guid4[4], FfsHeader.Name.Guid4[5], FfsHeader.Name.Guid4[6], FfsHeader.Name.Guid4[7])) Offset = Offset + sizeof(EFI_FFS_FILE_HEADER) while (Offset < FfsOffset + FfsSize) : SectionHeader = EFI_COMMON_SECTION_HEADER.from_buffer (data, Offset) #print " Section - " + hex(Offset) if (SectionHeader.Type == EFI_SECTION_PE32) or (SectionHeader.Type == EFI_SECTION_TE) : PeOffset = Offset + sizeof(EFI_COMMON_SECTION_HEADER) - print " PE - " + hex(PeOffset) + "(" + binascii.hexlify(data[PeOffset:PeOffset+2]) + ")" + print(" PE - " + hex(PeOffset) + "(" + bytes(data[PeOffset:PeOffset+2]).hex() + ")") newbase = int(rebasePcd[1],16) oldbase = int(rebasePcd[3],16) delta = newbase - oldbase - print " delta - " + hex(delta) + "(" + hex(oldbase) + " <== " + hex(newbase) + ")" + print(" delta - " + hex(delta) + "(" + hex(oldbase) + " <== " + hex(newbase) + ")") PeLength = FfsSize-sizeof(EFI_FFS_FILE_HEADER); @@ -618,26 +618,26 @@ class FileChecker: newline = line[:-1].replace('\r','') - if (cmp (newline, TargetPkg) == 0): + if newline == TargetPkg: FoundPkg = True continue - if (cmp (newline, "") == 0) or ((cmp (newline[0], " ") != 0) and (cmp (newline[0], "0") != 0)): + if newline == "" or (newline[0] != " " and newline[0] != "0"): FoundPkg = False if (FoundPkg == True) : newline = newline.strip() splitLine = newline.split(" ", 2) - if (cmp (splitLine[0], "*F") == 0) or (cmp (splitLine[0], "*P") == 0): - if (cmp (splitLine[1], TargetPcd) == 0): - print "found - " + TargetPkg + "." + TargetPcd + if (splitLine[0] == "*F") or (splitLine[0] == "*P"): + if splitLine[1] == TargetPcd: + print("found - " + TargetPkg + "." + TargetPcd) splitLine = splitLine[2].strip()[1:].strip().split(" ", 1) - if (cmp (splitLine[0], "FIXED") == 0) or (cmp (splitLine[0], "PATCH") == 0): + if splitLine[0] == "FIXED" or splitLine[0] == "PATCH": SplitLine = splitLine[1].strip()[1:].split(")", 1) Type = SplitLine[0] Value = SplitLine[1].strip()[1:].strip().split()[0] - print " Type - (" + Type + "), Value - (" + Value + ")" + print(" Type - (" + Type + "), Value - (" + Value + ")") return [Value, Type] return ["", ""] @@ -648,7 +648,7 @@ class FileChecker: try : file = open(fileName) except Exception: - print "fail to open " + fileName + print("fail to open " + fileName) return try: while 1: @@ -658,21 +658,21 @@ class FileChecker: newline = line[:-1].replace('\r','') - if cmp (newline, "") == 0: + if newline == "": continue - if cmp (newline, "#![Pcd]") == 0: + if newline == "#![Pcd]": ParseBase = True continue if ParseBase == True : - if (cmp (line[0:2], "#!") != 0) : + if line[0:2] != "#!": ParseBase = False continue newline = newline[2:].strip() splitLine = newline.split("|") - if cmp (PcdName, splitLine[0]) == 0: + if PcdName == splitLine[0]: Value = splitLine[1] finally: file.close() @@ -681,11 +681,11 @@ class FileChecker: def SetNewFvBase (self, fvName, PcdName, OldFvBase, NewFvBase): fileName = os.path.join(self.sourceRoot,fvName,self.target,fvName+".inf") - print "update - " + fileName + print("update - " + fileName) try : file = open(fileName, "r") except Exception: - print "fail to open " + fileName + print("fail to open " + fileName) return try: lines = file.readlines() @@ -699,23 +699,23 @@ class FileChecker: newline = line[:-1].strip() - if cmp (newline, "") == 0: + if newline == "": continue - if cmp (newline, "#![Pcd]") == 0: + if newline == "#![Pcd]": ParseBase = True continue if ParseBase == True : - if (cmp (line[0:2], "#!") != 0) : + if line[0:2] != "#!": ParseBase = False continue newline = newline[2:].strip() splitLine = newline.split("|") - if cmp (PcdName, splitLine[0]) == 0: - if cmp (OldFvBase, splitLine[1]) != 0: - print "ERROR: OldFvBase mismatch!" + if PcdName == splitLine[0]: + if OldFvBase != splitLine[1]: + print("ERROR: OldFvBase mismatch!") else: lines[index] = "#! " + PcdName + "|" + NewFvBase + "\n" break @@ -730,11 +730,11 @@ class FileChecker: try : file = open(self.reportFile) except Exception: - print "fail to open " + self.reportFile + print("fail to open " + self.reportFile) return try: file.seek(0) - print "checking - " + self.RebasePcd[0] + print("checking - " + self.RebasePcd[0]) ValuePair = self.GetPcdFromReport (file, self.RebasePcd[0]) self.RebasePcd[1] = ValuePair[0] self.RebasePcd[2] = ValuePair[1] @@ -747,7 +747,7 @@ def main(): fileChecker = FileChecker() if (len(sys.argv) != 6) : - print "usage: RebaseBinFv " + print("usage: RebaseBinFv ") return 0 fileChecker.target = sys.argv[1] -- 2.39.2.windows.1 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#111773): https://edk2.groups.io/g/devel/message/111773 Mute This Topic: https://groups.io/mt/102842751/7686176 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io] -=-=-=-=-=-=-=-=-=-=-=-