summaryrefslogtreecommitdiffstats
path: root/BaseTools/Source/Python/UPT
diff options
context:
space:
mode:
authorFeng, YunhuaX <yunhuax.feng@intel.com>2018-08-08 14:56:55 +0800
committerYonghong Zhu <yonghong.zhu@intel.com>2018-08-23 15:01:27 +0800
commitfcb1af1b69f8c491824aaa589c7693fa6e731e0b (patch)
tree56bb15c40ef0c9013e25939704b9b192972a26e8 /BaseTools/Source/Python/UPT
parent87010d3d02547c81f1add57a4e2ef0483c65fddf (diff)
downloadedk2-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')
-rw-r--r--BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py4
-rw-r--r--BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py4
-rw-r--r--BaseTools/Source/Python/UPT/InstallPkg.py12
-rw-r--r--BaseTools/Source/Python/UPT/MkPkg.py4
-rw-r--r--BaseTools/Source/Python/UPT/RmPkg.py4
5 files changed, 14 insertions, 14 deletions
diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py b/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py
index 0ba07ccebc..e2dd6a02dc 100644
--- a/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py
+++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenDecFile.py
@@ -19,7 +19,7 @@ GenDEC
import os
import stat
import codecs
-import md5
+from hashlib import md5
from Core.FileHook import __FileHookOpen__
from Library.Parsing import GenSection
from Library.CommentGenerating import GenHeaderCommentSection
@@ -646,7 +646,7 @@ def GenPackageUNIEncodeFile(PackageObject, UniFileHeader = '', Encoding=TAB_ENCO
File = codecs.open(ContainerFile, 'w', Encoding)
File.write(u'\uFEFF' + Content)
File.stream.close()
- Md5Sigature = md5.new(__FileHookOpen__(str(ContainerFile), 'rb').read())
+ Md5Sigature = md5(__FileHookOpen__(str(ContainerFile), 'rb').read())
Md5Sum = Md5Sigature.hexdigest()
if (ContainerFile, Md5Sum) not in PackageObject.FileList:
PackageObject.FileList.append((ContainerFile, Md5Sum))
diff --git a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
index b62c705137..c2a240a884 100644
--- a/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
+++ b/BaseTools/Source/Python/UPT/GenMetaFile/GenInfFile.py
@@ -18,7 +18,7 @@ GenInf
import os
import stat
import codecs
-import md5
+from hashlib import md5
from Core.FileHook import __FileHookOpen__
from Library.StringUtils import GetSplitValueList
from Library.Parsing import GenSection
@@ -255,7 +255,7 @@ def GenModuleUNIEncodeFile(ModuleObject, UniFileHeader='', Encoding=DT.TAB_ENCOD
File = codecs.open(ContainerFile, 'wb', Encoding)
File.write(u'\uFEFF' + Content)
File.stream.close()
- Md5Sigature = md5.new(__FileHookOpen__(str(ContainerFile), 'rb').read())
+ Md5Sigature = md5(__FileHookOpen__(str(ContainerFile), 'rb').read())
Md5Sum = Md5Sigature.hexdigest()
if (ContainerFile, Md5Sum) not in ModuleObject.FileList:
ModuleObject.FileList.append((ContainerFile, Md5Sum))
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))
diff --git a/BaseTools/Source/Python/UPT/MkPkg.py b/BaseTools/Source/Python/UPT/MkPkg.py
index 37942b8ed9..053d115547 100644
--- a/BaseTools/Source/Python/UPT/MkPkg.py
+++ b/BaseTools/Source/Python/UPT/MkPkg.py
@@ -27,7 +27,7 @@ from sys import stdin
from sys import platform
from traceback import format_exc
from platform import python_version
-import md5
+from hashlib import md5
from time import strftime
from time import localtime
from uuid import uuid4
@@ -196,7 +196,7 @@ def Main(Options = None):
#
# Add Md5Sigature
#
- DistPkg.Header.Signature = md5.new(open(str(ContentFile), 'rb').read()).hexdigest()
+ DistPkg.Header.Signature = md5(open(str(ContentFile), 'rb').read()).hexdigest()
#
# Add current Date
#
diff --git a/BaseTools/Source/Python/UPT/RmPkg.py b/BaseTools/Source/Python/UPT/RmPkg.py
index 78469dc758..f1d141c736 100644
--- a/BaseTools/Source/Python/UPT/RmPkg.py
+++ b/BaseTools/Source/Python/UPT/RmPkg.py
@@ -23,7 +23,7 @@ import os.path
from stat import S_IWUSR
from traceback import format_exc
from platform import python_version
-import md5
+from hashlib import md5
from sys import stdin
from sys import platform
@@ -242,7 +242,7 @@ def RemoveDist(Guid, Version, StoredDistFile, DataBase, WorkspaceDir, ForceRemov
#
# check whether modified by users
#
- Md5Sigature = md5.new(open(str(Path), 'rb').read())
+ Md5Sigature = md5(open(str(Path), 'rb').read())
if Md5Sum != Md5Sigature.hexdigest():
Logger.Info(ST.MSG_CONFIRM_REMOVE2 % Path)
Input = stdin.readline()