]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/InstallPkg.py
BaseTools:Update mailing list address in BaseTools error messages
[mirror_edk2.git] / BaseTools / Source / Python / UPT / InstallPkg.py
index dc22ff7e348438821677e5e8ea5b34687cfb9b64..e4c7565441ba1726066fc6c23ca13a01987d945a 100644 (file)
@@ -1,15 +1,9 @@
 ## @file\r
 # Install distribution package.\r
 #\r
-# Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2011 - 2018, Intel Corporation. All rights reserved.<BR>\r
 #\r
-# This program and the accompanying materials are licensed and made available \r
-# under the terms and conditions of the BSD License which accompanies this \r
-# distribution. The full text of the license may be found at \r
-# http://opensource.org/licenses/bsd-license.php\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
 #\r
 """\r
 Install a distribution package\r
@@ -23,7 +17,7 @@ from os import chmod
 from os import SEEK_SET\r
 from os import SEEK_END\r
 import stat\r
-import md5\r
+from hashlib import md5\r
 import copy\r
 from sys import stdin\r
 from sys import platform\r
@@ -102,7 +96,7 @@ def InstallNewModule(WorkspaceDir, Path, PathList = None):
         Logger.Info(ST.MSG_RELATIVE_PATH_ONLY%FullPath)\r
     else:\r
         return Path\r
-    \r
+\r
     Input = stdin.readline()\r
     Input = Input.replace('\r', '').replace('\n', '')\r
     if Input == '':\r
@@ -110,7 +104,7 @@ def InstallNewModule(WorkspaceDir, Path, PathList = None):
     Input = Input.replace('\r', '').replace('\n', '')\r
     return InstallNewModule(WorkspaceDir, Input, PathList)\r
 \r
-    \r
+\r
 ## InstallNewFile\r
 #\r
 # @param WorkspaceDir:   Workspace Direction\r
@@ -137,15 +131,15 @@ def UnZipDp(WorkspaceDir, DpPkgFileName, Index=1):
     ContentZipFile = None\r
     Logger.Quiet(ST.MSG_UZIP_PARSE_XML)\r
     DistFile = PackageFile(DpPkgFileName)\r
-    \r
+\r
     DpDescFileName, ContentFileName = GetDPFile(DistFile.GetZipFile())\r
-    \r
+\r
     TempDir = os.path.normpath(os.path.join(WorkspaceDir, "Conf/.tmp%s" % str(Index)))\r
     GlobalData.gUNPACK_DIR.append(TempDir)\r
     DistPkgFile = DistFile.UnpackFile(DpDescFileName, os.path.normpath(os.path.join(TempDir, DpDescFileName)))\r
     if not DistPkgFile:\r
         Logger.Error("InstallPkg", FILE_NOT_FOUND, ST.ERR_FILE_BROKEN %DpDescFileName)\r
-    \r
+\r
     #\r
     # Generate distpkg\r
     #\r
@@ -166,18 +160,18 @@ def UnZipDp(WorkspaceDir, DpPkgFileName, Index=1):
 \r
     #\r
     # Get file size\r
-    #                \r
+    #\r
     FileSize = os.path.getsize(ContentFile)\r
-               \r
-    if FileSize != 0:        \r
+\r
+    if FileSize != 0:\r
         ContentZipFile = PackageFile(ContentFile)\r
 \r
     #\r
     # verify MD5 signature when existed\r
     #\r
     if DistPkg.Header.Signature != '':\r
-        Md5Sigature = md5.new(__FileHookOpen__(ContentFile, 'rb').read())\r
-        if DistPkg.Header.Signature != Md5Sigature.hexdigest():\r
+        Md5Signature = md5(__FileHookOpen__(ContentFile, 'rb').read())\r
+        if DistPkg.Header.Signature != Md5Signature.hexdigest():\r
             ContentZipFile.Close()\r
             Logger.Error("InstallPkg", FILE_CHECKSUM_FAILURE,\r
                 ExtraData=ContentFile)\r
@@ -201,12 +195,12 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleLi
             NewPackagePath = InstallNewPackage(WorkspaceDir, GuidedPkgPath, Options.CustomPath)\r
         else:\r
             NewPackagePath = InstallNewPackage(WorkspaceDir, PackagePath, Options.CustomPath)\r
-        InstallPackageContent(PackagePath, NewPackagePath, Package, ContentZipFile, Dep, WorkspaceDir, ModuleList, \r
+        InstallPackageContent(PackagePath, NewPackagePath, Package, ContentZipFile, Dep, WorkspaceDir, ModuleList,\r
                               DistPkg.Header.ReadOnly)\r
         PackageList.append(Package)\r
-        \r
+\r
         NewDict[Guid, Version, Package.GetPackagePath()] = Package\r
-    \r
+\r
     #\r
     # Now generate meta-data files, first generate all dec for package\r
     # dec should be generated before inf, and inf should be generated after\r
@@ -215,11 +209,11 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleLi
     #\r
     for Package in PackageList:\r
         FilePath = PackageToDec(Package, DistPkg.Header)\r
-        Md5Sigature = md5.new(__FileHookOpen__(str(FilePath), 'rb').read())\r
-        Md5Sum = Md5Sigature.hexdigest()\r
+        Md5Signature = md5(__FileHookOpen__(str(FilePath), 'rb').read())\r
+        Md5Sum = Md5Signature.hexdigest()\r
         if (FilePath, Md5Sum) not in Package.FileList:\r
             Package.FileList.append((FilePath, Md5Sum))\r
-    \r
+\r
     return NewDict\r
 \r
 ## GetModuleList\r
@@ -229,18 +223,18 @@ def GetPackageList(DistPkg, Dep, WorkspaceDir, Options, ContentZipFile, ModuleLi
 def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):\r
     #\r
     # ModulePathList will keep track of the standalone module path that\r
-    # we just installed. If a new module's path in that list \r
-    # (only multiple INF in one directory will be so), we will \r
-    # install them directly. If not, we will try to create a new directory \r
+    # we just installed. If a new module's path in that list\r
+    # (only multiple INF in one directory will be so), we will\r
+    # install them directly. If not, we will try to create a new directory\r
     # for it.\r
     #\r
     ModulePathList = []\r
-    \r
+\r
     #\r
     # Check module exist and install\r
     #\r
     Module = None\r
-    NewDict = Sdict()        \r
+    NewDict = Sdict()\r
     for Guid, Version, Name, Path in DistPkg.ModuleSurfaceArea:\r
         ModulePath = Path\r
         Module = DistPkg.ModuleSurfaceArea[Guid, Version, Name, Path]\r
@@ -259,14 +253,14 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
             ModulePathList.append(NewModuleFullPath)\r
         else:\r
             NewModulePath = ModulePath\r
-        \r
-        InstallModuleContent(ModulePath, NewModulePath, '', Module, ContentZipFile, WorkspaceDir, ModuleList, None, \r
+\r
+        InstallModuleContent(ModulePath, NewModulePath, '', Module, ContentZipFile, WorkspaceDir, ModuleList, None,\r
                              DistPkg.Header.ReadOnly)\r
         #\r
         # Update module\r
         #\r
         Module.SetModulePath(Module.GetModulePath().replace(Path, NewModulePath, 1))\r
-        \r
+\r
         NewDict[Guid, Version, Name, Module.GetModulePath()] = Module\r
 \r
     #\r
@@ -275,8 +269,8 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
     for (Module, Package) in ModuleList:\r
         CheckCNameInModuleRedefined(Module, DistPkg)\r
         FilePath = ModuleToInf(Module, Package, DistPkg.Header)\r
-        Md5Sigature = md5.new(__FileHookOpen__(str(FilePath), 'rb').read())\r
-        Md5Sum = Md5Sigature.hexdigest()\r
+        Md5Signature = md5(__FileHookOpen__(str(FilePath), 'rb').read())\r
+        Md5Sum = Md5Signature.hexdigest()\r
         if Package:\r
             if (FilePath, Md5Sum) not in Package.FileList:\r
                 Package.FileList.append((FilePath, Md5Sum))\r
@@ -289,7 +283,7 @@ def GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList):
         for (FilePath, Md5Sum) in Module.FileList:\r
             if str(FilePath).endswith('.uni') and Package and (FilePath, Md5Sum) not in Package.FileList:\r
                 Package.FileList.append((FilePath, Md5Sum))\r
-    \r
+\r
     return NewDict\r
 \r
 ##\r
@@ -303,7 +297,7 @@ def GetDepProtocolPpiGuidPcdNames(DePackageObjList):
     DependentPpiCNames = []\r
     DependentGuidCNames = []\r
     DependentPcdNames = []\r
-    \r
+\r
     for PackageObj in DePackageObjList:\r
         #\r
         # Get protocol CName list from all dependent DEC file\r
@@ -312,29 +306,29 @@ def GetDepProtocolPpiGuidPcdNames(DePackageObjList):
         for Protocol in PackageObj.GetProtocolList():\r
             if Protocol.GetCName() not in ProtocolCNames:\r
                 ProtocolCNames.append(Protocol.GetCName())\r
-  \r
+\r
         DependentProtocolCNames.append(ProtocolCNames)\r
-            \r
+\r
         #\r
         # Get Ppi CName list from all dependent DEC file\r
-        #            \r
+        #\r
         PpiCNames = []\r
         for Ppi in PackageObj.GetPpiList():\r
             if Ppi.GetCName() not in PpiCNames:\r
                 PpiCNames.append(Ppi.GetCName())\r
 \r
         DependentPpiCNames.append(PpiCNames)\r
-            \r
+\r
         #\r
         # Get Guid CName list from all dependent DEC file\r
-        #      \r
+        #\r
         GuidCNames = []\r
         for Guid in PackageObj.GetGuidList():\r
             if Guid.GetCName() not in GuidCNames:\r
                 GuidCNames.append(Guid.GetCName())\r
-        \r
+\r
         DependentGuidCNames.append(GuidCNames)\r
-        \r
+\r
         #\r
         # Get PcdName list from all dependent DEC file\r
         #\r
@@ -343,10 +337,10 @@ def GetDepProtocolPpiGuidPcdNames(DePackageObjList):
             PcdName = '.'.join([Pcd.GetTokenSpaceGuidCName(), Pcd.GetCName()])\r
             if PcdName not in PcdNames:\r
                 PcdNames.append(PcdName)\r
-        \r
+\r
         DependentPcdNames.append(PcdNames)\r
-                \r
-            \r
+\r
+\r
     return DependentProtocolCNames, DependentPpiCNames, DependentGuidCNames, DependentPcdNames\r
 \r
 ##\r
@@ -358,8 +352,8 @@ def CheckProtoclCNameRedefined(Module, DependentProtocolCNames):
         for PackageProtocolCNames in DependentProtocolCNames:\r
             if ProtocolInModule.GetCName() in PackageProtocolCNames:\r
                 if IsCNameDefined:\r
-                    Logger.Error("\nUPT", FORMAT_INVALID, \r
-                                 File = Module.GetFullPath(), \r
+                    Logger.Error("\nUPT", FORMAT_INVALID,\r
+                                 File = Module.GetFullPath(),\r
                                  ExtraData = \\r
                                  ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % ProtocolInModule.GetCName())\r
                 else:\r
@@ -374,11 +368,11 @@ def CheckPpiCNameRedefined(Module, DependentPpiCNames):
         for PackagePpiCNames in DependentPpiCNames:\r
             if PpiInModule.GetCName() in PackagePpiCNames:\r
                 if IsCNameDefined:\r
-                    Logger.Error("\nUPT", FORMAT_INVALID, \r
-                                 File = Module.GetFullPath(), \r
+                    Logger.Error("\nUPT", FORMAT_INVALID,\r
+                                 File = Module.GetFullPath(),\r
                                  ExtraData = ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % PpiInModule.GetCName())\r
                 else:\r
-                    IsCNameDefined = True    \r
+                    IsCNameDefined = True\r
 \r
 ##\r
 # Check if Guid CName is redefined\r
@@ -389,8 +383,8 @@ def CheckGuidCNameRedefined(Module, DependentGuidCNames):
         for PackageGuidCNames in DependentGuidCNames:\r
             if GuidInModule.GetCName() in PackageGuidCNames:\r
                 if IsCNameDefined:\r
-                    Logger.Error("\nUPT", FORMAT_INVALID, \r
-                                 File = Module.GetFullPath(), \r
+                    Logger.Error("\nUPT", FORMAT_INVALID,\r
+                                 File = Module.GetFullPath(),\r
                                  ExtraData = \\r
                                  ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % GuidInModule.GetCName())\r
                 else:\r
@@ -414,8 +408,8 @@ def CheckPcdNameRedefined(Module, DependentPcdNames):
         for PcdNames in DependentPcdNames:\r
             if PcdName in PcdNames:\r
                 if IsPcdNameDefined:\r
-                    Logger.Error("\nUPT", FORMAT_INVALID, \r
-                                 File = Module.GetFullPath(), \r
+                    Logger.Error("\nUPT", FORMAT_INVALID,\r
+                                 File = Module.GetFullPath(),\r
                                  ExtraData = ST.ERR_INF_PARSER_ITEM_DUPLICATE_IN_DEC % PcdName)\r
                 else:\r
                     IsPcdNameDefined = True\r
@@ -427,7 +421,7 @@ def CheckCNameInModuleRedefined(Module, DistPkg):
     DePackageObjList = []\r
     #\r
     # Get all dependent package objects\r
-    # \r
+    #\r
     for Obj in Module.GetPackageDependencyList():\r
         Guid = Obj.GetGuid()\r
         Version = Obj.GetVersion()\r
@@ -435,7 +429,7 @@ def CheckCNameInModuleRedefined(Module, DistPkg):
             if Key[0] == Guid and Key[1] == Version:\r
                 if DistPkg.PackageSurfaceArea[Key] not in DePackageObjList:\r
                     DePackageObjList.append(DistPkg.PackageSurfaceArea[Key])\r
-    \r
+\r
     DependentProtocolCNames, DependentPpiCNames, DependentGuidCNames, DependentPcdNames = \\r
     GetDepProtocolPpiGuidPcdNames(DePackageObjList)\r
 \r
@@ -457,7 +451,7 @@ def GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile):
     ToolFileNum = 0\r
     FileNum = 0\r
     RootDir = WorkspaceDir\r
-    \r
+\r
     #\r
     # FileList stores both tools files and misc files\r
     # Misc file list must be appended to FileList *AFTER* Tools file list\r
@@ -506,7 +500,7 @@ def Main(Options = None):
         WorkspaceDir = GlobalData.gWORKSPACE\r
         if not Options.PackageFile:\r
             Logger.Error("InstallPkg", OPTION_MISSING, ExtraData=ST.ERR_SPECIFY_PACKAGE)\r
-        \r
+\r
         # Get all Dist Info\r
         DistInfoList = []\r
         DistPkgList = []\r
@@ -536,24 +530,24 @@ def Main(Options = None):
             InstallDp(ToBeInstalledDist[0], ToBeInstalledDist[2], ToBeInstalledDist[1],\r
                       Options, Dep, WorkspaceDir, DataBase)\r
         ReturnCode = 0\r
-        \r
+\r
     except FatalError as XExcept:\r
         ReturnCode = XExcept.args[0]\r
         if Logger.GetLevel() <= Logger.DEBUG_9:\r
             Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())\r
-            \r
+\r
     except KeyboardInterrupt:\r
         ReturnCode = ABORT_ERROR\r
         if Logger.GetLevel() <= Logger.DEBUG_9:\r
             Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + format_exc())\r
-            \r
+\r
     except:\r
         ReturnCode = CODE_ERROR\r
         Logger.Error(\r
                     "\nInstallPkg",\r
                     CODE_ERROR,\r
                     ST.ERR_UNKNOWN_FATAL_INSTALL_ERR % Options.PackageFile,\r
-                    ExtraData=ST.MSG_SEARCH_FOR_HELP,\r
+                    ExtraData=ST.MSG_SEARCH_FOR_HELP % ST.MSG_EDKII_MAIL_ADDR,\r
                     RaiseError=False\r
                     )\r
         Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(),\r
@@ -574,8 +568,8 @@ def Main(Options = None):
     return ReturnCode\r
 \r
 # BackupDist method\r
-#  \r
-# This method will backup the Distribution file into the $(WORKSPACE)/conf/upt, and rename it \r
+#\r
+# This method will backup the Distribution file into the $(WORKSPACE)/conf/upt, and rename it\r
 # if there is already a same-named distribution existed.\r
 #\r
 # @param DpPkgFileName: The distribution path\r
@@ -645,19 +639,19 @@ def CheckInstallDpx(Dep, DistPkg, DistPkgFileName):
 #\r
 def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,\r
     WorkspaceDir, ModuleList, Package = None, ReadOnly = False):\r
-    \r
+\r
     if NewPath.startswith("\\") or NewPath.startswith("/"):\r
         NewPath = NewPath[1:]\r
-    \r
+\r
     if not IsValidInstallPath(NewPath):\r
-        Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%NewPath) \r
-           \r
+        Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%NewPath)\r
+\r
     NewModuleFullPath = os.path.normpath(os.path.join(WorkspaceDir, NewPath,\r
         ConvertPath(ModulePath)))\r
     Module.SetFullPath(os.path.normpath(os.path.join(NewModuleFullPath,\r
         ConvertPath(Module.GetName()) + '.inf')))\r
     Module.FileList = []\r
-    \r
+\r
     for MiscFile in Module.GetMiscFileList():\r
         if not MiscFile:\r
             continue\r
@@ -665,12 +659,12 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
             File = Item.GetURI()\r
             if File.startswith("\\") or File.startswith("/"):\r
                 File = File[1:]\r
-            \r
+\r
             if not IsValidInstallPath(File):\r
                 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)\r
 \r
             FromFile = os.path.join(FromPath, ModulePath, File)\r
-            Executable = Item.GetExecutable()            \r
+            Executable = Item.GetExecutable()\r
             ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))\r
             Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable)\r
             if Package and ((ToFile, Md5Sum) not in Package.FileList):\r
@@ -683,10 +677,10 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
         File = Item.GetSourceFile()\r
         if File.startswith("\\") or File.startswith("/"):\r
             File = File[1:]\r
-            \r
+\r
         if not IsValidInstallPath(File):\r
-            Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File) \r
-                               \r
+            Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)\r
+\r
         FromFile = os.path.join(FromPath, ModulePath, File)\r
         ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))\r
         Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)\r
@@ -698,24 +692,24 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
             Module.FileList.append((ToFile, Md5Sum))\r
     for Item in Module.GetBinaryFileList():\r
         FileNameList = Item.GetFileNameList()\r
-        for FileName in FileNameList:              \r
-            File = FileName.GetFilename()          \r
+        for FileName in FileNameList:\r
+            File = FileName.GetFilename()\r
             if File.startswith("\\") or File.startswith("/"):\r
                 File = File[1:]\r
-                \r
+\r
             if not IsValidInstallPath(File):\r
                 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%File)\r
 \r
             FromFile = os.path.join(FromPath, ModulePath, File)\r
             ToFile = os.path.normpath(os.path.join(NewModuleFullPath, ConvertPath(File)))\r
-            Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)       \r
+            Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)\r
             if Package and ((ToFile, Md5Sum) not in Package.FileList):\r
                 Package.FileList.append((ToFile, Md5Sum))\r
             elif Package:\r
                 continue\r
             elif (ToFile, Md5Sum) not in Module.FileList:\r
                 Module.FileList.append((ToFile, Md5Sum))\r
-    \r
+\r
     InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceDir, NewPath, Module, Package, ReadOnly,\r
                                 ModuleList)\r
 \r
@@ -726,7 +720,7 @@ def InstallModuleContent(FromPath, NewPath, ModulePath, Module, ContentZipFile,
 def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceDir, NewPath, Module, Package, ReadOnly,\r
                                 ModuleList):\r
     #\r
-    # Extract other files under current module path in content Zip file but not listed in the description \r
+    # Extract other files under current module path in content Zip file but not listed in the description\r
     #\r
     if ContentZipFile:\r
         for FileName in ContentZipFile.GetZipFile().namelist():\r
@@ -735,12 +729,12 @@ def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceD
             if FileUnderPath(FileName, CheckPath):\r
                 if FileName.startswith("\\") or FileName.startswith("/"):\r
                     FileName = FileName[1:]\r
-                    \r
+\r
                 if not IsValidInstallPath(FileName):\r
                     Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)\r
-                                                   \r
+\r
                 FromFile = FileName\r
-                ToFile = os.path.normpath(os.path.join(WorkspaceDir, \r
+                ToFile = os.path.normpath(os.path.join(WorkspaceDir,\r
                         ConvertPath(FileName.replace(FromPath, NewPath, 1))))\r
                 CheckList = copy.copy(Module.FileList)\r
                 if Package:\r
@@ -755,16 +749,16 @@ def InstallModuleContentZipFile(ContentZipFile, FromPath, ModulePath, WorkspaceD
                     elif Package:\r
                         continue\r
                     elif (ToFile, Md5Sum) not in Module.FileList:\r
-                        Module.FileList.append((ToFile, Md5Sum))            \r
-    \r
+                        Module.FileList.append((ToFile, Md5Sum))\r
+\r
     ModuleList.append((Module, Package))\r
 \r
 ## FileUnderPath\r
-#  Check whether FileName started with directory specified by CheckPath \r
+#  Check whether FileName started with directory specified by CheckPath\r
 #\r
 # @param FileName: the FileName need to be checked\r
 # @param CheckPath: the path need to be checked against\r
-# @return:  True or False  \r
+# @return:  True or False\r
 #\r
 def FileUnderPath(FileName, CheckPath):\r
     FileName = FileName.replace('\\', '/')\r
@@ -777,13 +771,13 @@ def FileUnderPath(FileName, CheckPath):
             RemainingPath = RemainingPath[1:]\r
         if FileName == os.path.normpath(os.path.join(CheckPath, RemainingPath)):\r
             return True\r
-    \r
+\r
     return False\r
 \r
 ## InstallFile\r
 #  Extract File from Zipfile, set file attribute, and return the Md5Sum\r
 #\r
-# @return:  True or False  \r
+# @return:  True or False\r
 #\r
 def InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable=False):\r
     if os.path.exists(os.path.normpath(ToFile)):\r
@@ -802,9 +796,9 @@ def InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable=False):
                   stat.S_IWOTH | stat.S_IEXEC | stat.S_IXGRP | stat.S_IXOTH)\r
         else:\r
             chmod(ToFile, stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH | stat.S_IWUSR | stat.S_IWGRP | stat.S_IWOTH)\r
-                \r
-    Md5Sigature = md5.new(__FileHookOpen__(str(ToFile), 'rb').read())\r
-    Md5Sum = Md5Sigature.hexdigest()\r
+\r
+    Md5Signature = md5(__FileHookOpen__(str(ToFile), 'rb').read())\r
+    Md5Sum = Md5Signature.hexdigest()\r
 \r
     return Md5Sum\r
 \r
@@ -823,44 +817,44 @@ def InstallPackageContent(FromPath, ToPath, Package, ContentZipFile, Dep,
     if Dep:\r
         pass\r
     Package.FileList = []\r
-    \r
+\r
     if ToPath.startswith("\\") or ToPath.startswith("/"):\r
         ToPath = ToPath[1:]\r
-    \r
+\r
     if not IsValidInstallPath(ToPath):\r
-        Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%ToPath)     \r
+        Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%ToPath)\r
 \r
     if FromPath.startswith("\\") or FromPath.startswith("/"):\r
         FromPath = FromPath[1:]\r
-    \r
+\r
     if not IsValidInstallPath(FromPath):\r
-        Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FromPath)   \r
-    \r
+        Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FromPath)\r
+\r
     PackageFullPath = os.path.normpath(os.path.join(WorkspaceDir, ToPath))\r
     for MiscFile in Package.GetMiscFileList():\r
         for Item in MiscFile.GetFileList():\r
             FileName = Item.GetURI()\r
             if FileName.startswith("\\") or FileName.startswith("/"):\r
                 FileName = FileName[1:]\r
-                \r
+\r
             if not IsValidInstallPath(FileName):\r
                 Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)\r
-                            \r
+\r
             FromFile = os.path.join(FromPath, FileName)\r
             Executable = Item.GetExecutable()\r
             ToFile =  (os.path.join(PackageFullPath, ConvertPath(FileName)))\r
             Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable)\r
             if (ToFile, Md5Sum) not in Package.FileList:\r
                 Package.FileList.append((ToFile, Md5Sum))\r
-    PackageIncludeArchList = [] \r
+    PackageIncludeArchList = []\r
     for Item in Package.GetPackageIncludeFileList():\r
         FileName = Item.GetFilePath()\r
         if FileName.startswith("\\") or FileName.startswith("/"):\r
             FileName = FileName[1:]\r
-            \r
+\r
         if not IsValidInstallPath(FileName):\r
-            Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName) \r
-                   \r
+            Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)\r
+\r
         FromFile = os.path.join(FromPath, FileName)\r
         ToFile = os.path.normpath(os.path.join(PackageFullPath, ConvertPath(FileName)))\r
         RetFile = ContentZipFile.UnpackFile(FromFile, ToFile)\r
@@ -875,21 +869,21 @@ def InstallPackageContent(FromPath, ToPath, Package, ContentZipFile, Dep,
         if ReadOnly:\r
             chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH)\r
         else:\r
-            chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH)            \r
-        Md5Sigature = md5.new(__FileHookOpen__(str(ToFile), 'rb').read())\r
-        Md5Sum = Md5Sigature.hexdigest()\r
+            chmod(ToFile, stat.S_IRUSR|stat.S_IRGRP|stat.S_IROTH|stat.S_IWUSR|stat.S_IWGRP|stat.S_IWOTH)\r
+        Md5Signature = md5(__FileHookOpen__(str(ToFile), 'rb').read())\r
+        Md5Sum = Md5Signature.hexdigest()\r
         if (ToFile, Md5Sum) not in Package.FileList:\r
             Package.FileList.append((ToFile, Md5Sum))\r
     Package.SetIncludeArchList(PackageIncludeArchList)\r
-    \r
+\r
     for Item in Package.GetStandardIncludeFileList():\r
         FileName = Item.GetFilePath()\r
         if FileName.startswith("\\") or FileName.startswith("/"):\r
             FileName = FileName[1:]\r
-            \r
+\r
         if not IsValidInstallPath(FileName):\r
-            Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName) \r
-                    \r
+            Logger.Error("UPT", FORMAT_INVALID, ST.ERR_FILE_NAME_INVALIDE%FileName)\r
+\r
         FromFile = os.path.join(FromPath, FileName)\r
         ToFile = os.path.normpath(os.path.join(PackageFullPath, ConvertPath(FileName)))\r
         Md5Sum = InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly)\r
@@ -932,7 +926,7 @@ def GetDPFile(ZipFile):
                 continue\r
         else:\r
             continue\r
-        \r
+\r
         Logger.Error("PackagingTool", FILE_TYPE_MISMATCH,\r
             ExtraData=ST.ERR_DIST_FILE_TOOMANY)\r
     if not DescFile or not ContentFile:\r
@@ -951,13 +945,13 @@ def InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir
     #\r
     PackageList = []\r
     ModuleList = []\r
-    DistPkg.PackageSurfaceArea = GetPackageList(DistPkg, Dep, WorkspaceDir, Options, \r
+    DistPkg.PackageSurfaceArea = GetPackageList(DistPkg, Dep, WorkspaceDir, Options,\r
                                                 ContentZipFile, ModuleList, PackageList)\r
 \r
     DistPkg.ModuleSurfaceArea = GetModuleList(DistPkg, Dep, WorkspaceDir, ContentZipFile, ModuleList)\r
-    \r
+\r
     GenToolMisc(DistPkg, WorkspaceDir, ContentZipFile)\r
-    \r
+\r
     #\r
     # copy "Distribution File" to directory $(WORKSPACE)/conf/upt\r
     #\r
@@ -968,6 +962,6 @@ def InstallDp(DistPkg, DpPkgFileName, ContentZipFile, Options, Dep, WorkspaceDir
     # update database\r
     #\r
     Logger.Quiet(ST.MSG_UPDATE_PACKAGE_DATABASE)\r
-    DataBase.AddDPObject(DistPkg, NewDpPkgFileName, DistFileName, \r
+    DataBase.AddDPObject(DistPkg, NewDpPkgFileName, DistFileName,\r
                    DistPkg.Header.RePackage)\r
 \r