BaseTools: Use hashlib instead of md5

Use from hashlib import md5 instead of import md5
due to md5 deprecated in python3

Cc: Liming Gao <liming.gao@intel.com>
Cc: Yonghong Zhu <yonghong.zhu@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Yunhua Feng <yunhuax.feng@intel.com>
Reviewed-by: Yonghong Zhu <yonghong.zhu@intel.com>
This commit is contained in:
Feng, YunhuaX
2018-08-08 14:56:55 +08:00
committed by Yonghong Zhu
parent 87010d3d02
commit fcb1af1b69
6 changed files with 17 additions and 17 deletions

View File

@ -23,7 +23,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
@ -176,7 +176,7 @@ def UnZipDp(WorkspaceDir, DpPkgFileName, Index=1):
# verify MD5 signature when existed
#
if DistPkg.Header.Signature != '':
Md5Sigature = md5.new(__FileHookOpen__(ContentFile, 'rb').read())
Md5Sigature = md5(__FileHookOpen__(ContentFile, 'rb').read())
if DistPkg.Header.Signature != Md5Sigature.hexdigest():
ContentZipFile.Close()
Logger.Error("InstallPkg", FILE_CHECKSUM_FAILURE,
@ -215,7 +215,7 @@ 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())
Md5Sigature = md5(__FileHookOpen__(str(FilePath), 'rb').read())
Md5Sum = Md5Sigature.hexdigest()
if (FilePath, Md5Sum) not in Package.FileList:
Package.FileList.append((FilePath, Md5Sum))
@ -275,7 +275,7 @@ 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())
Md5Sigature = md5(__FileHookOpen__(str(FilePath), 'rb').read())
Md5Sum = Md5Sigature.hexdigest()
if Package:
if (FilePath, Md5Sum) not in Package.FileList:
@ -803,7 +803,7 @@ def InstallFile(ContentZipFile, FromFile, ToFile, ReadOnly, Executable=False):
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())
Md5Sigature = md5(__FileHookOpen__(str(ToFile), 'rb').read())
Md5Sum = Md5Sigature.hexdigest()
return Md5Sum
@ -876,7 +876,7 @@ def InstallPackageContent(FromPath, ToPath, Package, ContentZipFile, Dep,
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())
Md5Sigature = md5(__FileHookOpen__(str(ToFile), 'rb').read())
Md5Sum = Md5Sigature.hexdigest()
if (ToFile, Md5Sum) not in Package.FileList:
Package.FileList.append((ToFile, Md5Sum))