X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=BaseTools%2FSource%2FPython%2FUPT%2FInstallPkg.py;h=e4c7565441ba1726066fc6c23ca13a01987d945a;hp=3084b60bff3f0fb566adbcafc2a68c8d18816d03;hb=c1387446edbb05a11e2646e4184585d58d47a7d6;hpb=421ccda3079077dd613308526e02d797f5cc356a
diff --git a/BaseTools/Source/Python/UPT/InstallPkg.py b/BaseTools/Source/Python/UPT/InstallPkg.py
index 3084b60bff..e4c7565441 100644
--- a/BaseTools/Source/Python/UPT/InstallPkg.py
+++ b/BaseTools/Source/Python/UPT/InstallPkg.py
@@ -1,15 +1,9 @@
## @file
# Install distribution package.
#
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.
#
-# This program and the accompanying materials are licensed and made available
-# under the terms and conditions of the BSD License which accompanies this
-# distribution. The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
#
"""
Install a distribution package
@@ -23,7 +17,7 @@ from os import chmod
from os import SEEK_SET
from os import SEEK_END
import stat
-import md5
+from hashlib import md5
import copy
from sys import stdin
from sys import platform
@@ -91,7 +85,7 @@ def InstallNewPackage(WorkspaceDir, Path, CustomPath = False):
# @param PathList: The already installed standalone module Path list
#
def InstallNewModule(WorkspaceDir, Path, PathList = None):
- if PathList == None:
+ if PathList is None:
PathList = []
Path = ConvertPath(Path)
Path = os.path.normpath(Path)
@@ -102,7 +96,7 @@ def InstallNewModule(WorkspaceDir, Path, PathList = None):
Logger.Info(ST.MSG_RELATIVE_PATH_ONLY%FullPath)
else:
return Path
-
+
Input = stdin.readline()
Input = Input.replace('\r', '').replace('\n', '')
if Input == '':
@@ -110,7 +104,7 @@ def InstallNewModule(WorkspaceDir, Path, PathList = None):
Input = Input.replace('\r', '').replace('\n', '')
return InstallNewModule(WorkspaceDir, Input, PathList)
-
+
## InstallNewFile
#
# @param WorkspaceDir: Workspace Direction
@@ -133,19 +127,19 @@ def InstallNewFile(WorkspaceDir, File):
#
# UnZipDp
#
-def UnZipDp(WorkspaceDir, DpPkgFileName):
+def UnZipDp(WorkspaceDir, DpPkgFileName, Index=1):
ContentZipFile = None
Logger.Quiet(ST.MSG_UZIP_PARSE_XML)
DistFile = PackageFile(DpPkgFileName)
-
+
DpDescFileName, ContentFileName = GetDPFile(DistFile.GetZipFile())
-
- GlobalData.gUNPACK_DIR = os.path.normpath(os.path.join(WorkspaceDir, ".tmp"))
- DistPkgFile = DistFile.UnpackFile(DpDescFileName,
- os.path.normpath(os.path.join(GlobalData.gUNPACK_DIR, DpDescFileName)))
+
+ TempDir = os.path.normpath(os.path.join(WorkspaceDir, "Conf/.tmp%s" % str(Index)))
+ GlobalData.gUNPACK_DIR.append(TempDir)
+ DistPkgFile = DistFile.UnpackFile(DpDescFileName, os.path.normpath(os.path.join(TempDir, DpDescFileName)))
if not DistPkgFile:
Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_FILE_BROKEN %DpDescFileName)
-
+
#
# Generate distpkg
#
@@ -159,33 +153,25 @@ def UnZipDp(WorkspaceDir, DpPkgFileName):
#
# unzip contents.zip file
#
- ContentFile = DistFile.UnpackFile(ContentFileName,
- os.path.normpath(os.path.join(GlobalData.gUNPACK_DIR, ContentFileName)))
+ ContentFile = DistFile.UnpackFile(ContentFileName, os.path.normpath(os.path.join(TempDir, ContentFileName)))
if not ContentFile:
Logger.Error("InstallPkg", FILE_NOT_FOUND,
ST.ERR_FILE_BROKEN % ContentFileName)
- FilePointer = __FileHookOpen__(ContentFile, "rb")
- #
- # Assume no archive comment.
- #
- FilePointer.seek(0, SEEK_SET)
- FilePointer.seek(0, SEEK_END)
#
# Get file size
- #
- FileSize = FilePointer.tell()
- FilePointer.close()
-
- if FileSize != 0:
+ #
+ FileSize = os.path.getsize(ContentFile)
+
+ if FileSize != 0:
ContentZipFile = PackageFile(ContentFile)
#
# verify MD5 signature when existed
#
if DistPkg.Header.Signature != '':
- Md5Sigature = md5.new(__FileHookOpen__(ContentFile, 'rb').read())
- if DistPkg.Header.Signature != Md5Sigature.hexdigest():
+ Md5Signature = md5(__FileHookOpen__(ContentFile, 'rb').read())
+ if DistPkg.Header.Signature != Md5Signature.hexdigest():
ContentZipFile.Close()
Logger.Error("InstallPkg", FILE_CHECKSUM_FAILURE,
ExtraData=ContentFile)
@@ -202,19 +188,19 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleLi
PackagePath = Path
Package = DistPkg.PackageSurfaceArea[Guid, Version, Path]
Logger.Info(ST.MSG_INSTALL_PACKAGE % Package.GetName())
- if Dep.CheckPackageExists(Guid, Version):
- Logger.Info(ST.WRN_PACKAGE_EXISTED %(Guid, Version))
+# if Dep.CheckPackageExists(Guid, Version):
+# Logger.Info(ST.WRN_PACKAGE_EXISTED %(Guid, Version))
if Options.UseGuidedPkgPath:
GuidedPkgPath = "%s_%s_%s" % (Package.GetName(), Guid, Version)
NewPackagePath = InstallNewPackage(WorkspaceDir, GuidedPkgPath, Options.CustomPath)
else:
NewPackagePath = InstallNewPackage(WorkspaceDir, PackagePath, Options.CustomPath)
- InstallPackageContent(PackagePath, NewPackagePath, Package, ContentZipFile, Dep, WorkspaceDir, ModuleList,
+ InstallPackageContent(PackagePath, NewPackagePath, Package, ContentZipFile, Dep, WorkspaceDir, ModuleList,
DistPkg.Header.ReadOnly)
PackageList.append(Package)
-
+
NewDict[Guid, Version, Package.GetPackagePath()] = Package
-
+
#
# Now generate meta-data files, first generate all dec for package
# dec should be generated before inf, and inf should be generated after
@@ -223,11 +209,11 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleLi
#
for Package in PackageList:
FilePath = PackageToDec(Package, DistPkg.Header)
- Md5Sigature = md5.new(__FileHookOpen__(str(FilePath), 'rb').read())
- Md5Sum = Md5Sigature.hexdigest()
+ Md5Signature = md5(__FileHookOpen__(str(FilePath), 'rb').read())
+ Md5Sum = Md5Signature.hexdigest()
if (FilePath, Md5Sum) not in Package.FileList:
Package.FileList.append((FilePath, Md5Sum))
-
+
return NewDict
## GetModuleList
@@ -237,18 +223,18 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleLi
def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
#
# ModulePathList will keep track of the standalone module path that
- # we just installed. If a new module's path in that list
- # (only multiple INF in one directory will be so), we will
- # install them directly. If not, we will try to create a new directory
+ # we just installed. If a new module's path in that list
+ # (only multiple INF in one directory will be so), we will
+ # install them directly. If not, we will try to create a new directory
# for it.
#
ModulePathList = []
-
+
#
# Check module exist and install
#
Module = None
- NewDict = Sdict()
+ NewDict = Sdict()
for Guid, Version, Name, Path in DistPkg.ModuleSurfaceArea:
ModulePath = Path
Module = DistPkg.ModuleSurfaceArea[Guid, Version, Name, Path]
@@ -267,14 +253,14 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
ModulePathList.append(NewModuleFullPath)
else:
NewModulePath = ModulePath
-
- InstallModuleContent(ModulePath, NewModulePath, '', Module, ContentZipFile, WorkspaceDir, ModuleList, None,
+
+ InstallModuleContent(ModulePath, NewModulePath, '', Module, ContentZipFile, WorkspaceDir, ModuleList, None,
DistPkg.Header.ReadOnly)
#
# Update module
#
Module.SetModulePath(Module.GetModulePath().replace(Path, NewModulePath, 1))
-
+
NewDict[Guid, Version, Name, Module.GetModulePath()] = Module
#
@@ -283,8 +269,8 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
for (Module, Package) in ModuleList:
CheckCNameInModuleRedefined(Module, DistPkg)
FilePath = ModuleToInf(Module, Package, DistPkg.Header)
- Md5Sigature = md5.new(__FileHookOpen__(str(FilePath), 'rb').read())
- Md5Sum = Md5Sigature.hexdigest()
+ Md5Signature = md5(__FileHookOpen__(str(FilePath), 'rb').read())
+ Md5Sum = Md5Signature.hexdigest()
if Package:
if (FilePath, Md5Sum) not in Package.FileList:
Package.FileList.append((FilePath, Md5Sum))
@@ -297,7 +283,7 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
for (FilePath, Md5Sum) in Module.FileList:
if str(FilePath).endswith('.uni') and Package and (FilePath, Md5Sum) not in Package.FileList:
Package.FileList.append((FilePath, Md5Sum))
-
+
return NewDict
##
@@ -311,7 +297,7 @@ def GetDepProtocolPpiGuidPcdNames(DePackageObjList):
DependentPpiCNames = []
DependentGuidCNames = []
DependentPcdNames = []
-
+
for PackageObj in DePackageObjList:
#
# Get protocol CName list from all dependent DEC file
@@ -320,29 +306,29 @@ def GetDepProtocolPpiGuidPcdNames(DePackageObjList):
for Protocol in PackageObj.GetProtocolList():
if Protocol.GetCName() not in ProtocolCNames:
ProtocolCNames.append(Protocol.GetCName())
-
+
DependentProtocolCNames.append(ProtocolCNames)
-
+
#
# Get Ppi CName list from all dependent DEC file
- #
+ #
PpiCNames = []
for Ppi in PackageObj.GetPpiList():
if Ppi.GetCName() not in PpiCNames:
PpiCNames.append(Ppi.GetCName())
DependentPpiCNames.append(PpiCNames)
-
+
#
# Get Guid CName list from all dependent DEC file
- #
+ #
GuidCNames = []
for Guid in PackageObj.GetGuidList():
if Guid.GetCName() not in GuidCNames:
GuidCNames.append(Guid.GetCName())
-
+
DependentGuidCNames.append(GuidCNames)
-
+
#
# Get PcdName list from all dependent DEC file
#
@@ -351,10 +337,10 @@ def GetDepProtocolPpiGuidPcdNames(DePackageObjList):
PcdName = '.'.join([Pcd.GetTokenSpaceGuidCName(), Pcd.GetCName()])
if PcdName not in PcdNames:
PcdNames.append(PcdName)
-
+
DependentPcdNames.append(PcdNames)
-
-
+
+
return DependentProtocolCNames, DependentPpiCNames, DependentGuidCNames, DependentPcdNames
##
@@ -366,8 +352,8 @@ def CheckProtoclCNameRedefined(Module, DependentProtocolCNames):
for PackageProtocolCNames in DependentProtocolCNames:
if ProtocolInModule.GetCName() in PackageProtocolCNames:
if IsCNameDefined:
- Logger.Error("\nUPT", FORMAT_INVALID,
- File = Module.GetFullPath(),
+ Logger.Error("\nUPT", FORMAT_INVALID,
+ File = Module.GetFullPath(),
ExtraData = \
ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % ProtocolInModule.GetCName())
else:
@@ -382,11 +368,11 @@ def CheckPpiCNameRedefined(Module, DependentPpiCNames):
for PackagePpiCNames in DependentPpiCNames:
if PpiInModule.GetCName() in PackagePpiCNames:
if IsCNameDefined:
- Logger.Error("\nUPT", FORMAT_INVALID,
- File = Module.GetFullPath(),
+ Logger.Error("\nUPT", FORMAT_INVALID,
+ File = Module.GetFullPath(),
ExtraData = ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % PpiInModule.GetCName())
else:
- IsCNameDefined = True
+ IsCNameDefined = True
##
# Check if Guid CName is redefined
@@ -397,8 +383,8 @@ def CheckGuidCNameRedefined(Module, DependentGuidCNames):
for PackageGuidCNames in DependentGuidCNames:
if GuidInModule.GetCName() in PackageGuidCNames:
if IsCNameDefined:
- Logger.Error("\nUPT", FORMAT_INVALID,
- File = Module.GetFullPath(),
+ Logger.Error("\nUPT", FORMAT_INVALID,
+ File = Module.GetFullPath(),
ExtraData = \
ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % GuidInModule.GetCName())
else:
@@ -422,8 +408,8 @@ def CheckPcdNameRedefined(Module, DependentPcdNames):
for PcdNames in DependentPcdNames:
if PcdName in PcdNames:
if IsPcdNameDefined:
- Logger.Error("\nUPT", FORMAT_INVALID,
- File = Module.GetFullPath(),
+ Logger.Error("\nUPT", FORMAT_INVALID,
+ File = Module.GetFullPath(),
ExtraData = ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % PcdName)
else:
IsPcdNameDefined = True
@@ -435,7 +421,7 @@ def CheckCNameInModuleRedefined(Module, DistPkg):
DePackageObjList = []
#
# Get all dependent package objects
- #
+ #
for Obj in Module.GetPackageDependencyList():
Guid = Obj.GetGuid()
Version = Obj.GetVersion()
@@ -443,7 +429,7 @@ def CheckCNameInModuleRedefined(Module, DistPkg):
if Key[0] == Guid and Key[1] == Version:
if DistPkg.PackageSurfaceArea[Key] not in DePackageObjList:
DePackageObjList.append(DistPkg.PackageSurfaceArea[Key])
-
+
DependentProtocolCNames, DependentPpiCNames, DependentGuidCNames, DependentPcdNames = \
GetDepProtocolPpiGuidPcdNames(DePackageObjList)
@@ -465,7 +451,7 @@ def GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile):
ToolFileNum = 0
FileNum = 0
RootDir = WorkspaceDir
-
+
#
# FileList stores both tools files and misc files
# Misc file list must be appended to FileList *AFTER* Tools file list
@@ -509,69 +495,81 @@ def GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile):
# @param Options: command Options
#
def Main(Options = None):
- ContentZipFile, DistFile = None, None
-
try:
DataBase = GlobalData.gDB
WorkspaceDir = GlobalData.gWORKSPACE
if not Options.PackageFile:
Logger.Error("InstallPkg", OPTION_MISSING, ExtraData=ST.ERR_SPECIFY_PACKAGE)
-
- #
- # unzip dist.pkg file
- #
- DistPkg, ContentZipFile, DpPkgFileName, DistFile = UnZipDp(WorkspaceDir, Options.PackageFile)
- #
- # check dependency
- #
- Dep = DependencyRules(DataBase)
- CheckInstallDpx(Dep, DistPkg)
+ # Get all Dist Info
+ DistInfoList = []
+ DistPkgList = []
+ Index = 1
+ for ToBeInstalledDist in Options.PackageFile:
+ #
+ # unzip dist.pkg file
+ #
+ DistInfoList.append(UnZipDp(WorkspaceDir, ToBeInstalledDist, Index))
+ DistPkgList.append(DistInfoList[-1][0])
+ Index += 1
- #
- # Install distribution
- #
- InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir, DataBase)
+ #
+ # Add dist
+ #
+ GlobalData.gTO_BE_INSTALLED_DIST_LIST.append(DistInfoList[-1][0])
+
+ # Check for dependency
+ Dep = DependencyRules(DataBase, DistPkgList)
+
+ for ToBeInstalledDist in DistInfoList:
+ CheckInstallDpx(Dep, ToBeInstalledDist[0], ToBeInstalledDist[2])
+
+ #
+ # Install distribution
+ #
+ InstallDp(ToBeInstalledDist[0], ToBeInstalledDist[2], ToBeInstalledDist[1],
+ Options, Dep, WorkspaceDir, DataBase)
ReturnCode = 0
-
- except FatalError, XExcept:
+
+ except FatalError as XExcept:
ReturnCode = XExcept.args[0]
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
-
+
except KeyboardInterrupt:
ReturnCode = ABORT_ERROR
if Logger.GetLevel() <= Logger.DEBUG_9:
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())
-
+
except:
ReturnCode = CODE_ERROR
Logger.Error(
"\nInstallPkg",
CODE_ERROR,
ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.PackageFile,
- ExtraData=ST.MSG_SEARCH_FOR_HELP,
+ ExtraData=ST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL_ADDR,
RaiseError=False
)
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(),
platform) + format_exc())
finally:
Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_STARTED)
- if DistFile:
- DistFile.Close()
- if ContentZipFile:
- ContentZipFile.Close()
- if GlobalData.gUNPACK_DIR:
- rmtree(GlobalData.gUNPACK_DIR)
- GlobalData.gUNPACK_DIR = None
+ for ToBeInstalledDist in DistInfoList:
+ if ToBeInstalledDist[3]:
+ ToBeInstalledDist[3].Close()
+ if ToBeInstalledDist[1]:
+ ToBeInstalledDist[1].Close()
+ for TempDir in GlobalData.gUNPACK_DIR:
+ rmtree(TempDir)
+ GlobalData.gUNPACK_DIR = []
Logger.Quiet(ST.MSG_REMOVE_TEMP_FILE_DONE)
if ReturnCode == 0:
Logger.Quiet(ST.MSG_FINISH)
return ReturnCode
# BackupDist method
-#
-# This method will backup the Distribution file into the $(WORKSPACE)/conf/upt, and rename it
+#
+# This method will backup the Distribution file into the $(WORKSPACE)/conf/upt, and rename it
# if there is already a same-named distribution existed.
#
# @param DpPkgFileName: The distribution path
@@ -608,14 +606,15 @@ def BackupDist(DpPkgFileName, Guid, Version, WorkspaceDir):
# @param Dep: the DependencyRules instance that used to check dependency
# @param DistPkg: the distribution object
#
-def CheckInstallDpx(Dep, DistPkg):
+def CheckInstallDpx(Dep, DistPkg, DistPkgFileName):
#
# Check distribution package installed or not
#
if Dep.CheckDpExists(DistPkg.Header.GetGuid(),
DistPkg.Header.GetVersion()):
- Logger.Error("InstallPkg", UPT_ALREADY_INSTALLED_ERROR,
- ST.WRN_DIST_PKG_INSTALLED)
+ Logger.Error("InstallPkg",
+ UPT_ALREADY_INSTALLED_ERROR,
+ ST.WRN_DIST_PKG_INSTALLED % os.path.basename(DistPkgFileName))
#
# Check distribution dependency (all module dependency should be
# satisfied)
@@ -640,19 +639,19 @@ def CheckInstallDpx(Dep, DistPkg):
#
def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
WorkspaceDir, ModuleList, Package = None, ReadOnly = False):
-
+
if NewPath.startswith("\\") or NewPath.startswith("/"):
NewPath = NewPath[1:]
-
+
if not IsValidInstallPath(NewPath):
- Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%NewPath)
-
+ Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%NewPath)
+
NewModuleFullPath = os.path.normpath(os.path.join(WorkspaceDir, NewPath,
ConvertPath(ModulePath)))
Module.SetFullPath(os.path.normpath(os.path.join(NewModuleFullPath,
ConvertPath(Module.GetName()) + '.inf')))
Module.FileList = []
-
+
for MiscFile in Module.GetMiscFileList():
if not MiscFile:
continue
@@ -660,12 +659,12 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
File = Item.GetURI()
if File.startswith("\\") or File.startswith("/"):
File = File[1:]
-
+
if not IsValidInstallPath(File):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)
FromFile = os.path.join(FromPath, ModulePath, File)
- Executable = Item.GetExecutable()
+ Executable = Item.GetExecutable()
ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))
Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable)
if Package and ((ToFile, Md5Sum) not in Package.FileList):
@@ -678,10 +677,10 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
File = Item.GetSourceFile()
if File.startswith("\\") or File.startswith("/"):
File = File[1:]
-
+
if not IsValidInstallPath(File):
- Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)
-
+ Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)
+
FromFile = os.path.join(FromPath, ModulePath, File)
ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))
Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)
@@ -693,24 +692,24 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
Module.FileList.append((ToFile, Md5Sum))
for Item in Module.GetBinaryFileList():
FileNameList = Item.GetFileNameList()
- for FileName in FileNameList:
- File = FileName.GetFilename()
+ for FileName in FileNameList:
+ File = FileName.GetFilename()
if File.startswith("\\") or File.startswith("/"):
File = File[1:]
-
+
if not IsValidInstallPath(File):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)
FromFile = os.path.join(FromPath, ModulePath, File)
ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))
- Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)
+ Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)
if Package and ((ToFile, Md5Sum) not in Package.FileList):
Package.FileList.append((ToFile, Md5Sum))
elif Package:
continue
elif (ToFile, Md5Sum) not in Module.FileList:
Module.FileList.append((ToFile, Md5Sum))
-
+
InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceDir, NewPath, Module, Package, ReadOnly,
ModuleList)
@@ -721,7 +720,7 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceDir, NewPath, Module, Package, ReadOnly,
ModuleList):
#
- # Extract other files under current module path in content Zip file but not listed in the description
+ # Extract other files under current module path in content Zip file but not listed in the description
#
if ContentZipFile:
for FileName in ContentZipFile.GetZipFile().namelist():
@@ -730,12 +729,12 @@ def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceD
if FileUnderPath(FileName, CheckPath):
if FileName.startswith("\\") or FileName.startswith("/"):
FileName = FileName[1:]
-
+
if not IsValidInstallPath(FileName):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
-
+
FromFile = FileName
- ToFile = os.path.normpath(os.path.join(WorkspaceDir,
+ ToFile = os.path.normpath(os.path.join(WorkspaceDir,
ConvertPath(FileName.replace(FromPath, NewPath, 1))))
CheckList = copy.copy(Module.FileList)
if Package:
@@ -750,16 +749,16 @@ def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceD
elif Package:
continue
elif (ToFile, Md5Sum) not in Module.FileList:
- Module.FileList.append((ToFile, Md5Sum))
-
+ Module.FileList.append((ToFile, Md5Sum))
+
ModuleList.append((Module, Package))
## FileUnderPath
-# Check whether FileName started with directory specified by CheckPath
+# Check whether FileName started with directory specified by CheckPath
#
# @param FileName: the FileName need to be checked
# @param CheckPath: the path need to be checked against
-# @return: True or False
+# @return: True or False
#
def FileUnderPath(FileName, CheckPath):
FileName = FileName.replace('\\', '/')
@@ -772,13 +771,13 @@ def FileUnderPath(FileName, CheckPath):
RemainingPath = RemainingPath[1:]
if FileName == os.path.normpath(os.path.join(CheckPath, RemainingPath)):
return True
-
+
return False
## InstallFile
# Extract File from Zipfile, set file attribute, and return the Md5Sum
#
-# @return: True or False
+# @return: True or False
#
def InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable=False):
if os.path.exists(os.path.normpath(ToFile)):
@@ -797,9 +796,9 @@ def InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable=False):
stat.S_IWOTH | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)
else:
chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)
-
- Md5Sigature = md5.new(__FileHookOpen__(str(ToFile), 'rb').read())
- Md5Sum = Md5Sigature.hexdigest()
+
+ Md5Signature = md5(__FileHookOpen__(str(ToFile), 'rb').read())
+ Md5Sum = Md5Signature.hexdigest()
return Md5Sum
@@ -818,44 +817,44 @@ def InstallPackageContent(FromPath, ToPath, Package, ContentZipFile, Dep,
if Dep:
pass
Package.FileList = []
-
+
if ToPath.startswith("\\") or ToPath.startswith("/"):
ToPath = ToPath[1:]
-
+
if not IsValidInstallPath(ToPath):
- Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%ToPath)
+ Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%ToPath)
if FromPath.startswith("\\") or FromPath.startswith("/"):
FromPath = FromPath[1:]
-
+
if not IsValidInstallPath(FromPath):
- Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FromPath)
-
+ Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FromPath)
+
PackageFullPath = os.path.normpath(os.path.join(WorkspaceDir, ToPath))
for MiscFile in Package.GetMiscFileList():
for Item in MiscFile.GetFileList():
FileName = Item.GetURI()
if FileName.startswith("\\") or FileName.startswith("/"):
FileName = FileName[1:]
-
+
if not IsValidInstallPath(FileName):
Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
-
+
FromFile = os.path.join(FromPath, FileName)
Executable = Item.GetExecutable()
ToFile = (os.path.join(PackageFullPath, ConvertPath(FileName)))
Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable)
if (ToFile, Md5Sum) not in Package.FileList:
Package.FileList.append((ToFile, Md5Sum))
- PackageIncludeArchList = []
+ PackageIncludeArchList = []
for Item in Package.GetPackageIncludeFileList():
FileName = Item.GetFilePath()
if FileName.startswith("\\") or FileName.startswith("/"):
FileName = FileName[1:]
-
+
if not IsValidInstallPath(FileName):
- Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
-
+ Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
+
FromFile = os.path.join(FromPath, FileName)
ToFile = os.path.normpath(os.path.join(PackageFullPath, ConvertPath(FileName)))
RetFile = ContentZipFile.UnpackFile(FromFile, ToFile)
@@ -870,21 +869,21 @@ def InstallPackageContent(FromPath, ToPath, Package, ContentZipFile, Dep,
if ReadOnly:
chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)
else:
- chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH)
- Md5Sigature = md5.new(__FileHookOpen__(str(ToFile), 'rb').read())
- Md5Sum = Md5Sigature.hexdigest()
+ chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH)
+ Md5Signature = md5(__FileHookOpen__(str(ToFile), 'rb').read())
+ Md5Sum = Md5Signature.hexdigest()
if (ToFile, Md5Sum) not in Package.FileList:
Package.FileList.append((ToFile, Md5Sum))
Package.SetIncludeArchList(PackageIncludeArchList)
-
+
for Item in Package.GetStandardIncludeFileList():
FileName = Item.GetFilePath()
if FileName.startswith("\\") or FileName.startswith("/"):
FileName = FileName[1:]
-
+
if not IsValidInstallPath(FileName):
- Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
-
+ Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)
+
FromFile = os.path.join(FromPath, FileName)
ToFile = os.path.normpath(os.path.join(PackageFullPath, ConvertPath(FileName)))
Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)
@@ -927,7 +926,7 @@ def GetDPFile(ZipFile):
continue
else:
continue
-
+
Logger.Error("PackagingTool", FILE_TYPE_MISMATCH,
ExtraData=ST.ERR_DIST_FILE_TOOMANY)
if not DescFile or not ContentFile:
@@ -946,13 +945,13 @@ def InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir
#
PackageList = []
ModuleList = []
- DistPkg.PackageSurfaceArea = GetPackageList(DistPkg, Dep, WorkspaceDir, Options,
+ DistPkg.PackageSurfaceArea = GetPackageList(DistPkg, Dep, WorkspaceDir, Options,
ContentZipFile, ModuleList, PackageList)
DistPkg.ModuleSurfaceArea = GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList)
-
+
GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile)
-
+
#
# copy "Distribution File" to directory $(WORKSPACE)/conf/upt
#
@@ -963,6 +962,6 @@ def InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir
# update database
#
Logger.Quiet(ST.MSG_UPDATE_PACKAGE_DATABASE)
- DataBase.AddDPObject(DistPkg, NewDpPkgFileName, DistFileName,
+ DataBase.AddDPObject(DistPkg, NewDpPkgFileName, DistFileName,
DistPkg.Header.RePackage)