## @file\r
# Install distribution package.\r
#\r
-# Copyright (c) 2011 - 2014, 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
'''\r
from stat import S_IWUSR\r
from traceback import format_exc\r
from platform import python_version\r
-import md5\r
+from hashlib import md5\r
from sys import stdin\r
from sys import platform\r
\r
return 1\r
else:\r
#\r
- # report list of modules that are not valid due to force \r
+ # report list of modules that are not valid due to force\r
# remove,\r
# also generate a log file for reference\r
#\r
LogFile.write("%s\n"%ModulePath)\r
Logger.Info(ModulePath)\r
except IOError:\r
- Logger.Warn("\nRmPkg", ST.ERR_FILE_WRITE_FAILURE, \r
+ Logger.Warn("\nRmPkg", ST.ERR_FILE_WRITE_FAILURE,\r
File=LogFilePath)\r
except IOError:\r
- Logger.Warn("\nRmPkg", ST.ERR_FILE_OPEN_FAILURE, \r
+ Logger.Warn("\nRmPkg", ST.ERR_FILE_OPEN_FAILURE,\r
File=LogFilePath)\r
- finally: \r
+ finally:\r
LogFile.close()\r
\r
## Remove Path\r
# removing readonly file on windows will get "Access is denied"\r
# error, so before removing, change the mode to be writeable\r
#\r
-# @param Path: The Path to be removed \r
+# @param Path: The Path to be removed\r
#\r
def RemovePath(Path):\r
Logger.Info(ST.MSG_REMOVE_FILE % Path)\r
# If no error found, return zero value so the caller of this tool can know\r
# if it's executed successfully or not.\r
#\r
-# @param Options: command option \r
+# @param Options: command option\r
#\r
def Main(Options = None):\r
\r
try:\r
- DataBase = GlobalData.gDB \r
+ DataBase = GlobalData.gDB\r
if not Options.DistributionFile:\r
- Logger.Error("RmPkg", \r
- OPTION_MISSING, \r
+ Logger.Error("RmPkg",\r
+ OPTION_MISSING,\r
ExtraData=ST.ERR_SPECIFY_PACKAGE)\r
WorkspaceDir = GlobalData.gWORKSPACE\r
#\r
# Prepare check dependency\r
#\r
Dep = DependencyRules(DataBase)\r
- \r
+\r
#\r
# Get the Dp information\r
#\r
StoredDistFile, Guid, Version = GetInstalledDpInfo(Options.DistributionFile, Dep, DataBase, WorkspaceDir)\r
\r
- # \r
+ #\r
# Check Dp depex\r
#\r
CheckDpDepex(Dep, Guid, Version, WorkspaceDir)\r
\r
- # \r
+ #\r
# remove distribution\r
#\r
RemoveDist(Guid, Version, StoredDistFile, DataBase, WorkspaceDir, Options.Yes)\r
\r
Logger.Quiet(ST.MSG_FINISH)\r
- \r
+\r
ReturnCode = 0\r
- \r
+\r
except FatalError as XExcept:\r
- ReturnCode = XExcept.args[0] \r
+ ReturnCode = XExcept.args[0]\r
if Logger.GetLevel() <= Logger.DEBUG_9:\r
Logger.Quiet(ST.MSG_PYTHON_ON % (python_version(), platform) + \\r
format_exc())\r
if not Dep.CheckDpExists(Guid, Version):\r
Logger.Error("RmPkg", UNKNOWN_ERROR, ST.ERR_DISTRIBUTION_NOT_INSTALLED)\r
#\r
- # Check for Distribution files existence in /conf/upt, if not exist, \r
+ # Check for Distribution files existence in /conf/upt, if not exist,\r
# Warn user and go on.\r
#\r
StoredDistFile = os.path.normpath(os.path.join(WorkspaceDir, GlobalData.gUPT_DIR, NewDpFileName))\r
#\r
# check whether modified by users\r
#\r
- Md5Sigature = md5.new(open(str(Path), 'rb').read())\r
- if Md5Sum != Md5Sigature.hexdigest():\r
+ Md5Signature = md5(open(str(Path), 'rb').read())\r
+ if Md5Sum != Md5Signature.hexdigest():\r
Logger.Info(ST.MSG_CONFIRM_REMOVE2 % Path)\r
Input = stdin.readline()\r
Input = Input.replace('\r', '').replace('\n', '')\r
RemovePath(Path)\r
else:\r
MissingFileList.append(Path)\r
- \r
+\r
for Path in NewFileList:\r
if os.path.isfile(Path):\r
if (not ForceRemove) and (not os.path.split(Path)[1].startswith('.')):\r