diff options
author | Feng, YunhuaX <yunhuax.feng@intel.com> | 2018-08-08 14:56:55 +0800 |
---|---|---|
committer | Yonghong Zhu <yonghong.zhu@intel.com> | 2018-08-23 15:01:27 +0800 |
commit | fcb1af1b69f8c491824aaa589c7693fa6e731e0b (patch) | |
tree | 56bb15c40ef0c9013e25939704b9b192972a26e8 /BaseTools/Source/Python/UPT/InstallPkg.py | |
parent | 87010d3d02547c81f1add57a4e2ef0483c65fddf (diff) | |
download | edk2-fcb1af1b69f8c491824aaa589c7693fa6e731e0b.tar.gz edk2-fcb1af1b69f8c491824aaa589c7693fa6e731e0b.tar.bz2 edk2-fcb1af1b69f8c491824aaa589c7693fa6e731e0b.zip |
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>
Diffstat (limited to 'BaseTools/Source/Python/UPT/InstallPkg.py')
-rw-r--r-- | BaseTools/Source/Python/UPT/InstallPkg.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/BaseTools/Source/Python/UPT/InstallPkg.py b/BaseTools/Source/Python/UPT/InstallPkg.py index 3573886d5a..c553d707fd 100644 --- a/BaseTools/Source/Python/UPT/InstallPkg.py +++ b/BaseTools/Source/Python/UPT/InstallPkg.py @@ -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))
|