]> git.proxmox.com Git - mirror_edk2.git/blob - BaseTools/Source/Python/GenFds/CapsuleData.py
Sync EDKII BaseTools to BaseTools project r1971
[mirror_edk2.git] / BaseTools / Source / Python / GenFds / CapsuleData.py
1 ## @file
2 # generate capsule
3 #
4 # Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
5 #
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
10 #
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.
13 #
14
15 ##
16 # Import Modules
17 #
18 import Ffs
19 from GenFdsGlobalVariable import GenFdsGlobalVariable
20 import StringIO
21
22 ## base class for capsule data
23 #
24 #
25 class CapsuleData:
26 ## The constructor
27 #
28 # @param self The object pointer
29 def __init__(self):
30 pass
31
32 ## generate capsule data
33 #
34 # @param self The object pointer
35 def GenCapsuleSubItem(self):
36 pass
37
38 ## FFS class for capsule data
39 #
40 #
41 class CapsuleFfs (CapsuleData):
42 ## The constructor
43 #
44 # @param self The object pointer
45 #
46 def __init_(self) :
47 self.Ffs = None
48 self.FvName = None
49
50 ## generate FFS capsule data
51 #
52 # @param self The object pointer
53 # @retval string Generated file name
54 #
55 def GenCapsuleSubItem(self):
56 FfsFile = self.Ffs.GenFfs()
57 return FfsFile
58
59 ## FV class for capsule data
60 #
61 #
62 class CapsuleFv (CapsuleData):
63 ## The constructor
64 #
65 # @param self The object pointer
66 #
67 def __init__(self) :
68 self.Ffs = None
69 self.FvName = None
70 self.CapsuleName = None
71
72 ## generate FV capsule data
73 #
74 # @param self The object pointer
75 # @retval string Generated file name
76 #
77 def GenCapsuleSubItem(self):
78 if self.FvName.find('.fv') == -1:
79 if self.FvName.upper() in GenFdsGlobalVariable.FdfParser.Profile.FvDict.keys():
80 FvObj = GenFdsGlobalVariable.FdfParser.Profile.FvDict.get(self.FvName.upper())
81 FdBuffer = StringIO.StringIO('')
82 FvObj.CapsuleName = self.CapsuleName
83 FvFile = FvObj.AddToBuffer(FdBuffer)
84 FvObj.CapsuleName = None
85 FdBuffer.close()
86 return FvFile
87 else:
88 FvFile = GenFdsGlobalVariable.ReplaceWorkspaceMacro(self.FvName)
89 return FvFile