]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/UPT/Core/DependencyRules.py
BaseTools: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / BaseTools / Source / Python / UPT / Core / DependencyRules.py
index 2af847ed2e0bbcfaa28d59aa83891608ad24d423..0c801c72d614b9e6f4e868ab45658900a04db70c 100644 (file)
@@ -1,16 +1,9 @@
 ## @file\r
 # This file is for installed package information database operations\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
-#\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
 '''\r
@@ -40,7 +33,7 @@ DEPEX_CHECK_PACKAGE_NOT_FOUND, DEPEX_CHECK_DP_NOT_FOUND) = (0, 1, 2, 3)
 ## DependencyRules\r
 #\r
 # This class represents the dependency rule check mechanism\r
-# \r
+#\r
 # @param object:      Inherited from object class\r
 #\r
 class DependencyRules(object):\r
@@ -53,7 +46,7 @@ class DependencyRules(object):
 \r
         # Add package info from the DIST to be installed.\r
         self.PkgsToBeDepend.extend(self.GenToBeInstalledPkgList(ToBeInstalledPkgList))\r
-        \r
+\r
     def GenToBeInstalledPkgList(self, ToBeInstalledPkgList):\r
         if not ToBeInstalledPkgList:\r
             return []\r
@@ -81,7 +74,7 @@ class DependencyRules(object):
             return True\r
         else:\r
             return False\r
-        \r
+\r
     ## Check whether a module depex satisfied.\r
     #\r
     # @param ModuleObj: A module object\r
@@ -101,7 +94,7 @@ class DependencyRules(object):
             #\r
             Exist = self.CheckPackageExists(Dep.GetGuid(), Dep.GetVersion())\r
             #\r
-            # check whether satisfied by current distribution \r
+            # check whether satisfied by current distribution\r
             #\r
             if not Exist:\r
                 if DpObj is None:\r
@@ -119,7 +112,7 @@ class DependencyRules(object):
                 else:\r
                     Result = False\r
                     break\r
-        \r
+\r
         if not Result:\r
             Logger.Error("CheckModuleDepex", UNKNOWN_ERROR, \\r
                          ST.ERR_DEPENDENCY_NOT_MATCH % (ModuleObj.GetName(), \\r
@@ -127,7 +120,7 @@ class DependencyRules(object):
                                                         Dep.GetGuid(), \\r
                                                         Dep.GetVersion()))\r
         return Result\r
-            \r
+\r
     ## Check whether a package exists in a package list specified by PkgsToBeDepend.\r
     #\r
     # @param Guid: Guid of a package\r
@@ -154,12 +147,12 @@ class DependencyRules(object):
 \r
         Logger.Verbose(ST.MSG_CHECK_PACKAGE_FINISH)\r
         return Found\r
-         \r
+\r
     ## Check whether a package depex satisfied.\r
     #\r
     # @param PkgObj: A package object\r
     # @param DpObj: A distribution object\r
-    # @return: True if package depex satisified\r
+    # @return: True if package depex satisfied\r
     #          False else\r
     #\r
     def CheckPackageDepexSatisfied(self, PkgObj, DpObj=None):\r
@@ -171,7 +164,7 @@ class DependencyRules(object):
             else:\r
                 return False\r
         return True\r
-        \r
+\r
     ## Check whether a DP exists.\r
     #\r
     # @param Guid: Guid of a Distribution\r
@@ -216,7 +209,7 @@ class DependencyRules(object):
         return True, DpObj\r
 \r
 \r
-    ## Check whether a DP depex satisfied by current workspace \r
+    ## Check whether a DP depex satisfied by current workspace\r
     #  (excluding the original distribution's packages to be replaced) for Replace\r
     #\r
     # @param DpObj:  A distribution object\r
@@ -243,17 +236,17 @@ class DependencyRules(object):
                 continue\r
             else:\r
                 return False\r
-            \r
+\r
         for ModKey in DpObj.ModuleSurfaceArea.keys():\r
             ModObj = DpObj.ModuleSurfaceArea[ModKey]\r
             if self.CheckModuleDepexSatisfied(ModObj, DpObj):\r
                 continue\r
             else:\r
                 return False\r
-        \r
+\r
         return True\r
-    \r
-    ## Check whether a DP could be removed from current workspace. \r
+\r
+    ## Check whether a DP could be removed from current workspace.\r
     #\r
     # @param DpGuid:  File's guid\r
     # @param DpVersion: File's version\r
@@ -267,7 +260,7 @@ class DependencyRules(object):
         #\r
         # remove modules that included in current DP\r
         # List of item (FilePath)\r
-        DpModuleList = self.IpiDb.GetDpModuleList(DpGuid, DpVersion) \r
+        DpModuleList = self.IpiDb.GetDpModuleList(DpGuid, DpVersion)\r
         for Module in DpModuleList:\r
             if Module in WsModuleList:\r
                 WsModuleList.remove(Module)\r
@@ -277,7 +270,7 @@ class DependencyRules(object):
         #\r
         # get packages in current Dp and find the install path\r
         # List of item (PkgGuid, PkgVersion, InstallPath)\r
-        DpPackageList = self.IpiDb.GetPackageListFromDp(DpGuid, DpVersion) \r
+        DpPackageList = self.IpiDb.GetPackageListFromDp(DpGuid, DpVersion)\r
         DpPackagePathList = []\r
         WorkSP = GlobalData.gWORKSPACE\r
         for (PkgName, PkgGuid, PkgVersion, DecFile) in self.WsPkgList:\r
@@ -285,23 +278,23 @@ class DependencyRules(object):
                 pass\r
             DecPath = dirname(DecFile)\r
             if DecPath.find(WorkSP) > -1:\r
-                InstallPath = GetRelativePath(DecPath,WorkSP)\r
-                DecFileRelaPath = GetRelativePath(DecFile,WorkSP)\r
+                InstallPath = GetRelativePath(DecPath, WorkSP)\r
+                DecFileRelaPath = GetRelativePath(DecFile, WorkSP)\r
             else:\r
                 InstallPath = DecPath\r
                 DecFileRelaPath = DecFile\r
-                \r
+\r
             if (PkgGuid, PkgVersion, InstallPath) in DpPackageList:\r
                 DpPackagePathList.append(DecFileRelaPath)\r
                 DpPackageList.remove((PkgGuid, PkgVersion, InstallPath))\r
-        \r
+\r
         #\r
         # the left items in DpPackageList are the packages that installed but not found anymore\r
         #\r
         for (PkgGuid, PkgVersion, InstallPath) in DpPackageList:\r
             Logger.Warn("UPT",\r
                         ST.WARN_INSTALLED_PACKAGE_NOT_FOUND%(PkgGuid, PkgVersion, InstallPath))\r
-        \r
+\r
         #\r
         # check modules to see if has dependency on package of current DP\r
         #\r
@@ -320,7 +313,7 @@ class DependencyRules(object):
     # @param NewDpPkgList: a list of package information (Guid, Version) in new Dp\r
     # @retval Replaceable: True if distribution could be replaced, False Else\r
     # @retval DependModuleList: the list of modules that make distribution can not be replaced\r
-    # \r
+    #\r
     def CheckDpDepexForReplace(self, OrigDpGuid, OrigDpVersion, NewDpPkgList):\r
         Replaceable = True\r
         DependModuleList = []\r
@@ -328,19 +321,19 @@ class DependencyRules(object):
         #\r
         # remove modules that included in current DP\r
         # List of item (FilePath)\r
-        DpModuleList = self.IpiDb.GetDpModuleList(OrigDpGuid, OrigDpVersion) \r
+        DpModuleList = self.IpiDb.GetDpModuleList(OrigDpGuid, OrigDpVersion)\r
         for Module in DpModuleList:\r
             if Module in WsModuleList:\r
                 WsModuleList.remove(Module)\r
             else:\r
                 Logger.Warn("UPT\n",\r
                             ST.ERR_MODULE_NOT_INSTALLED % Module)\r
-        \r
+\r
         OtherPkgList = NewDpPkgList\r
         #\r
         # get packages in current Dp and find the install path\r
         # List of item (PkgGuid, PkgVersion, InstallPath)\r
-        DpPackageList = self.IpiDb.GetPackageListFromDp(OrigDpGuid, OrigDpVersion) \r
+        DpPackageList = self.IpiDb.GetPackageListFromDp(OrigDpGuid, OrigDpVersion)\r
         DpPackagePathList = []\r
         WorkSP = GlobalData.gWORKSPACE\r
         for (PkgName, PkgGuid, PkgVersion, DecFile) in self.WsPkgList:\r
@@ -348,12 +341,12 @@ class DependencyRules(object):
                 pass\r
             DecPath = dirname(DecFile)\r
             if DecPath.find(WorkSP) > -1:\r
-                InstallPath = GetRelativePath(DecPath,WorkSP)\r
-                DecFileRelaPath = GetRelativePath(DecFile,WorkSP)\r
+                InstallPath = GetRelativePath(DecPath, WorkSP)\r
+                DecFileRelaPath = GetRelativePath(DecFile, WorkSP)\r
             else:\r
                 InstallPath = DecPath\r
                 DecFileRelaPath = DecFile\r
-                \r
+\r
             if (PkgGuid, PkgVersion, InstallPath) in DpPackageList:\r
                 DpPackagePathList.append(DecFileRelaPath)\r
                 DpPackageList.remove((PkgGuid, PkgVersion, InstallPath))\r
@@ -366,7 +359,7 @@ class DependencyRules(object):
         for (PkgGuid, PkgVersion, InstallPath) in DpPackageList:\r
             Logger.Warn("UPT",\r
                         ST.WARN_INSTALLED_PACKAGE_NOT_FOUND%(PkgGuid, PkgVersion, InstallPath))\r
-        \r
+\r
         #\r
         # check modules to see if it can be satisfied by package not belong to removed DP\r
         #\r
@@ -376,8 +369,8 @@ class DependencyRules(object):
                 DependModuleList.append(Module)\r
         return (Replaceable, DependModuleList)\r
 \r
-    \r
-## check whether module depends on packages in DpPackagePathList, return True \r
+\r
+## check whether module depends on packages in DpPackagePathList, return True\r
 # if found, False else\r
 #\r
 # @param Path: a module path\r
@@ -394,7 +387,7 @@ def VerifyRemoveModuleDep(Path, DpPackagePathList):
                 return False\r
         else:\r
             return True\r
-    except FatalError, ErrCode:\r
+    except FatalError as ErrCode:\r
         if ErrCode.message == EDK1_INF_ERROR:\r
             Logger.Warn("UPT",\r
                         ST.WRN_EDK1_INF_FOUND%Path)\r
@@ -432,7 +425,7 @@ def GetPackagePath(InfPath):
 # @param DpPackagePathList:  a list of Package Paths\r
 # @param OtherPkgList:       a list of Package Information (Guid, Version)\r
 # @retval:  False: module depends on package in DpPackagePathList and can not be satisfied by OtherPkgList\r
-#           True:  either module doesn't depend on DpPackagePathList or module depends on DpPackagePathList \r
+#           True:  either module doesn't depend on DpPackagePathList or module depends on DpPackagePathList\r
 #                 but can be satisfied by OtherPkgList\r
 #\r
 def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):\r
@@ -446,7 +439,7 @@ def VerifyReplaceModuleDep(Path, DpPackagePathList, OtherPkgList):
                     return False\r
         else:\r
             return True\r
-    except FatalError, ErrCode:\r
+    except FatalError as ErrCode:\r
         if ErrCode.message == EDK1_INF_ERROR:\r
             Logger.Warn("UPT",\r
                         ST.WRN_EDK1_INF_FOUND%Path)\r