!55 BaseTools Adaper for python3.9
Merge pull request !55 from caojinhuahw/master
This commit is contained in:
commit
ddb4134a16
51
0028-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch
Normal file
51
0028-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch
Normal file
@ -0,0 +1,51 @@
|
||||
From 5df044496a30e4fa62b71513f3ae87400ceff4c4 Mon Sep 17 00:00:00 2001
|
||||
From: Cole Robinson <crobinso@redhat.com>
|
||||
Date: Wed, 12 Aug 2020 01:28:17 +0800
|
||||
Subject: [PATCH] BaseTools: fix ucs-2 lookup on python 3.9
|
||||
|
||||
python3.9 changed/fixed codec.register behavior to always replace
|
||||
hyphen with underscore for passed in codec names:
|
||||
|
||||
https://bugs.python.org/issue37751
|
||||
|
||||
So the custom Ucs2Search needs to be adapted to handle 'ucs_2' in
|
||||
addition to existing 'ucs-2' for back compat.
|
||||
|
||||
This fixes test failures on python3.9, example:
|
||||
|
||||
======================================================================
|
||||
FAIL: testUtf16InUniFile (CheckUnicodeSourceFiles.Tests)
|
||||
----------------------------------------------------------------------
|
||||
Traceback (most recent call last):
|
||||
File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 375, in PreProcess
|
||||
FileIn = UniFileClassObject.OpenUniFile(LongFilePath(File.Path))
|
||||
File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 303, in OpenUniFile
|
||||
UniFileClassObject.VerifyUcs2Data(FileIn, FileName, Encoding)
|
||||
File "/builddir/build/BUILD/edk2-edk2-stable202002/BaseTools/Source/Python/AutoGen/UniClassObject.py", line 312, in VerifyUcs2Data
|
||||
Ucs2Info = codecs.lookup('ucs-2')
|
||||
LookupError: unknown encoding: ucs-2
|
||||
|
||||
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
||||
Reviewed-by: Yuwei Chen <yuwei.chen@intel.com>
|
||||
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
|
||||
Signed-off-by: Jinhua Cao <caojinhua1@huawei.com>
|
||||
---
|
||||
BaseTools/Source/Python/AutoGen/UniClassObject.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/BaseTools/Source/Python/AutoGen/UniClassObject.py b/BaseTools/Source/Python/AutoGen/UniClassObject.py
|
||||
index b2895f7e5c..883c2356e0 100644
|
||||
--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py
|
||||
+++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py
|
||||
@@ -152,7 +152,7 @@ class Ucs2Codec(codecs.Codec):
|
||||
|
||||
TheUcs2Codec = Ucs2Codec()
|
||||
def Ucs2Search(name):
|
||||
- if name == 'ucs-2':
|
||||
+ if name in ['ucs-2', 'ucs_2']:
|
||||
return codecs.CodecInfo(
|
||||
name=name,
|
||||
encode=TheUcs2Codec.encode,
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -0,0 +1,51 @@
|
||||
From d935684f89d972f3b9ff8fabe18fffefe75b2ed6 Mon Sep 17 00:00:00 2001
|
||||
From: Cole Robinson <crobinso@redhat.com>
|
||||
Date: Wed, 12 Aug 2020 01:28:18 +0800
|
||||
Subject: [PATCH] BaseTools: Work around array.array.tostring() removal in
|
||||
python 3.9
|
||||
|
||||
In python3, array.array.tostring() was a compat alias for tobytes().
|
||||
tostring() was removed in python 3.9.
|
||||
|
||||
Convert this to use tolist() which should be valid for all python
|
||||
versions.
|
||||
|
||||
This fixes this build error on python3.9:
|
||||
|
||||
(Python 3.9.0b5 on linux) Traceback (most recent call last):
|
||||
File "/root/edk2/edk2-edk2-stable202002/BaseTools/BinWrappers/PosixLike/../../Source/Python/Trim/Trim.py", line 593, in Main
|
||||
GenerateVfrBinSec(CommandOptions.ModuleName, CommandOptions.DebugDir, CommandOptions.OutputFile)
|
||||
File "/root/edk2/edk2-edk2-stable202002/BaseTools/BinWrappers/PosixLike/../../Source/Python/Trim/Trim.py", line 449, in GenerateVfrBinSec
|
||||
VfrUniOffsetList = GetVariableOffset(MapFileName, EfiFileName, VfrNameList)
|
||||
File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 88, in GetVariableOffset
|
||||
return _parseForGCC(lines, efifilepath, varnames)
|
||||
File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 151, in _parseForGCC
|
||||
efisecs = PeImageClass(efifilepath).SectionHeaderList
|
||||
File "/root/edk2/edk2-edk2-stable202002/BaseTools/Source/Python/Common/Misc.py", line 1638, in __init__
|
||||
if ByteArray.tostring() != b'PE\0\0':
|
||||
AttributeError: 'array.array' object has no attribute 'tostring'
|
||||
|
||||
Signed-off-by: Cole Robinson <crobinso@redhat.com>
|
||||
Reviewed-by: Yuwei Chen <yuwei.chen@intel.com>
|
||||
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
|
||||
Signed-off-by: Jinhua Cao <caojinhua1@huawei.com>
|
||||
---
|
||||
BaseTools/Source/Python/Common/Misc.py | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/BaseTools/Source/Python/Common/Misc.py b/BaseTools/Source/Python/Common/Misc.py
|
||||
index da5fb380f0..751b2c24f0 100755
|
||||
--- a/BaseTools/Source/Python/Common/Misc.py
|
||||
+++ b/BaseTools/Source/Python/Common/Misc.py
|
||||
@@ -1635,7 +1635,7 @@ class PeImageClass():
|
||||
ByteArray = array.array('B')
|
||||
ByteArray.fromfile(PeObject, 4)
|
||||
# PE signature should be 'PE\0\0'
|
||||
- if ByteArray.tostring() != b'PE\0\0':
|
||||
+ if ByteArray.tolist() != [ord('P'), ord('E'), 0, 0]:
|
||||
self.ErrorInfo = self.FileName + ' has no valid PE signature PE00'
|
||||
return
|
||||
|
||||
--
|
||||
2.27.0
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
|
||||
Name: edk2
|
||||
Version: %{stable_date}
|
||||
Release: 9
|
||||
Release: 10
|
||||
Summary: EFI Development Kit II
|
||||
License: BSD-2-Clause-Patent
|
||||
URL: https://github.com/tianocore/edk2
|
||||
@ -39,6 +39,8 @@ Patch0024: 0024-NetworkPkg-IScsiDxe-reformat-IScsiHexToBin-leading-c.patch
|
||||
Patch0025: 0025-NetworkPkg-IScsiDxe-fix-IScsiHexToBin-hex-parsing.patch
|
||||
Patch0026: 0026-NetworkPkg-IScsiDxe-fix-IScsiHexToBin-buffer-overflo.patch
|
||||
Patch0027: 0027-NetworkPkg-IScsiDxe-check-IScsiHexToBin-return-value.patch
|
||||
Patch0028: 0028-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch
|
||||
Patch0029: 0029-BaseTools-Work-around-array.array.tostring-removal-i.patch
|
||||
|
||||
BuildRequires: acpica-tools gcc gcc-c++ libuuid-devel python3 bc nasm python3-unversioned-command
|
||||
|
||||
@ -236,6 +238,10 @@ chmod +x %{buildroot}%{_bindir}/Rsa2048Sha256GenerateKeys
|
||||
%endif
|
||||
|
||||
%changelog
|
||||
* Tue Jan 18 2022 Jinhua Cao <caojinhua1@huawei.com> - 202002-10
|
||||
- BaseTools: fix ucs-2 lookup on python3.9
|
||||
- BaseTools: Work around array.array.tostring() removal in python3.9
|
||||
|
||||
* Wed Sep 22 2021 imxcc <xingchaochao@huawei.com> - 202002-9
|
||||
- fix cve-2021-38575
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user