]>
git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/Capsule.py
85f95a69c1f050036dd2daf3bca052187cd56613
4 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
6 # This program and the accompanying materials
7 # are licensed and made available under the terms and conditions of the BSD License
8 # which accompanies this distribution. The full text of the license may be found at
9 # http://opensource.org/licenses/bsd-license.php
11 # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 from GenFdsGlobalVariable
import GenFdsGlobalVariable
19 from CommonDataClass
.FdfClass
import CapsuleClassObject
20 import Common
.LongFilePathOs
as os
23 from Common
.Misc
import SaveFileOnChange
24 from GenFds
import GenFds
29 ## create inf file describes what goes into capsule and call GenFv to generate capsule
32 class Capsule (CapsuleClassObject
) :
35 # @param self The object pointer
38 CapsuleClassObject
.__init
__(self
)
43 self
.CapsuleName
= None
47 # @param self The object pointer
48 # @retval string Generated Capsule file path
51 if self
.UiCapsuleName
.upper() + 'cap' in GenFds
.ImageBinDict
.keys():
52 return GenFds
.ImageBinDict
[self
.UiCapsuleName
.upper() + 'cap']
54 GenFdsGlobalVariable
.InfLogger( "\nGenerate %s Capsule" %self
.UiCapsuleName
)
55 CapInfFile
= self
.GenCapInf()
56 CapInfFile
.writelines("[files]" + T_CHAR_LF
)
58 for CapsuleDataObj
in self
.CapsuleDataList
:
59 CapsuleDataObj
.CapsuleName
= self
.CapsuleName
60 FileName
= CapsuleDataObj
.GenCapsuleSubItem()
61 CapsuleDataObj
.CapsuleName
= None
62 CapFileList
.append(FileName
)
63 CapInfFile
.writelines("EFI_FILE_NAME = " + \
66 SaveFileOnChange(self
.CapInfFileName
, CapInfFile
.getvalue(), False)
69 # Call GenFv tool to generate capsule
71 CapOutputFile
= os
.path
.join(GenFdsGlobalVariable
.FvDir
, self
.UiCapsuleName
)
72 CapOutputFile
= CapOutputFile
+ '.Cap'
73 GenFdsGlobalVariable
.GenerateFirmwareVolume(
75 [self
.CapInfFileName
],
80 GenFdsGlobalVariable
.VerboseLogger( "\nGenerate %s Capsule Successfully" %self
.UiCapsuleName
)
81 GenFdsGlobalVariable
.SharpCounter
= 0
82 GenFds
.ImageBinDict
[self
.UiCapsuleName
.upper() + 'cap'] = CapOutputFile
85 ## Generate inf file for capsule
87 # @param self The object pointer
88 # @retval file inf file object
91 self
.CapInfFileName
= os
.path
.join(GenFdsGlobalVariable
.FvDir
,
92 self
.UiCapsuleName
+ "_Cap" + '.inf')
93 CapInfFile
= StringIO
.StringIO() #open (self.CapInfFileName , 'w+')
95 CapInfFile
.writelines("[options]" + T_CHAR_LF
)
97 for Item
in self
.TokensDict
.keys():
98 CapInfFile
.writelines("EFI_" + \
101 self
.TokensDict
.get(Item
) + \