From c13d7dcfe7c0013beafe96161c4b1523e9303eee Mon Sep 17 00:00:00 2001 From: Bruce Leidl Date: Sun, 29 Nov 2020 18:33:23 -0500 Subject: [PATCH] Fix build failures caused by upgrade to Python 3.9 on build host --- .../bbappends/libxcb_1.13.1.bbappend | 7 +++ .../ovmf/python3.9-fix-ucs2-lookup.patch | 46 ++++++++++++++++++ ....9-workaround-array-tostring-removal.patch | 47 +++++++++++++++++++ .../recipes-citadel/bbappends/ovmf_%.bbappend | 9 ++++ 4 files changed, 109 insertions(+) create mode 100644 meta-citadel/recipes-citadel/bbappends/libxcb_1.13.1.bbappend create mode 100644 meta-citadel/recipes-citadel/bbappends/ovmf/python3.9-fix-ucs2-lookup.patch create mode 100644 meta-citadel/recipes-citadel/bbappends/ovmf/python3.9-workaround-array-tostring-removal.patch create mode 100644 meta-citadel/recipes-citadel/bbappends/ovmf_%.bbappend diff --git a/meta-citadel/recipes-citadel/bbappends/libxcb_1.13.1.bbappend b/meta-citadel/recipes-citadel/bbappends/libxcb_1.13.1.bbappend new file mode 100644 index 0000000..3f13b51 --- /dev/null +++ b/meta-citadel/recipes-citadel/bbappends/libxcb_1.13.1.bbappend @@ -0,0 +1,7 @@ + +# Fix Python 3.9 build failure by using native python3 instead of host python3 +# +# https://gitlab.freedesktop.org/xorg/proto/xcbproto/-/merge_requests/8 +# +inherit python3native + diff --git a/meta-citadel/recipes-citadel/bbappends/ovmf/python3.9-fix-ucs2-lookup.patch b/meta-citadel/recipes-citadel/bbappends/ovmf/python3.9-fix-ucs2-lookup.patch new file mode 100644 index 0000000..7478894 --- /dev/null +++ b/meta-citadel/recipes-citadel/bbappends/ovmf/python3.9-fix-ucs2-lookup.patch @@ -0,0 +1,46 @@ +From 64a1a0c2b29860e9e2d5afdbcb2336f38fba5909 Mon Sep 17 00:00:00 2001 +From: Cole Robinson +Date: Tue, 4 Aug 2020 17:04:50 -0400 +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 +--- + 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 b2895f7e5c6..883c2356e0c 100644 +--- a/BaseTools/Source/Python/AutoGen/UniClassObject.py ++++ b/BaseTools/Source/Python/AutoGen/UniClassObject.py +@@ -152,7 +152,7 @@ def encode(self, input, errors='strict'): + + TheUcs2Codec = Ucs2Codec() + def Ucs2Search(name): +- if name == 'ucs-2': ++ if name in ['ucs-2', 'ucs_2']: + return codecs.CodecInfo( + name=name, + encode=TheUcs2Codec.encode, + diff --git a/meta-citadel/recipes-citadel/bbappends/ovmf/python3.9-workaround-array-tostring-removal.patch b/meta-citadel/recipes-citadel/bbappends/ovmf/python3.9-workaround-array-tostring-removal.patch new file mode 100644 index 0000000..bc821ad --- /dev/null +++ b/meta-citadel/recipes-citadel/bbappends/ovmf/python3.9-workaround-array-tostring-removal.patch @@ -0,0 +1,47 @@ +From 43bec9ea3d56f3662ede78023baa2a791b66acac Mon Sep 17 00:00:00 2001 +From: Cole Robinson +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 +Reviewed-by: Yuwei Chen +Reviewed-by: Bob Feng +--- + 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 ad556710802..4be7957138a 100755 +--- a/BaseTools/Source/Python/Common/Misc.py ++++ b/BaseTools/Source/Python/Common/Misc.py +@@ -1635,7 +1635,7 @@ def __init__(self, PeFile): + 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 + diff --git a/meta-citadel/recipes-citadel/bbappends/ovmf_%.bbappend b/meta-citadel/recipes-citadel/bbappends/ovmf_%.bbappend new file mode 100644 index 0000000..67f80b8 --- /dev/null +++ b/meta-citadel/recipes-citadel/bbappends/ovmf_%.bbappend @@ -0,0 +1,9 @@ + +FILESEXTRAPATHS_prepend := "${THISDIR}/ovmf:" + +# Fixes build failure when host Python updated to 3.9 + +SRC_URI += "\ + file://python3.9-fix-ucs2-lookup.patch \ + file://python3.9-workaround-array-tostring-removal.patch \ +"