From a6540d49072ae29632a94b9bd9f1d4a63ac92e4c Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Aug 04 2020 23:48:51 +0000 Subject: Fix build failures on rawhide Signed-off-by: Cole Robinson --- diff --git a/0001-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch b/0001-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch new file mode 100644 index 0000000..f40f815 --- /dev/null +++ b/0001-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch @@ -0,0 +1,49 @@ +From a32df3463befa04913fd1934ed264038a9eae00f Mon Sep 17 00:00:00 2001 +Message-Id: +From: Cole Robinson +Date: Tue, 4 Aug 2020 17:04:50 -0400 +Subject: [PATCH 1/2] 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 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.26.2 + diff --git a/0002-BaseTools-Work-around-array.array.tostring-removal-i.patch b/0002-BaseTools-Work-around-array.array.tostring-removal-i.patch new file mode 100644 index 0000000..3f569ea --- /dev/null +++ b/0002-BaseTools-Work-around-array.array.tostring-removal-i.patch @@ -0,0 +1,51 @@ +From f6e649b25150c1417ebcd595004da6d788d7c9c5 Mon Sep 17 00:00:00 2001 +Message-Id: +In-Reply-To: +References: +From: Cole Robinson +Date: Tue, 4 Aug 2020 17:24:32 -0400 +Subject: [PATCH 2/2] 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 +--- + 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.26.2 + diff --git a/edk2.spec b/edk2.spec index e53f09b..17c34ff 100644 --- a/edk2.spec +++ b/edk2.spec @@ -1,7 +1,3 @@ -# This package depends on automagic byte compilation -# https://fedoraproject.org/wiki/Changes/No_more_automagic_Python_bytecompilation_phase_2 -%global _python_bytecompile_extra 1 - # RPM doesn't detect that code in /usr/share is python3, this forces it # https://fedoraproject.org/wiki/Changes/Avoid_usr_bin_python_in_RPM_Build#Python_bytecompilation %global __python %{__python3} @@ -56,7 +52,7 @@ Name: edk2 # to use YYYMMDD to avoid needing to bump package epoch # due to previous 'git' Version: Version: %{edk2_stable_date}01stable -Release: 4%{dist} +Release: 5%{dist} Summary: EFI Development Kit II License: BSD-2-Clause-Patent @@ -105,6 +101,9 @@ Patch0015: 0015-ArmVirtPkg-set-early-hello-message-RH-only.patch Patch0016: 0016-Tweak-the-tools_def-to-support-cross-compiling.patch # openssl compilation fix Patch0017: 0017-fix-openssl-compilation.patch +# py39 build fixes +Patch0018: 0001-BaseTools-fix-ucs-2-lookup-on-python-3.9.patch +Patch0019: 0002-BaseTools-Work-around-array.array.tostring-removal-i.patch %if 0%{?cross:1} %endif @@ -496,6 +495,11 @@ for f in %{_sourcedir}/*edk2-arm*.json; do done %endif +%if 0%{?py_byte_compile:1} +# https://docs.fedoraproject.org/en-US/packaging-guidelines/Python_Appendix/#manual-bytecompilation +%py_byte_compile %{python3} %{buildroot}%{_datadir}/edk2/Python +%endif + install qemu-ovmf-secureboot-%{qosb_version}/ovmf-vars-generator %{buildroot}%{_bindir} @@ -603,6 +607,9 @@ install qemu-ovmf-secureboot-%{qosb_version}/ovmf-vars-generator %{buildroot}%{_ %changelog +* Tue Aug 04 2020 Cole Robinson - 20200201stable-5 +- Fix build failures on rawhide + * Sat Aug 01 2020 Fedora Release Engineering - 20200201stable-4 - Second attempt - Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild