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