Reviewed-by: Zailiang Sun <[email protected]> -----Original Message----- From: Gary Lin <[email protected]> Sent: Wednesday, February 12, 2020 2:24 PM To: [email protected] Cc: Sun, Zailiang <[email protected]>; Qian, Yi <[email protected]> Subject: [PATCH 2/2] Vlv2TbltDevicePkg/PreBuild.py: Remove unused functions
Clean up the script. Cc: Zailiang Sun <[email protected]> cc: Yi Qian <[email protected]> Signed-off-by: Gary Lin <[email protected]> --- Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py | 97 ---------------------------- 1 file changed, 97 deletions(-) diff --git a/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py b/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py index 220515c809..be1d23560e 100644 --- a/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py +++ b/Platform/Intel/Vlv2TbltDevicePkg/PreBuild.py @@ -59,108 +59,12 @@ def NormalizePath(target): else: return os.path.normpath (target) -def RemoveFile(target): - target = NormalizePath(target) - if not target or target == os.pathsep: - Error ('RemoveFile() invalid target') - if os.path.exists(target): - os.remove (target) - Log ('remove %s' % (RelativePath (target))) - -def RemoveDirectory(target): - target = NormalizePath(target) - if not target or target == os.pathsep: - Error ('RemoveDirectory() invalid target') - if os.path.exists(target): - Log ('rmdir %s' % (RelativePath (target))) - shutil.rmtree(target) - def CreateDirectory(target): target = NormalizePath(target) if not os.path.exists(target): Log ('mkdir %s' % (RelativePath (target))) os.makedirs (target) -def Copy(src, dst): - src = NormalizePath(src) - dst = NormalizePath(dst) - for File in glob.glob(src): - Log ('copy %s -> %s' % (RelativePath (File), RelativePath (dst))) - shutil.copy (File, dst) - -def GenCapsuleDevice (BaseName, PayloadFileName, Guid, Version, Lsv, CapsulesPath, CapsulesSubDir): - global gBaseToolsPath - LogAlways ('Generate Capsule: {0} {1:08x} {2:08x} {3}'.format (Guid, Version, Lsv, PayloadFileName)) - - VersionString = '.'.join([str(ord(x)) for x in struct.pack('>I', Version).decode()]) - - FmpCapsuleFile = NormalizePath ((CapsulesPath, CapsulesSubDir, BaseName + '.' + VersionString + '.cap')) - Command = GenerateCapsuleCommand.format ( - FMP_CAPSULE_GUID = Guid, - FMP_CAPSULE_VERSION = Version, - FMP_CAPSULE_LSV = Lsv, - BASE_TOOLS_PATH = gBaseToolsPath, - FMP_CAPSULE_FILE = FmpCapsuleFile, - FMP_CAPSULE_PAYLOAD = PayloadFileName - ) - Command = ' '.join(Command.splitlines()).strip() - if gArgs.Verbose: - Command = Command + ' -v' - - Log (Command) - - Process = subprocess.Popen(Command, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - ProcessOutput = Process.communicate() - - if Process.returncode == 0: - Log (ProcessOutput[0].decode()) - else: - LogAlways (Command) - LogAlways (ProcessOutput[0].decode()) - Error ('GenerateCapsule returned an error') - - Copy (PayloadFileName, (CapsulesPath, 'firmware.bin')) - MetaInfoXml = MetaInfoXmlTemplate - MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_GUID', Guid) - MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_BASE_NAME', BaseName) - MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_VERSION_DECIMAL', str(Version)) - MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_STRING', VersionString) - MetaInfoXml = MetaInfoXml.replace ('FMP_CAPSULE_DATE', str(datetime.date.today())) - f = open (NormalizePath ((CapsulesPath, 'firmware.metainfo.xml')), 'w') - f.write(MetaInfoXml) - f.close() - - f = open (NormalizePath ((CapsulesPath, 'Lvfs.ddf')), 'w') - f.write(LvfsDdfTemplate) - f.close() - - if sys.platform == "win32": - Command = 'makecab /f ' + NormalizePath ((CapsulesPath, 'Lvfs.ddf')) - else: - Command = 'gcab --create firmware.cab firmware.bin firmware.metainfo.xml' - Log (Command) - - Process = subprocess.Popen(Command, cwd=CapsulesPath, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, shell=True) - ProcessOutput = Process.communicate() - - if Process.returncode == 0: - Log (ProcessOutput[0].decode()) - else: - LogAlways (Command) - LogAlways (ProcessOutput[0].decode()) - Error ('GenerateCapsule returned an error') - - FmpCabinetFile = NormalizePath ((CapsulesPath, CapsulesSubDir, BaseName + '.' + VersionString + '.cab')) - - Copy ((CapsulesPath, 'firmware.cab'), FmpCabinetFile) - - RemoveFile ((CapsulesPath, 'firmware.cab')) - RemoveFile ((CapsulesPath, 'setup.inf')) - RemoveFile ((CapsulesPath, 'setup.rpt')) - RemoveFile ((CapsulesPath, 'Lvfs.ddf')) - RemoveFile ((CapsulesPath, 'firmware.metainfo.xml')) - RemoveFile ((CapsulesPath, 'firmware.bin')) - BiosIdTemplate = ''' BOARD_ID = MNW2MAX BOARD_REV = $BOARD_REV @@ -170,7 +74,6 @@ BUILD_TYPE = $BUILD_TYPE VERSION_MINOR = 01 ''' - if __name__ == '__main__': # # Create command line argument parser object -- 2.16.4 -=-=-=-=-=-=-=-=-=-=-=- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#54261): https://edk2.groups.io/g/devel/message/54261 Mute This Topic: https://groups.io/mt/71206013/21656 Group Owner: [email protected] Unsubscribe: https://edk2.groups.io/g/devel/unsub [[email protected]] -=-=-=-=-=-=-=-=-=-=-=-
