]> git.proxmox.com Git - mirror_edk2.git/blame - BaseTools/Source/Python/UPT/InstallPkg.py
BaseTools: Remove './SecMain' from 'run' target
[mirror_edk2.git] / BaseTools / Source / Python / UPT / InstallPkg.py
CommitLineData
4234283c
LG
1## @file\r
2# Install distribution package.\r
3#\r
f7496d71 4# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
4234283c 5#\r
2e351cbe 6# SPDX-License-Identifier: BSD-2-Clause-Patent\r
4234283c
LG
7#\r
8"""\r
9Install a distribution package\r
10"""\r
11##\r
12# Import Modules\r
13#\r
421ccda3 14from Core.FileHook import __FileHookOpen__\r
4234283c
LG
15import os.path\r
16from os import chmod\r
17from os import SEEK_SET\r
18from os import SEEK_END\r
19import stat\r
fcb1af1b 20from hashlib import md5\r
421ccda3 21import copy\r
4234283c
LG
22from sys import stdin\r
23from sys import platform\r
24from shutil import rmtree\r
25from shutil import copyfile\r
26from traceback import format_exc\r
27from platform import python_version\r
28\r
29from Logger import StringTable as ST\r
30from Logger.ToolError import UNKNOWN_ERROR\r
31from Logger.ToolError import FILE_UNKNOWN_ERROR\r
32from Logger.ToolError import OPTION_MISSING\r
33from Logger.ToolError import UPT_ALREADY_INSTALLED_ERROR\r
34from Logger.ToolError import FatalError\r
35from Logger.ToolError import ABORT_ERROR\r
36from Logger.ToolError import CODE_ERROR\r
37from Logger.ToolError import FORMAT_INVALID\r
38from Logger.ToolError import FILE_TYPE_MISMATCH\r
39import Logger.Log as Logger\r
40\r
4234283c
LG
41from Library.Misc import Sdict\r
42from Library.Misc import ConvertPath\r
43from Library.ParserValidate import IsValidInstallPath\r
44from Xml.XmlParser import DistributionPackageXml\r
45from GenMetaFile.GenDecFile import PackageToDec\r
46from GenMetaFile.GenInfFile import ModuleToInf\r
47from Core.PackageFile import PackageFile\r
48from Core.PackageFile import FILE_NOT_FOUND\r
49from Core.PackageFile import FILE_CHECKSUM_FAILURE\r
50from Core.PackageFile import CreateDirectory\r
51from Core.DependencyRules import DependencyRules\r
52from Library import GlobalData\r
53\r
54## InstallNewPackage\r
55#\r
56# @param WorkspaceDir: Workspace Directory\r
57# @param Path: Package Path\r
58# @param CustomPath: whether need to customize path at first\r
59#\r
60def InstallNewPackage(WorkspaceDir, Path, CustomPath = False):\r
61 if os.path.isabs(Path):\r
62 Logger.Info(ST.MSG_RELATIVE_PATH_ONLY%Path)\r
63 elif CustomPath:\r
64 Logger.Info(ST.MSG_NEW_PKG_PATH)\r
65 else:\r
66 Path = ConvertPath(Path)\r
67 Path = os.path.normpath(Path)\r
68 FullPath = os.path.normpath(os.path.join(WorkspaceDir, Path))\r
69 if os.path.exists(FullPath):\r
70 Logger.Info(ST.ERR_DIR_ALREADY_EXIST%FullPath)\r
71 else:\r
72 return Path\r
73\r
74 Input = stdin.readline()\r
75 Input = Input.replace('\r', '').replace('\n', '')\r
76 if Input == '':\r
77 Logger.Error("InstallPkg", UNKNOWN_ERROR, ST.ERR_USER_INTERRUPT)\r
78 Input = Input.replace('\r', '').replace('\n', '')\r
79 return InstallNewPackage(WorkspaceDir, Input, False)\r
80\r
4234283c
LG
81## InstallNewModule\r
82#\r
83# @param WorkspaceDir: Workspace Directory\r
84# @param Path: Standalone Module Path\r
85# @param PathList: The already installed standalone module Path list\r
86#\r
87def InstallNewModule(WorkspaceDir, Path, PathList = None):\r
4231a819 88 if PathList is None:\r
4234283c
LG
89 PathList = []\r
90 Path = ConvertPath(Path)\r
91 Path = os.path.normpath(Path)\r
92 FullPath = os.path.normpath(os.path.join(WorkspaceDir, Path))\r
93 if os.path.exists(FullPath) and FullPath not in PathList:\r
94 Logger.Info(ST.ERR_DIR_ALREADY_EXIST%Path)\r
95 elif Path == FullPath:\r
96 Logger.Info(ST.MSG_RELATIVE_PATH_ONLY%FullPath)\r
97 else:\r
98 return Path\r
f7496d71 99\r
4234283c
LG
100 Input = stdin.readline()\r
101 Input = Input.replace('\r', '').replace('\n', '')\r
102 if Input == '':\r
103 Logger.Error("InstallPkg", UNKNOWN_ERROR, ST.ERR_USER_INTERRUPT)\r
104 Input = Input.replace('\r', '').replace('\n', '')\r
105 return InstallNewModule(WorkspaceDir, Input, PathList)\r
106\r
f7496d71 107\r
4234283c
LG
108## InstallNewFile\r
109#\r
110# @param WorkspaceDir: Workspace Direction\r
111# @param File: File\r
112#\r
113def InstallNewFile(WorkspaceDir, File):\r
114 FullPath = os.path.normpath(os.path.join(WorkspaceDir, File))\r
115 if os.path.exists(FullPath):\r
116 Logger.Info(ST.ERR_FILE_ALREADY_EXIST %File)\r
117 Input = stdin.readline()\r
118 Input = Input.replace('\r', '').replace('\n', '')\r
119 if Input == '':\r
120 Logger.Error("InstallPkg", UNKNOWN_ERROR, ST.ERR_USER_INTERRUPT)\r
121 Input = Input.replace('\r', '').replace('\n', '')\r
122 return InstallNewFile(WorkspaceDir, Input)\r
123 else:\r
124 return File\r
125\r
126## UnZipDp\r
127#\r
128# UnZipDp\r
129#\r
56636814 130def UnZipDp(WorkspaceDir, DpPkgFileName, Index=1):\r
4234283c
LG
131 ContentZipFile = None\r
132 Logger.Quiet(ST.MSG_UZIP_PARSE_XML)\r
4234283c 133 DistFile = PackageFile(DpPkgFileName)\r
f7496d71 134\r
4234283c 135 DpDescFileName, ContentFileName = GetDPFile(DistFile.GetZipFile())\r
f7496d71 136\r
56636814
HC
137 TempDir = os.path.normpath(os.path.join(WorkspaceDir, "Conf/.tmp%s" % str(Index)))\r
138 GlobalData.gUNPACK_DIR.append(TempDir)\r
139 DistPkgFile = DistFile.UnpackFile(DpDescFileName, os.path.normpath(os.path.join(TempDir, DpDescFileName)))\r
4234283c
LG
140 if not DistPkgFile:\r
141 Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_FILE_BROKEN %DpDescFileName)\r
f7496d71 142\r
4234283c
LG
143 #\r
144 # Generate distpkg\r
145 #\r
146 DistPkgObj = DistributionPackageXml()\r
147 DistPkg = DistPkgObj.FromXml(DistPkgFile)\r
148 if DistPkg.Header.RePackage == '':\r
149 DistPkg.Header.RePackage = False\r
150 if DistPkg.Header.ReadOnly == '':\r
151 DistPkg.Header.ReadOnly = False\r
421ccda3 152\r
4234283c
LG
153 #\r
154 # unzip contents.zip file\r
155 #\r
56636814 156 ContentFile = DistFile.UnpackFile(ContentFileName, os.path.normpath(os.path.join(TempDir, ContentFileName)))\r
4234283c
LG
157 if not ContentFile:\r
158 Logger.Error("InstallPkg", FILE_NOT_FOUND,\r
159 ST.ERR_FILE_BROKEN % ContentFileName)\r
160\r
4234283c
LG
161 #\r
162 # Get file size\r
f7496d71 163 #\r
56636814 164 FileSize = os.path.getsize(ContentFile)\r
f7496d71
LG
165\r
166 if FileSize != 0:\r
4234283c
LG
167 ContentZipFile = PackageFile(ContentFile)\r
168\r
169 #\r
170 # verify MD5 signature when existed\r
171 #\r
172 if DistPkg.Header.Signature != '':\r
fb0b35e0
AC
173 Md5Signature = md5(__FileHookOpen__(ContentFile, 'rb').read())\r
174 if DistPkg.Header.Signature != Md5Signature.hexdigest():\r
4234283c
LG
175 ContentZipFile.Close()\r
176 Logger.Error("InstallPkg", FILE_CHECKSUM_FAILURE,\r
177 ExtraData=ContentFile)\r
178\r
421ccda3 179 return DistPkg, ContentZipFile, DpPkgFileName, DistFile\r
4234283c
LG
180\r
181## GetPackageList\r
182#\r
183# GetPackageList\r
184#\r
185def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleList, PackageList):\r
186 NewDict = Sdict()\r
187 for Guid, Version, Path in DistPkg.PackageSurfaceArea:\r
188 PackagePath = Path\r
189 Package = DistPkg.PackageSurfaceArea[Guid, Version, Path]\r
190 Logger.Info(ST.MSG_INSTALL_PACKAGE % Package.GetName())\r
56636814
HC
191# if Dep.CheckPackageExists(Guid, Version):\r
192# Logger.Info(ST.WRN_PACKAGE_EXISTED %(Guid, Version))\r
421ccda3
HC
193 if Options.UseGuidedPkgPath:\r
194 GuidedPkgPath = "%s_%s_%s" % (Package.GetName(), Guid, Version)\r
195 NewPackagePath = InstallNewPackage(WorkspaceDir, GuidedPkgPath, Options.CustomPath)\r
196 else:\r
197 NewPackagePath = InstallNewPackage(WorkspaceDir, PackagePath, Options.CustomPath)\r
f7496d71 198 InstallPackageContent(PackagePath, NewPackagePath, Package, ContentZipFile, Dep, WorkspaceDir, ModuleList,\r
4234283c
LG
199 DistPkg.Header.ReadOnly)\r
200 PackageList.append(Package)\r
f7496d71 201\r
4234283c 202 NewDict[Guid, Version, Package.GetPackagePath()] = Package\r
f7496d71 203\r
4234283c
LG
204 #\r
205 # Now generate meta-data files, first generate all dec for package\r
206 # dec should be generated before inf, and inf should be generated after\r
207 # all packages installed, else hard to resolve modules' package\r
208 # dependency (Hard to get the location of the newly installed package)\r
209 #\r
210 for Package in PackageList:\r
421ccda3 211 FilePath = PackageToDec(Package, DistPkg.Header)\r
fb0b35e0
AC
212 Md5Signature = md5(__FileHookOpen__(str(FilePath), 'rb').read())\r
213 Md5Sum = Md5Signature.hexdigest()\r
4234283c
LG
214 if (FilePath, Md5Sum) not in Package.FileList:\r
215 Package.FileList.append((FilePath, Md5Sum))\r
f7496d71 216\r
4234283c
LG
217 return NewDict\r
218\r
219## GetModuleList\r
220#\r
221# GetModuleList\r
222#\r
223def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):\r
224 #\r
225 # ModulePathList will keep track of the standalone module path that\r
f7496d71
LG
226 # we just installed. If a new module's path in that list\r
227 # (only multiple INF in one directory will be so), we will\r
228 # install them directly. If not, we will try to create a new directory\r
4234283c
LG
229 # for it.\r
230 #\r
421ccda3 231 ModulePathList = []\r
f7496d71 232\r
4234283c
LG
233 #\r
234 # Check module exist and install\r
235 #\r
236 Module = None\r
f7496d71 237 NewDict = Sdict()\r
d0acc87a 238 for Guid, Version, Name, Path in DistPkg.ModuleSurfaceArea:\r
4234283c 239 ModulePath = Path\r
d0acc87a 240 Module = DistPkg.ModuleSurfaceArea[Guid, Version, Name, Path]\r
4234283c 241 Logger.Info(ST.MSG_INSTALL_MODULE % Module.GetName())\r
d0acc87a 242 if Dep.CheckModuleExists(Guid, Version, Name, Path):\r
4234283c
LG
243 Logger.Quiet(ST.WRN_MODULE_EXISTED %Path)\r
244 #\r
245 # here check for the multiple inf share the same module path cases:\r
246 # they should be installed into the same directory\r
247 #\r
248 ModuleFullPath = \\r
249 os.path.normpath(os.path.join(WorkspaceDir, ModulePath))\r
250 if ModuleFullPath not in ModulePathList:\r
251 NewModulePath = InstallNewModule(WorkspaceDir, ModulePath, ModulePathList)\r
252 NewModuleFullPath = os.path.normpath(os.path.join(WorkspaceDir, NewModulePath))\r
253 ModulePathList.append(NewModuleFullPath)\r
254 else:\r
255 NewModulePath = ModulePath\r
f7496d71
LG
256\r
257 InstallModuleContent(ModulePath, NewModulePath, '', Module, ContentZipFile, WorkspaceDir, ModuleList, None,\r
4234283c
LG
258 DistPkg.Header.ReadOnly)\r
259 #\r
260 # Update module\r
261 #\r
262 Module.SetModulePath(Module.GetModulePath().replace(Path, NewModulePath, 1))\r
f7496d71 263\r
d0acc87a 264 NewDict[Guid, Version, Name, Module.GetModulePath()] = Module\r
4234283c
LG
265\r
266 #\r
267 # generate all inf for modules\r
268 #\r
269 for (Module, Package) in ModuleList:\r
421ccda3
HC
270 CheckCNameInModuleRedefined(Module, DistPkg)\r
271 FilePath = ModuleToInf(Module, Package, DistPkg.Header)\r
fb0b35e0
AC
272 Md5Signature = md5(__FileHookOpen__(str(FilePath), 'rb').read())\r
273 Md5Sum = Md5Signature.hexdigest()\r
4234283c
LG
274 if Package:\r
275 if (FilePath, Md5Sum) not in Package.FileList:\r
276 Package.FileList.append((FilePath, Md5Sum))\r
277 else:\r
278 if (FilePath, Md5Sum) not in Module.FileList:\r
279 Module.FileList.append((FilePath, Md5Sum))\r
421ccda3
HC
280 #\r
281 # append the module unicode files to Package FileList\r
282 #\r
283 for (FilePath, Md5Sum) in Module.FileList:\r
284 if str(FilePath).endswith('.uni') and Package and (FilePath, Md5Sum) not in Package.FileList:\r
285 Package.FileList.append((FilePath, Md5Sum))\r
f7496d71 286\r
4234283c
LG
287 return NewDict\r
288\r
421ccda3
HC
289##\r
290# Get all protocol/ppi/guid CNames and pcd name from all dependent DEC file\r
291#\r
292def GetDepProtocolPpiGuidPcdNames(DePackageObjList):\r
293 #\r
294 # [[Dec1Protocol1, Dec1Protocol2...], [Dec2Protocols...],...]\r
295 #\r
296 DependentProtocolCNames = []\r
297 DependentPpiCNames = []\r
298 DependentGuidCNames = []\r
299 DependentPcdNames = []\r
f7496d71 300\r
421ccda3
HC
301 for PackageObj in DePackageObjList:\r
302 #\r
303 # Get protocol CName list from all dependent DEC file\r
304 #\r
305 ProtocolCNames = []\r
306 for Protocol in PackageObj.GetProtocolList():\r
307 if Protocol.GetCName() not in ProtocolCNames:\r
308 ProtocolCNames.append(Protocol.GetCName())\r
f7496d71 309\r
421ccda3 310 DependentProtocolCNames.append(ProtocolCNames)\r
f7496d71 311\r
421ccda3
HC
312 #\r
313 # Get Ppi CName list from all dependent DEC file\r
f7496d71 314 #\r
421ccda3
HC
315 PpiCNames = []\r
316 for Ppi in PackageObj.GetPpiList():\r
317 if Ppi.GetCName() not in PpiCNames:\r
318 PpiCNames.append(Ppi.GetCName())\r
319\r
320 DependentPpiCNames.append(PpiCNames)\r
f7496d71 321\r
421ccda3
HC
322 #\r
323 # Get Guid CName list from all dependent DEC file\r
f7496d71 324 #\r
421ccda3
HC
325 GuidCNames = []\r
326 for Guid in PackageObj.GetGuidList():\r
327 if Guid.GetCName() not in GuidCNames:\r
328 GuidCNames.append(Guid.GetCName())\r
f7496d71 329\r
421ccda3 330 DependentGuidCNames.append(GuidCNames)\r
f7496d71 331\r
421ccda3
HC
332 #\r
333 # Get PcdName list from all dependent DEC file\r
334 #\r
335 PcdNames = []\r
336 for Pcd in PackageObj.GetPcdList():\r
337 PcdName = '.'.join([Pcd.GetTokenSpaceGuidCName(), Pcd.GetCName()])\r
338 if PcdName not in PcdNames:\r
339 PcdNames.append(PcdName)\r
f7496d71 340\r
421ccda3 341 DependentPcdNames.append(PcdNames)\r
f7496d71
LG
342\r
343\r
421ccda3
HC
344 return DependentProtocolCNames, DependentPpiCNames, DependentGuidCNames, DependentPcdNames\r
345\r
346##\r
347# Check if protocol CName is redefined\r
348#\r
349def CheckProtoclCNameRedefined(Module, DependentProtocolCNames):\r
350 for ProtocolInModule in Module.GetProtocolList():\r
351 IsCNameDefined = False\r
352 for PackageProtocolCNames in DependentProtocolCNames:\r
353 if ProtocolInModule.GetCName() in PackageProtocolCNames:\r
354 if IsCNameDefined:\r
f7496d71
LG
355 Logger.Error("\nUPT", FORMAT_INVALID,\r
356 File = Module.GetFullPath(),\r
421ccda3
HC
357 ExtraData = \\r
358 ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % ProtocolInModule.GetCName())\r
359 else:\r
360 IsCNameDefined = True\r
361\r
362##\r
363# Check if Ppi CName is redefined\r
364#\r
365def CheckPpiCNameRedefined(Module, DependentPpiCNames):\r
366 for PpiInModule in Module.GetPpiList():\r
367 IsCNameDefined = False\r
368 for PackagePpiCNames in DependentPpiCNames:\r
369 if PpiInModule.GetCName() in PackagePpiCNames:\r
370 if IsCNameDefined:\r
f7496d71
LG
371 Logger.Error("\nUPT", FORMAT_INVALID,\r
372 File = Module.GetFullPath(),\r
421ccda3
HC
373 ExtraData = ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % PpiInModule.GetCName())\r
374 else:\r
f7496d71 375 IsCNameDefined = True\r
421ccda3
HC
376\r
377##\r
378# Check if Guid CName is redefined\r
379#\r
380def CheckGuidCNameRedefined(Module, DependentGuidCNames):\r
381 for GuidInModule in Module.GetGuidList():\r
382 IsCNameDefined = False\r
383 for PackageGuidCNames in DependentGuidCNames:\r
384 if GuidInModule.GetCName() in PackageGuidCNames:\r
385 if IsCNameDefined:\r
f7496d71
LG
386 Logger.Error("\nUPT", FORMAT_INVALID,\r
387 File = Module.GetFullPath(),\r
421ccda3
HC
388 ExtraData = \\r
389 ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % GuidInModule.GetCName())\r
390 else:\r
391 IsCNameDefined = True\r
392\r
393##\r
394# Check if PcdName is redefined\r
395#\r
396def CheckPcdNameRedefined(Module, DependentPcdNames):\r
397 PcdObjs = []\r
398 if not Module.GetBinaryFileList():\r
399 PcdObjs += Module.GetPcdList()\r
400 else:\r
401 Binary = Module.GetBinaryFileList()[0]\r
402 for AsBuild in Binary.GetAsBuiltList():\r
403 PcdObjs += AsBuild.GetPatchPcdList() + AsBuild.GetPcdExList()\r
404\r
405 for PcdObj in PcdObjs:\r
406 PcdName = '.'.join([PcdObj.GetTokenSpaceGuidCName(), PcdObj.GetCName()])\r
407 IsPcdNameDefined = False\r
408 for PcdNames in DependentPcdNames:\r
409 if PcdName in PcdNames:\r
410 if IsPcdNameDefined:\r
f7496d71
LG
411 Logger.Error("\nUPT", FORMAT_INVALID,\r
412 File = Module.GetFullPath(),\r
421ccda3
HC
413 ExtraData = ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % PcdName)\r
414 else:\r
415 IsPcdNameDefined = True\r
416\r
417##\r
418# Check if any Protocol/Ppi/Guid and Pcd name is redefined in its dependent DEC files\r
419#\r
420def CheckCNameInModuleRedefined(Module, DistPkg):\r
421 DePackageObjList = []\r
422 #\r
423 # Get all dependent package objects\r
f7496d71 424 #\r
421ccda3
HC
425 for Obj in Module.GetPackageDependencyList():\r
426 Guid = Obj.GetGuid()\r
427 Version = Obj.GetVersion()\r
428 for Key in DistPkg.PackageSurfaceArea:\r
429 if Key[0] == Guid and Key[1] == Version:\r
430 if DistPkg.PackageSurfaceArea[Key] not in DePackageObjList:\r
431 DePackageObjList.append(DistPkg.PackageSurfaceArea[Key])\r
f7496d71 432\r
421ccda3
HC
433 DependentProtocolCNames, DependentPpiCNames, DependentGuidCNames, DependentPcdNames = \\r
434 GetDepProtocolPpiGuidPcdNames(DePackageObjList)\r
435\r
436 CheckProtoclCNameRedefined(Module, DependentProtocolCNames)\r
437 CheckPpiCNameRedefined(Module, DependentPpiCNames)\r
438 CheckGuidCNameRedefined(Module, DependentGuidCNames)\r
439 CheckPcdNameRedefined(Module, DependentPcdNames)\r
440\r
4234283c
LG
441## GenToolMisc\r
442#\r
443# GenToolMisc\r
444#\r
445#\r
446def GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile):\r
447 ToolObject = DistPkg.Tools\r
448 MiscObject = DistPkg.MiscellaneousFiles\r
449 DistPkg.FileList = []\r
450 FileList = []\r
451 ToolFileNum = 0\r
452 FileNum = 0\r
453 RootDir = WorkspaceDir\r
f7496d71 454\r
4234283c
LG
455 #\r
456 # FileList stores both tools files and misc files\r
457 # Misc file list must be appended to FileList *AFTER* Tools file list\r
458 #\r
459 if ToolObject:\r
460 FileList += ToolObject.GetFileList()\r
461 ToolFileNum = len(ToolObject.GetFileList())\r
462 if 'EDK_TOOLS_PATH' in os.environ:\r
463 RootDir = os.environ['EDK_TOOLS_PATH']\r
464 if MiscObject:\r
465 FileList += MiscObject.GetFileList()\r
466 for FileObject in FileList:\r
467 FileNum += 1\r
468 if FileNum > ToolFileNum:\r
469 #\r
470 # Misc files, root should be changed to WORKSPACE\r
471 #\r
472 RootDir = WorkspaceDir\r
473 File = ConvertPath(FileObject.GetURI())\r
474 ToFile = os.path.normpath(os.path.join(RootDir, File))\r
475 if os.path.exists(ToFile):\r
476 Logger.Info( ST.WRN_FILE_EXISTED % ToFile )\r
477 #\r
478 # ask for user input the new file name\r
479 #\r
480 Logger.Info( ST.MSG_NEW_FILE_NAME)\r
481 Input = stdin.readline()\r
482 Input = Input.replace('\r', '').replace('\n', '')\r
483 OrigPath = os.path.split(ToFile)[0]\r
484 ToFile = os.path.normpath(os.path.join(OrigPath, Input))\r
485 FromFile = os.path.join(FileObject.GetURI())\r
486 Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, DistPkg.Header.ReadOnly, FileObject.GetExecutable())\r
487 DistPkg.FileList.append((ToFile, Md5Sum))\r
488\r
489## Tool entrance method\r
490#\r
491# This method mainly dispatch specific methods per the command line options.\r
492# If no error found, return zero value so the caller of this tool can know\r
493# if it's executed successfully or not.\r
494#\r
495# @param Options: command Options\r
496#\r
497def Main(Options = None):\r
4234283c 498 try:\r
421ccda3 499 DataBase = GlobalData.gDB\r
4234283c
LG
500 WorkspaceDir = GlobalData.gWORKSPACE\r
501 if not Options.PackageFile:\r
502 Logger.Error("InstallPkg", OPTION_MISSING, ExtraData=ST.ERR_SPECIFY_PACKAGE)\r
f7496d71 503\r
56636814
HC
504 # Get all Dist Info\r
505 DistInfoList = []\r
506 DistPkgList = []\r
507 Index = 1\r
508 for ToBeInstalledDist in Options.PackageFile:\r
509 #\r
510 # unzip dist.pkg file\r
511 #\r
512 DistInfoList.append(UnZipDp(WorkspaceDir, ToBeInstalledDist, Index))\r
513 DistPkgList.append(DistInfoList[-1][0])\r
514 Index += 1\r
4234283c 515\r
56636814
HC
516 #\r
517 # Add dist\r
518 #\r
519 GlobalData.gTO_BE_INSTALLED_DIST_LIST.append(DistInfoList[-1][0])\r
4234283c 520\r
56636814
HC
521 # Check for dependency\r
522 Dep = DependencyRules(DataBase, DistPkgList)\r
523\r
524 for ToBeInstalledDist in DistInfoList:\r
525 CheckInstallDpx(Dep, ToBeInstalledDist[0], ToBeInstalledDist[2])\r
526\r
527 #\r
528 # Install distribution\r
529 #\r
530 InstallDp(ToBeInstalledDist[0], ToBeInstalledDist[2], ToBeInstalledDist[1],\r
531 Options, Dep, WorkspaceDir, DataBase)\r
4234283c 532 ReturnCode = 0\r
f7496d71 533\r
5b0671c1 534 except FatalError as XExcept:\r
4234283c
LG
535 ReturnCode = XExcept.args[0]\r
536 if Logger.GetLevel() <= Logger.DEBUG_9:\r
421ccda3 537 Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())\r
f7496d71 538\r
4234283c
LG
539 except KeyboardInterrupt:\r
540 ReturnCode = ABORT_ERROR\r
541 if Logger.GetLevel() <= Logger.DEBUG_9:\r
421ccda3 542 Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())\r
f7496d71 543\r
4234283c
LG
544 except:\r
545 ReturnCode = CODE_ERROR\r
546 Logger.Error(\r
547 "\nInstallPkg",\r
548 CODE_ERROR,\r
549 ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.PackageFile,\r
c1387446 550 ExtraData=ST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL_ADDR,\r
4234283c
LG
551 RaiseError=False\r
552 )\r
553 Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(),\r
554 platform) + format_exc())\r
4234283c 555 finally:\r
56636814
HC
556 Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_STARTED)\r
557 for ToBeInstalledDist in DistInfoList:\r
558 if ToBeInstalledDist[3]:\r
559 ToBeInstalledDist[3].Close()\r
560 if ToBeInstalledDist[1]:\r
561 ToBeInstalledDist[1].Close()\r
562 for TempDir in GlobalData.gUNPACK_DIR:\r
563 rmtree(TempDir)\r
564 GlobalData.gUNPACK_DIR = []\r
565 Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE)\r
4234283c
LG
566 if ReturnCode == 0:\r
567 Logger.Quiet(ST.MSG_FINISH)\r
4234283c
LG
568 return ReturnCode\r
569\r
421ccda3 570# BackupDist method\r
f7496d71
LG
571#\r
572# This method will backup the Distribution file into the $(WORKSPACE)/conf/upt, and rename it\r
421ccda3
HC
573# if there is already a same-named distribution existed.\r
574#\r
575# @param DpPkgFileName: The distribution path\r
576# @param Guid: The distribution Guid\r
577# @param Version: The distribution Version\r
578# @param WorkspaceDir: The workspace directory\r
579# @retval NewDpPkgFileName: The exact backup file name\r
580#\r
581def BackupDist(DpPkgFileName, Guid, Version, WorkspaceDir):\r
582 DistFileName = os.path.split(DpPkgFileName)[1]\r
583 DestDir = os.path.normpath(os.path.join(WorkspaceDir, GlobalData.gUPT_DIR))\r
584 CreateDirectory(DestDir)\r
585 DestFile = os.path.normpath(os.path.join(DestDir, DistFileName))\r
586 if os.path.exists(DestFile):\r
587 FileName, Ext = os.path.splitext(DistFileName)\r
588 NewFileName = FileName + '_' + Guid + '_' + Version + Ext\r
589 DestFile = os.path.normpath(os.path.join(DestDir, NewFileName))\r
590 if os.path.exists(DestFile):\r
591 #\r
592 # ask for user input the new file name\r
593 #\r
594 Logger.Info( ST.MSG_NEW_FILE_NAME_FOR_DIST)\r
595 Input = stdin.readline()\r
596 Input = Input.replace('\r', '').replace('\n', '')\r
597 DestFile = os.path.normpath(os.path.join(DestDir, Input))\r
598 copyfile(DpPkgFileName, DestFile)\r
599 NewDpPkgFileName = DestFile[DestFile.find(DestDir) + len(DestDir) + 1:]\r
600 return NewDpPkgFileName\r
601\r
602## CheckInstallDpx method\r
603#\r
604# check whether distribution could be installed\r
605#\r
606# @param Dep: the DependencyRules instance that used to check dependency\r
607# @param DistPkg: the distribution object\r
608#\r
56636814 609def CheckInstallDpx(Dep, DistPkg, DistPkgFileName):\r
421ccda3
HC
610 #\r
611 # Check distribution package installed or not\r
612 #\r
613 if Dep.CheckDpExists(DistPkg.Header.GetGuid(),\r
614 DistPkg.Header.GetVersion()):\r
56636814
HC
615 Logger.Error("InstallPkg",\r
616 UPT_ALREADY_INSTALLED_ERROR,\r
617 ST.WRN_DIST_PKG_INSTALLED % os.path.basename(DistPkgFileName))\r
421ccda3
HC
618 #\r
619 # Check distribution dependency (all module dependency should be\r
620 # satisfied)\r
621 #\r
622 if not Dep.CheckInstallDpDepexSatisfied(DistPkg):\r
623 Logger.Error("InstallPkg", UNKNOWN_ERROR,\r
624 ST.ERR_PACKAGE_NOT_MATCH_DEPENDENCY,\r
625 ExtraData=DistPkg.Header.Name)\r
626\r
4234283c
LG
627## InstallModuleContent method\r
628#\r
629# If this is standalone module, then Package should be none,\r
630# ModulePath should be ''\r
631# @param FromPath: FromPath\r
632# @param NewPath: NewPath\r
633# @param ModulePath: ModulePath\r
634# @param Module: Module\r
635# @param ContentZipFile: ContentZipFile\r
636# @param WorkspaceDir: WorkspaceDir\r
637# @param ModuleList: ModuleList\r
638# @param Package: Package\r
639#\r
640def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,\r
641 WorkspaceDir, ModuleList, Package = None, ReadOnly = False):\r
f7496d71 642\r
4234283c
LG
643 if NewPath.startswith("\\") or NewPath.startswith("/"):\r
644 NewPath = NewPath[1:]\r
f7496d71 645\r
4234283c 646 if not IsValidInstallPath(NewPath):\r
f7496d71
LG
647 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%NewPath)\r
648\r
4234283c
LG
649 NewModuleFullPath = os.path.normpath(os.path.join(WorkspaceDir, NewPath,\r
650 ConvertPath(ModulePath)))\r
651 Module.SetFullPath(os.path.normpath(os.path.join(NewModuleFullPath,\r
652 ConvertPath(Module.GetName()) + '.inf')))\r
653 Module.FileList = []\r
f7496d71 654\r
4234283c
LG
655 for MiscFile in Module.GetMiscFileList():\r
656 if not MiscFile:\r
657 continue\r
658 for Item in MiscFile.GetFileList():\r
659 File = Item.GetURI()\r
660 if File.startswith("\\") or File.startswith("/"):\r
661 File = File[1:]\r
f7496d71 662\r
4234283c
LG
663 if not IsValidInstallPath(File):\r
664 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)\r
421ccda3 665\r
4234283c 666 FromFile = os.path.join(FromPath, ModulePath, File)\r
f7496d71 667 Executable = Item.GetExecutable()\r
4234283c
LG
668 ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))\r
669 Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable)\r
670 if Package and ((ToFile, Md5Sum) not in Package.FileList):\r
671 Package.FileList.append((ToFile, Md5Sum))\r
672 elif Package:\r
673 continue\r
674 elif (ToFile, Md5Sum) not in Module.FileList:\r
675 Module.FileList.append((ToFile, Md5Sum))\r
676 for Item in Module.GetSourceFileList():\r
677 File = Item.GetSourceFile()\r
678 if File.startswith("\\") or File.startswith("/"):\r
679 File = File[1:]\r
f7496d71 680\r
4234283c 681 if not IsValidInstallPath(File):\r
f7496d71
LG
682 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)\r
683\r
4234283c
LG
684 FromFile = os.path.join(FromPath, ModulePath, File)\r
685 ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))\r
686 Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)\r
687 if Package and ((ToFile, Md5Sum) not in Package.FileList):\r
688 Package.FileList.append((ToFile, Md5Sum))\r
689 elif Package:\r
690 continue\r
691 elif (ToFile, Md5Sum) not in Module.FileList:\r
692 Module.FileList.append((ToFile, Md5Sum))\r
693 for Item in Module.GetBinaryFileList():\r
694 FileNameList = Item.GetFileNameList()\r
f7496d71
LG
695 for FileName in FileNameList:\r
696 File = FileName.GetFilename()\r
4234283c
LG
697 if File.startswith("\\") or File.startswith("/"):\r
698 File = File[1:]\r
f7496d71 699\r
4234283c
LG
700 if not IsValidInstallPath(File):\r
701 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)\r
702\r
703 FromFile = os.path.join(FromPath, ModulePath, File)\r
704 ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))\r
f7496d71 705 Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)\r
4234283c
LG
706 if Package and ((ToFile, Md5Sum) not in Package.FileList):\r
707 Package.FileList.append((ToFile, Md5Sum))\r
708 elif Package:\r
709 continue\r
710 elif (ToFile, Md5Sum) not in Module.FileList:\r
711 Module.FileList.append((ToFile, Md5Sum))\r
f7496d71 712\r
4234283c
LG
713 InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceDir, NewPath, Module, Package, ReadOnly,\r
714 ModuleList)\r
715\r
716## InstallModuleContentZipFile\r
717#\r
718# InstallModuleContentZipFile\r
719#\r
720def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceDir, NewPath, Module, Package, ReadOnly,\r
721 ModuleList):\r
722 #\r
f7496d71 723 # Extract other files under current module path in content Zip file but not listed in the description\r
4234283c
LG
724 #\r
725 if ContentZipFile:\r
726 for FileName in ContentZipFile.GetZipFile().namelist():\r
727 FileName = os.path.normpath(FileName)\r
728 CheckPath = os.path.normpath(os.path.join(FromPath, ModulePath))\r
729 if FileUnderPath(FileName, CheckPath):\r
730 if FileName.startswith("\\") or FileName.startswith("/"):\r
731 FileName = FileName[1:]\r
f7496d71 732\r
4234283c
LG
733 if not IsValidInstallPath(FileName):\r
734 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)\r
f7496d71 735\r
4234283c 736 FromFile = FileName\r
f7496d71 737 ToFile = os.path.normpath(os.path.join(WorkspaceDir,\r
4234283c 738 ConvertPath(FileName.replace(FromPath, NewPath, 1))))\r
421ccda3 739 CheckList = copy.copy(Module.FileList)\r
4234283c
LG
740 if Package:\r
741 CheckList += Package.FileList\r
742 for Item in CheckList:\r
743 if Item[0] == ToFile:\r
744 break\r
745 else:\r
746 Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)\r
747 if Package and ((ToFile, Md5Sum) not in Package.FileList):\r
748 Package.FileList.append((ToFile, Md5Sum))\r
749 elif Package:\r
750 continue\r
751 elif (ToFile, Md5Sum) not in Module.FileList:\r
f7496d71
LG
752 Module.FileList.append((ToFile, Md5Sum))\r
753\r
4234283c
LG
754 ModuleList.append((Module, Package))\r
755\r
756## FileUnderPath\r
f7496d71 757# Check whether FileName started with directory specified by CheckPath\r
4234283c
LG
758#\r
759# @param FileName: the FileName need to be checked\r
760# @param CheckPath: the path need to be checked against\r
f7496d71 761# @return: True or False\r
4234283c
LG
762#\r
763def FileUnderPath(FileName, CheckPath):\r
764 FileName = FileName.replace('\\', '/')\r
765 FileName = os.path.normpath(FileName)\r
766 CheckPath = CheckPath.replace('\\', '/')\r
767 CheckPath = os.path.normpath(CheckPath)\r
768 if FileName.startswith(CheckPath):\r
769 RemainingPath = os.path.normpath(FileName.replace(CheckPath, '', 1))\r
770 while RemainingPath.startswith('\\') or RemainingPath.startswith('/'):\r
771 RemainingPath = RemainingPath[1:]\r
772 if FileName == os.path.normpath(os.path.join(CheckPath, RemainingPath)):\r
773 return True\r
f7496d71 774\r
4234283c
LG
775 return False\r
776\r
777## InstallFile\r
778# Extract File from Zipfile, set file attribute, and return the Md5Sum\r
779#\r
f7496d71 780# @return: True or False\r
4234283c
LG
781#\r
782def InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable=False):\r
421ccda3
HC
783 if os.path.exists(os.path.normpath(ToFile)):\r
784 pass\r
785 else:\r
786 if not ContentZipFile or not ContentZipFile.UnpackFile(FromFile, ToFile):\r
787 Logger.Error("UPT", FILE_NOT_FOUND, ST.ERR_INSTALL_FILE_FROM_EMPTY_CONTENT % FromFile)\r
4234283c 788\r
421ccda3
HC
789 if ReadOnly:\r
790 if not Executable:\r
791 chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH)\r
792 else:\r
793 chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)\r
794 elif Executable:\r
795 chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IWUSR | stat.S_IWGRP |\r
796 stat.S_IWOTH | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)\r
4234283c 797 else:\r
421ccda3 798 chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)\r
f7496d71 799\r
fb0b35e0
AC
800 Md5Signature = md5(__FileHookOpen__(str(ToFile), 'rb').read())\r
801 Md5Sum = Md5Signature.hexdigest()\r
421ccda3 802\r
4234283c 803 return Md5Sum\r
421ccda3 804\r
4234283c
LG
805## InstallPackageContent method\r
806#\r
807# @param FromPath: FromPath\r
808# @param ToPath: ToPath\r
809# @param Package: Package\r
810# @param ContentZipFile: ContentZipFile\r
811# @param Dep: Dep\r
812# @param WorkspaceDir: WorkspaceDir\r
813# @param ModuleList: ModuleList\r
814#\r
815def InstallPackageContent(FromPath, ToPath, Package, ContentZipFile, Dep,\r
816 WorkspaceDir, ModuleList, ReadOnly = False):\r
817 if Dep:\r
818 pass\r
819 Package.FileList = []\r
f7496d71 820\r
4234283c
LG
821 if ToPath.startswith("\\") or ToPath.startswith("/"):\r
822 ToPath = ToPath[1:]\r
f7496d71 823\r
4234283c 824 if not IsValidInstallPath(ToPath):\r
f7496d71 825 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%ToPath)\r
4234283c
LG
826\r
827 if FromPath.startswith("\\") or FromPath.startswith("/"):\r
828 FromPath = FromPath[1:]\r
f7496d71 829\r
4234283c 830 if not IsValidInstallPath(FromPath):\r
f7496d71
LG
831 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FromPath)\r
832\r
4234283c
LG
833 PackageFullPath = os.path.normpath(os.path.join(WorkspaceDir, ToPath))\r
834 for MiscFile in Package.GetMiscFileList():\r
835 for Item in MiscFile.GetFileList():\r
836 FileName = Item.GetURI()\r
837 if FileName.startswith("\\") or FileName.startswith("/"):\r
838 FileName = FileName[1:]\r
f7496d71 839\r
4234283c
LG
840 if not IsValidInstallPath(FileName):\r
841 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)\r
f7496d71 842\r
4234283c
LG
843 FromFile = os.path.join(FromPath, FileName)\r
844 Executable = Item.GetExecutable()\r
845 ToFile = (os.path.join(PackageFullPath, ConvertPath(FileName)))\r
846 Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable)\r
847 if (ToFile, Md5Sum) not in Package.FileList:\r
848 Package.FileList.append((ToFile, Md5Sum))\r
f7496d71 849 PackageIncludeArchList = []\r
4234283c
LG
850 for Item in Package.GetPackageIncludeFileList():\r
851 FileName = Item.GetFilePath()\r
852 if FileName.startswith("\\") or FileName.startswith("/"):\r
853 FileName = FileName[1:]\r
f7496d71 854\r
4234283c 855 if not IsValidInstallPath(FileName):\r
f7496d71
LG
856 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)\r
857\r
4234283c
LG
858 FromFile = os.path.join(FromPath, FileName)\r
859 ToFile = os.path.normpath(os.path.join(PackageFullPath, ConvertPath(FileName)))\r
860 RetFile = ContentZipFile.UnpackFile(FromFile, ToFile)\r
861 if RetFile == '':\r
862 #\r
863 # a non-exist path in Zipfile will return '', which means an include directory in our case\r
864 # save the information for later DEC creation usage and also create the directory\r
865 #\r
866 PackageIncludeArchList.append([Item.GetFilePath(), Item.GetSupArchList()])\r
867 CreateDirectory(ToFile)\r
868 continue\r
869 if ReadOnly:\r
421ccda3 870 chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)\r
4234283c 871 else:\r
f7496d71 872 chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH)\r
fb0b35e0
AC
873 Md5Signature = md5(__FileHookOpen__(str(ToFile), 'rb').read())\r
874 Md5Sum = Md5Signature.hexdigest()\r
4234283c
LG
875 if (ToFile, Md5Sum) not in Package.FileList:\r
876 Package.FileList.append((ToFile, Md5Sum))\r
877 Package.SetIncludeArchList(PackageIncludeArchList)\r
f7496d71 878\r
4234283c
LG
879 for Item in Package.GetStandardIncludeFileList():\r
880 FileName = Item.GetFilePath()\r
881 if FileName.startswith("\\") or FileName.startswith("/"):\r
882 FileName = FileName[1:]\r
f7496d71 883\r
4234283c 884 if not IsValidInstallPath(FileName):\r
f7496d71
LG
885 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)\r
886\r
4234283c
LG
887 FromFile = os.path.join(FromPath, FileName)\r
888 ToFile = os.path.normpath(os.path.join(PackageFullPath, ConvertPath(FileName)))\r
889 Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)\r
890 if (ToFile, Md5Sum) not in Package.FileList:\r
891 Package.FileList.append((ToFile, Md5Sum))\r
892\r
893 #\r
894 # Update package\r
895 #\r
896 Package.SetPackagePath(Package.GetPackagePath().replace(FromPath,\r
897 ToPath, 1))\r
898 Package.SetFullPath(os.path.normpath(os.path.join(PackageFullPath,\r
899 ConvertPath(Package.GetName()) + '.dec')))\r
900\r
901 #\r
902 # Install files in module\r
903 #\r
904 Module = None\r
905 ModuleDict = Package.GetModuleDict()\r
d0acc87a
LG
906 for ModuleGuid, ModuleVersion, ModuleName, ModulePath in ModuleDict:\r
907 Module = ModuleDict[ModuleGuid, ModuleVersion, ModuleName, ModulePath]\r
4234283c
LG
908 InstallModuleContent(FromPath, ToPath, ModulePath, Module,\r
909 ContentZipFile, WorkspaceDir, ModuleList, Package, ReadOnly)\r
910\r
911## GetDPFile method\r
912#\r
913# @param ZipFile: A ZipFile\r
914#\r
915def GetDPFile(ZipFile):\r
916 ContentFile = ''\r
917 DescFile = ''\r
918 for FileName in ZipFile.namelist():\r
919 if FileName.endswith('.content'):\r
920 if not ContentFile:\r
921 ContentFile = FileName\r
922 continue\r
923 elif FileName.endswith('.pkg'):\r
924 if not DescFile:\r
925 DescFile = FileName\r
926 continue\r
927 else:\r
928 continue\r
f7496d71 929\r
4234283c
LG
930 Logger.Error("PackagingTool", FILE_TYPE_MISMATCH,\r
931 ExtraData=ST.ERR_DIST_FILE_TOOMANY)\r
932 if not DescFile or not ContentFile:\r
933 Logger.Error("PackagingTool", FILE_UNKNOWN_ERROR,\r
934 ExtraData=ST.ERR_DIST_FILE_TOOFEW)\r
935 return DescFile, ContentFile\r
936\r
421ccda3
HC
937## InstallDp method\r
938#\r
939# Install the distribution to current workspace\r
940#\r
941def InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir, DataBase):\r
942 #\r
943 # PackageList, ModuleList record the information for the meta-data\r
944 # files that need to be generated later\r
945 #\r
946 PackageList = []\r
947 ModuleList = []\r
f7496d71 948 DistPkg.PackageSurfaceArea = GetPackageList(DistPkg, Dep, WorkspaceDir, Options,\r
421ccda3
HC
949 ContentZipFile, ModuleList, PackageList)\r
950\r
951 DistPkg.ModuleSurfaceArea = GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList)\r
f7496d71 952\r
421ccda3 953 GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile)\r
f7496d71 954\r
421ccda3
HC
955 #\r
956 # copy "Distribution File" to directory $(WORKSPACE)/conf/upt\r
957 #\r
958 DistFileName = os.path.split(DpPkgFileName)[1]\r
959 NewDpPkgFileName = BackupDist(DpPkgFileName, DistPkg.Header.GetGuid(), DistPkg.Header.GetVersion(), WorkspaceDir)\r
960\r
961 #\r
962 # update database\r
963 #\r
964 Logger.Quiet(ST.MSG_UPDATE_PACKAGE_DATABASE)\r
f7496d71 965 DataBase.AddDPObject(DistPkg, NewDpPkgFileName, DistFileName,\r
421ccda3
HC
966 DistPkg.Header.RePackage)\r
967\r