2 # This file is used to define a class object to describe a distribution package
4 # Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
6 # This program and the accompanying materials are licensed and made available
7 # under the terms and conditions of the BSD License which accompanies this
8 # 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.
15 DistributionPackageClass
23 from Library
.Misc
import Sdict
24 from Library
.Misc
import GetNonMetaDataFiles
25 from PomAdapter
.InfPomAlignment
import InfPomAlignment
26 from PomAdapter
.DecPomAlignment
import DecPomAlignment
27 import Logger
.Log
as Logger
28 from Logger
import StringTable
as ST
29 from Logger
.ToolError
import OPTION_VALUE_INVALID
30 from Logger
.ToolError
import FatalError
31 from Logger
.ToolError
import EDK1_INF_ERROR
32 from Object
.POM
.CommonObject
import IdentificationObject
33 from Object
.POM
.CommonObject
import CommonHeaderObject
34 from Object
.POM
.CommonObject
import MiscFileObject
36 ## DistributionPackageHeaderClass
38 # @param IdentificationObject: Identification Object
39 # @param CommonHeaderObject: Common Header Object
41 class DistributionPackageHeaderObject(IdentificationObject
, \
44 IdentificationObject
.__init
__(self
)
45 CommonHeaderObject
.__init
__(self
)
50 self
.Signature
= 'Md5Sum'
51 self
.XmlSpecification
= ''
53 def GetReadOnly(self
):
56 def SetReadOnly(self
, ReadOnly
):
57 self
.ReadOnly
= ReadOnly
59 def GetRePackage(self
):
62 def SetRePackage(self
, RePackage
):
63 self
.RePackage
= RePackage
68 def SetDate(self
, Date
):
74 def SetSignature(self
, Signature
):
75 self
.Signature
= Signature
77 def GetSignature(self
):
80 def SetXmlSpecification(self
, XmlSpecification
):
81 self
.XmlSpecification
= XmlSpecification
83 def GetXmlSpecification(self
):
84 return self
.XmlSpecification
86 ## DistributionPackageClass
88 # @param object: DistributionPackageClass
90 class DistributionPackageClass(object):
92 self
.Header
= DistributionPackageHeaderObject()
94 # {(Guid, Version, Path) : PackageObj}
96 self
.PackageSurfaceArea
= Sdict()
98 # {(Guid, Version, Path) : ModuleObj}
100 self
.ModuleSurfaceArea
= Sdict()
101 self
.Tools
= MiscFileObject()
102 self
.MiscellaneousFiles
= MiscFileObject()
103 self
.UserExtensions
= []
106 ## Get all included packages and modules for a distribution package
108 # @param WorkspaceDir: WorkspaceDir
109 # @param PackageList: A list of all packages
110 # @param ModuleList: A list of all modules
112 def GetDistributionPackage(self
, WorkspaceDir
, PackageList
, ModuleList
):
117 for PackageFile
in PackageList
:
118 PackageFileFullPath
= \
119 os
.path
.normpath(os
.path
.join(WorkspaceDir
, PackageFile
))
120 DecObj
= DecPomAlignment(PackageFileFullPath
, WorkspaceDir
, CheckMulDec
= True)
123 # Parser inf file one bye one
125 ModuleInfFileList
= PackageObj
.GetModuleFileList()
126 for File
in ModuleInfFileList
:
127 WsRelPath
= os
.path
.join(PackageObj
.GetPackagePath(), File
)
128 WsRelPath
= os
.path
.normpath(WsRelPath
)
129 if ModuleList
and WsRelPath
in ModuleList
:
131 OPTION_VALUE_INVALID
,
132 ST
.ERR_NOT_STANDALONE_MODULE_ERROR
%\
133 (WsRelPath
, PackageFile
))
134 Filename
= os
.path
.normpath\
135 (os
.path
.join(PackageObj
.GetRelaPath(), File
))
136 os
.path
.splitext(Filename
)
138 # Call INF parser to generate Inf Object.
139 # Actually, this call is not directly call, but wrapped by
140 # Inf class in InfPomAlignment.
143 ModuleObj
= InfPomAlignment(Filename
, WorkspaceDir
, \
144 PackageObj
.GetPackagePath())
147 # Add module to package
149 ModuleDict
= PackageObj
.GetModuleDict()
150 ModuleDict
[(ModuleObj
.GetGuid(), \
151 ModuleObj
.GetVersion(), \
152 ModuleObj
.GetCombinePath())] = ModuleObj
153 PackageObj
.SetModuleDict(ModuleDict
)
154 except FatalError
, ErrCode
:
155 if ErrCode
.message
== EDK1_INF_ERROR
:
157 ST
.WRN_EDK1_INF_FOUND
%Filename
)
161 self
.PackageSurfaceArea\
162 [(PackageObj
.GetGuid(), PackageObj
.GetVersion(), \
163 PackageObj
.GetCombinePath())] = PackageObj
169 for ModuleFile
in ModuleList
:
170 ModuleFileFullPath
= \
171 os
.path
.normpath(os
.path
.join(WorkspaceDir
, ModuleFile
))
173 ModuleObj
= InfPomAlignment(ModuleFileFullPath
,
175 self
.ModuleSurfaceArea
[(ModuleObj
.GetGuid(), \
176 ModuleObj
.GetVersion(), \
177 ModuleObj
.GetCombinePath())] = \
179 except FatalError
, ErrCode
:
180 if ErrCode
.message
== EDK1_INF_ERROR
:
183 ST
.WRN_EDK1_INF_FOUND
%ModuleFileFullPath
,
184 ExtraData
=ST
.ERR_NOT_SUPPORTED_SA_MODULE
)
188 ## Get all files included for a distribution package, except tool/misc of
191 # @retval DistFileList A list of filepath for NonMetaDataFile, relative to workspace
192 # @retval MetaDataFileList A list of filepath for MetaDataFile, relative to workspace
194 def GetDistributionFileList(self
):
195 MetaDataFileList
= []
197 for Guid
, Version
, Path
in self
.PackageSurfaceArea
:
198 Package
= self
.PackageSurfaceArea
[Guid
, Version
, Path
]
199 PackagePath
= Package
.GetPackagePath()
200 FullPath
= Package
.GetFullPath()
201 MetaDataFileList
.append(Path
)
202 IncludePathList
= Package
.GetIncludePathList()
203 for IncludePath
in IncludePathList
:
204 SearchPath
= os
.path
.normpath(os
.path
.join(os
.path
.dirname(FullPath
), IncludePath
))
205 AddPath
= os
.path
.normpath(os
.path
.join(PackagePath
, IncludePath
))
206 self
.FileList
+= GetNonMetaDataFiles(SearchPath
, ['CVS', '.svn'], False, AddPath
)
209 ModuleDict
= Package
.GetModuleDict()
210 for Guid
, Version
, Path
in ModuleDict
:
211 Module
= ModuleDict
[Guid
, Version
, Path
]
212 ModulePath
= Module
.GetModulePath()
213 FullPath
= Module
.GetFullPath()
214 PkgRelPath
= os
.path
.normpath(os
.path
.join(PackagePath
, ModulePath
))
215 MetaDataFileList
.append(Path
)
216 self
.FileList
+= GetNonMetaDataFiles(os
.path
.dirname(FullPath
), ['CVS', '.svn'], False, PkgRelPath
)
218 for Guid
, Version
, Path
in self
.ModuleSurfaceArea
:
219 Module
= self
.ModuleSurfaceArea
[Guid
, Version
, Path
]
220 ModulePath
= Module
.GetModulePath()
221 FullPath
= Module
.GetFullPath()
222 MetaDataFileList
.append(Path
)
223 self
.FileList
+= GetNonMetaDataFiles(os
.path
.dirname(FullPath
), ['CVS', '.svn'], False, ModulePath
)
225 return self
.FileList
, MetaDataFileList