From 2f05921a63e84243b8d1814aab04b6544bab01ba Mon Sep 17 00:00:00 2001 From: Michal Vasilek Date: Thu, 22 Dec 2022 10:43:50 +0100 Subject: [PATCH 1/2] nodejs: update to 18.12.1. --- ...s-v8-src-trap-handler-trap-handler.h.patch | 31 ------------------- srcpkgs/nodejs/template | 4 +-- 2 files changed, 2 insertions(+), 33 deletions(-) delete mode 100644 srcpkgs/nodejs/patches/999-deps-v8-src-trap-handler-trap-handler.h.patch diff --git a/srcpkgs/nodejs/patches/999-deps-v8-src-trap-handler-trap-handler.h.patch b/srcpkgs/nodejs/patches/999-deps-v8-src-trap-handler-trap-handler.h.patch deleted file mode 100644 index 56529af97223..000000000000 --- a/srcpkgs/nodejs/patches/999-deps-v8-src-trap-handler-trap-handler.h.patch +++ /dev/null @@ -1,31 +0,0 @@ -https://github.com/nxhack/openwrt-node-packages/blob/master/node/patches/v16.x/999-deps-v8-src-trap-handler-trap-handler.h.patch - ---- a/deps/v8/src/trap-handler/trap-handler.h -+++ b/deps/v8/src/trap-handler/trap-handler.h -@@ -17,19 +17,16 @@ namespace v8 { - namespace internal { - namespace trap_handler { - --// X64 on Linux, Windows, MacOS, FreeBSD. --#if V8_HOST_ARCH_X64 && V8_TARGET_ARCH_X64 && \ -- ((V8_OS_LINUX && !V8_OS_ANDROID) || V8_OS_WIN || V8_OS_MACOSX || \ -- V8_OS_FREEBSD) -+#if V8_TARGET_ARCH_X64 && V8_OS_LINUX && !V8_OS_ANDROID - #define V8_TRAP_HANDLER_SUPPORTED true --// Arm64 (non-simulator) on Mac. --#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_ARM64 && V8_OS_MACOSX -+#elif V8_TARGET_ARCH_X64 && V8_OS_WIN - #define V8_TRAP_HANDLER_SUPPORTED true --// Arm64 simulator on x64 on Linux or Mac. --#elif V8_TARGET_ARCH_ARM64 && V8_HOST_ARCH_X64 && (V8_OS_LINUX || V8_OS_MACOSX) --#define V8_TRAP_HANDLER_VIA_SIMULATOR -+#elif V8_TARGET_ARCH_X64 && V8_OS_MACOSX -+#define V8_TRAP_HANDLER_SUPPORTED true -+#elif V8_TARGET_ARCH_X64 && V8_OS_FREEBSD -+#define V8_TRAP_HANDLER_SUPPORTED true -+#elif V8_HOST_ARCH_ARM64 && V8_TARGET_ARCH_ARM64 && V8_OS_MACOSX - #define V8_TRAP_HANDLER_SUPPORTED true --// Everything else is unsupported. - #else - #define V8_TRAP_HANDLER_SUPPORTED false - #endif diff --git a/srcpkgs/nodejs/template b/srcpkgs/nodejs/template index 0fee0a8ec725..43d70f938ed3 100644 --- a/srcpkgs/nodejs/template +++ b/srcpkgs/nodejs/template @@ -1,6 +1,6 @@ # Template file for 'nodejs' pkgname=nodejs -version=16.19.0 +version=18.12.1 revision=1 # Need these for host v8 for torque, see https://github.com/nodejs/node/pull/21079 hostmakedepends="which pkg-config python3 libatomic-devel zlib-devel @@ -15,7 +15,7 @@ maintainer="Enno Boland " license="MIT" homepage="https://nodejs.org/" distfiles="https://nodejs.org/dist/v${version}/node-v${version}.tar.gz" -checksum=8b8a2939fa5f654ff61cae29b12118c24109273458ecbe6162ad8a8858309e0d +checksum=ba8174dda00d5b90943f37c6a180a1d37c861d91e04a4cb38dc1c0c74981c186 python_version=3 build_options="ssl libuv icu nghttp2 cares" From 21106885ff00c61370e8b148a73aae6cc815e9af Mon Sep 17 00:00:00 2001 From: Zapeth Date: Thu, 22 Dec 2022 17:00:45 +0100 Subject: [PATCH 2/2] firefox-esr: fix build with Python 3.11 --- .../patches/fix-iomode-python3.11.patch | 107 ++++++++++++++++++ .../firefox-esr/patches/ply-python3.11.patch | 85 ++++++++++++++ 2 files changed, 192 insertions(+) create mode 100644 srcpkgs/firefox-esr/patches/fix-iomode-python3.11.patch create mode 100644 srcpkgs/firefox-esr/patches/ply-python3.11.patch diff --git a/srcpkgs/firefox-esr/patches/fix-iomode-python3.11.patch b/srcpkgs/firefox-esr/patches/fix-iomode-python3.11.patch new file mode 100644 index 000000000000..3c13bc656d54 --- /dev/null +++ b/srcpkgs/firefox-esr/patches/fix-iomode-python3.11.patch @@ -0,0 +1,107 @@ +Support for 'U' mode was removed in python 3.11, see https://bugs.python.org/issue37330 + +diff --git a/dom/base/usecounters.py b/dom/base/usecounters.py +index 780e3b3..7e2c714 100644 +--- a/dom/base/usecounters.py ++++ b/dom/base/usecounters.py +@@ -8,7 +8,7 @@ import re + + def read_conf(conf_filename): + # Can't read/write from a single StringIO, so make a new one for reading. +- stream = open(conf_filename, "rU") ++ stream = open(conf_filename, "r") + + def parse_counters(stream): + for line_num, line in enumerate(stream): +diff --git a/python/mozbuild/mozbuild/action/process_define_files.py b/python/mozbuild/mozbuild/action/process_define_files.py +index f1d401a..aca59d0 100644 +--- a/python/mozbuild/mozbuild/action/process_define_files.py ++++ b/python/mozbuild/mozbuild/action/process_define_files.py +@@ -36,7 +36,7 @@ def process_define_file(output, input): + ) and not config.substs.get("JS_STANDALONE"): + config = PartialConfigEnvironment(mozpath.join(topobjdir, "js", "src")) + +- with open(path, "rU") as input: ++ with open(path, "r") as input: + r = re.compile( + "^\s*#\s*(?P[a-z]+)(?:\s+(?P\S+)(?:\s+(?P\S+))?)?", re.U + ) +diff --git a/python/mozbuild/mozbuild/backend/base.py b/python/mozbuild/mozbuild/backend/base.py +index 7bc1986..b64a709 100644 +--- a/python/mozbuild/mozbuild/backend/base.py ++++ b/python/mozbuild/mozbuild/backend/base.py +@@ -272,7 +272,7 @@ class BuildBackend(LoggingMixin): + return status + + @contextmanager +- def _write_file(self, path=None, fh=None, readmode="rU"): ++ def _write_file(self, path=None, fh=None, readmode="r"): + """Context manager to write a file. + + This is a glorified wrapper around FileAvoidWrite with integration to +diff --git a/python/mozbuild/mozbuild/preprocessor.py b/python/mozbuild/mozbuild/preprocessor.py +index f7820b9..857f1a6 100644 +--- a/python/mozbuild/mozbuild/preprocessor.py ++++ b/python/mozbuild/mozbuild/preprocessor.py +@@ -531,7 +531,7 @@ class Preprocessor: + + if args: + for f in args: +- with io.open(f, "rU", encoding="utf-8") as input: ++ with io.open(f, "r", encoding="utf-8") as input: + self.processFile(input=input, output=out) + if depfile: + mk = Makefile() +@@ -860,7 +860,7 @@ class Preprocessor: + args = self.applyFilters(args) + if not os.path.isabs(args): + args = os.path.join(self.curdir, args) +- args = io.open(args, "rU", encoding="utf-8") ++ args = io.open(args, "r", encoding="utf-8") + except Preprocessor.Error: + raise + except Exception: +@@ -914,7 +914,7 @@ class Preprocessor: + def preprocess(includes=[sys.stdin], defines={}, output=sys.stdout, marker="#"): + pp = Preprocessor(defines=defines, marker=marker) + for f in includes: +- with io.open(f, "rU", encoding="utf-8") as input: ++ with io.open(f, "r", encoding="utf-8") as input: + pp.processFile(input=input, output=output) + return pp.includes + +diff --git a/python/mozbuild/mozbuild/util.py b/python/mozbuild/mozbuild/util.py +index b09f164..4f1e0cd 100644 +--- a/python/mozbuild/mozbuild/util.py ++++ b/python/mozbuild/mozbuild/util.py +@@ -236,7 +236,7 @@ class FileAvoidWrite(BytesIO): + still occur, as well as diff capture if requested. + """ + +- def __init__(self, filename, capture_diff=False, dry_run=False, readmode="rU"): ++ def __init__(self, filename, capture_diff=False, dry_run=False, readmode="r"): + BytesIO.__init__(self) + self.name = filename + assert type(capture_diff) == bool +diff --git a/python/mozbuild/mozpack/files.py b/python/mozbuild/mozpack/files.py +index 1d8a1ed..a295a67 100644 +--- a/python/mozbuild/mozpack/files.py ++++ b/python/mozbuild/mozpack/files.py +@@ -554,7 +554,7 @@ class PreprocessedFile(BaseFile): + pp = Preprocessor(defines=self.defines, marker=self.marker) + pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings) + +- with _open(self.path, "rU") as input: ++ with _open(self.path, "r") as input: + with _open(os.devnull, "w") as output: + pp.processFile(input=input, output=output) + +@@ -611,7 +611,7 @@ class PreprocessedFile(BaseFile): + pp = Preprocessor(defines=self.defines, marker=self.marker) + pp.setSilenceDirectiveWarnings(self.silence_missing_directive_warnings) + +- with _open(self.path, "rU") as input: ++ with _open(self.path, "r") as input: + pp.processFile(input=input, output=dest, depfile=deps_out) + + dest.close() diff --git a/srcpkgs/firefox-esr/patches/ply-python3.11.patch b/srcpkgs/firefox-esr/patches/ply-python3.11.patch new file mode 100644 index 000000000000..8d1415a4b369 --- /dev/null +++ b/srcpkgs/firefox-esr/patches/ply-python3.11.patch @@ -0,0 +1,85 @@ +The Ply lexer, which doesn't seem too active a project, wraps regular +expressions from grammar definitions in its own regular expressions that name +groups. This breaks re.compile in Python >= 3.11 when the original expressions +contain global flags, because the compiler requires that global flags appear at +the start of the expression instead of inside the named group. + +This patch wraps re.compile to scan the expression for any global flags and, +when found, moves them to the start of the expression. + +--- a/third_party/python/ply/ply/lex.py ++++ b/third_party/python/ply/ply/lex.py +@@ -49,6 +49,37 @@ + # Python 3.0 + StringTypes = (str, bytes) + ++ ++def _re_compile(expression, *args, **kwargs): ++ ''' ++ Rearrange global flags in the regular expression to appear at the ++ beginning, avoiding deprecation warnings on Python < 3.11 and hard ++ errors on Python >= 3.11. ++ ''' ++ flags = set() ++ remainder = '' ++ ++ pattern = re.compile(r'\(\?([aiLmsux]+)\)') ++ while m := pattern.search(expression): ++ # Location of the global flag spec ++ l, h = m.span(0) ++ # Accumulate global flags from this spec ++ flags.update(m.group(1)) ++ # Capture all text leading up to the match ++ remainder += expression[:l] ++ # Trim to the end fo the flag spec ++ expression = expression[h:] ++ ++ # Any remaining expression contains no flags ++ remainder += expression ++ ++ # If there are flags, they belong at the beginning ++ if flags: ++ remainder = f'(?{"".join(sorted(flags))})' + remainder ++ ++ return re.compile(remainder, *args, **kwargs) ++ ++ + # This regular expression is used to match valid token names + _is_identifier = re.compile(r'^[a-zA-Z0-9_]+$') + +@@ -230,7 +261,7 @@ + titem = [] + txtitem = [] + for pat, func_name in lre: +- titem.append((re.compile(pat, lextab._lexreflags), _names_to_funcs(func_name, fdict))) ++ titem.append((_re_compile(pat, lextab._lexreflags), _names_to_funcs(func_name, fdict))) + + self.lexstatere[statename] = titem + self.lexstateretext[statename] = txtitem +@@ -495,7 +526,7 @@ + return [] + regex = '|'.join(relist) + try: +- lexre = re.compile(regex, reflags) ++ lexre = _re_compile(regex, reflags) + + # Build the index to function map for the matching engine + lexindexfunc = [None] * (max(lexre.groupindex.values()) + 1) +@@ -758,7 +789,7 @@ + continue + + try: +- c = re.compile('(?P<%s>%s)' % (fname, _get_regex(f)), self.reflags) ++ c = _re_compile('(?P<%s>%s)' % (fname, _get_regex(f)), self.reflags) + if c.match(''): + self.log.error("%s:%d: Regular expression for rule '%s' matches empty string", file, line, f.__name__) + self.error = True +@@ -782,7 +813,7 @@ + continue + + try: +- c = re.compile('(?P<%s>%s)' % (name, r), self.reflags) ++ c = _re_compile('(?P<%s>%s)' % (name, r), self.reflags) + if (c.match('')): + self.log.error("Regular expression for rule '%s' matches empty string", name) + self.error = True