From 4fd4157b50b984a02047db408575f97c6b3bed1e Mon Sep 17 00:00:00 2001 From: Stephen Gallagher Date: Tue, 17 Mar 2020 23:24:03 -0400 Subject: [PATCH] Fix python3 issue in icustrip.py Signed-off-by: Stephen Gallagher --- ...y-fix-use-of-string-and-byte-objects.patch | 82 +++++++++++++++++++ nodejs.spec | 12 ++- 2 files changed, 92 insertions(+), 2 deletions(-) create mode 100644 0003-icustrip.py-fix-use-of-string-and-byte-objects.patch diff --git a/0003-icustrip.py-fix-use-of-string-and-byte-objects.patch b/0003-icustrip.py-fix-use-of-string-and-byte-objects.patch new file mode 100644 index 0000000..fe01f64 --- /dev/null +++ b/0003-icustrip.py-fix-use-of-string-and-byte-objects.patch @@ -0,0 +1,82 @@ +From fa4382c4b48ec34ed3259334f2e0f8d2706ffcf9 Mon Sep 17 00:00:00 2001 +From: Jonathan MERCIER +Date: Tue, 17 Mar 2020 21:18:37 -0400 +Subject: [PATCH 3/3] icustrip.py: fix use of string and byte objects + +Signed-off-by: Stephen Gallagher +--- + tools/icu/icutrim.py | 17 ++++++++--------- + 1 file changed, 8 insertions(+), 9 deletions(-) + +diff --git a/tools/icu/icutrim.py b/tools/icu/icutrim.py +index 25bd99d9cb260da00de9647f9b060790b48af8b2..f857e73bbce298048e407ddbef87f5bc4ac5307a 100755 +--- a/tools/icu/icutrim.py ++++ b/tools/icu/icutrim.py +@@ -11,10 +11,11 @@ + # Usage: + # Use "-h" to get help options. + + from __future__ import print_function + ++import io + import json + import optparse + import os + import re + import shutil +@@ -157,13 +158,12 @@ def runcmd(tool, cmd, doContinue=False): + print("FAILED: %s" % cmd) + sys.exit(1) + return rc + + ## STEP 0 - read in json config +-fi= open(options.filterfile, "rb") +-config=json.load(fi) +-fi.close() ++with io.open(options.filterfile, encoding='utf-8') as fi: ++ config = json.load(fi) + + if options.locales: + config["variables"] = config.get("variables", {}) + config["variables"]["locales"] = config["variables"].get("locales", {}) + config["variables"]["locales"]["only"] = options.locales.split(',') +@@ -283,14 +283,13 @@ for i in range(len(items)): + print("procesing %s" % (tree)) + trees[tree] = { "extension": ".res", "treeprefix": treeprefix, "hasIndex": True } + # read in the resource list for the tree + treelistfile = os.path.join(options.tmpdir,"%s.lst" % tree) + runcmd("iculslocs", "-i %s -N %s -T %s -l > %s" % (outfile, dataname, tree, treelistfile)) +- fi = open(treelistfile, 'rb') +- treeitems = fi.readlines() +- trees[tree]["locs"] = [treeitems[i].strip() for i in range(len(treeitems))] +- fi.close() ++ with io.open(treelistfile, 'r', encoding='utf-8') as fi: ++ treeitems = fi.readlines() ++ trees[tree]["locs"] = [line.strip() for line in treeitems] + if tree not in config.get("trees", {}): + print(" Warning: filter file %s does not mention trees.%s - will be kept as-is" % (options.filterfile, tree)) + else: + queueForRemoval(tree) + +@@ -315,16 +314,16 @@ def removeList(count=0): + print("## Damage control, trying to parse stderr from icupkg..") + fi = open(hackerrfile, 'rb') + erritems = fi.readlines() + fi.close() + #Item zone/zh_Hant_TW.res depends on missing item zone/zh_Hant.res +- pat = re.compile("""^Item ([^ ]+) depends on missing item ([^ ]+).*""") ++ pat = re.compile(bytes(r"^Item ([^ ]+) depends on missing item ([^ ]+).*", 'utf-8')) + for i in range(len(erritems)): + line = erritems[i].strip() + m = pat.match(line) + if m: +- toDelete = m.group(1) ++ toDelete = m.group(1).decode("utf-8") + if(options.verbose > 5): + print("<< %s added to delete" % toDelete) + remove.add(toDelete) + else: + print("ERROR: could not match errline: %s" % line) +-- +2.25.1 + diff --git a/nodejs.spec b/nodejs.spec index 3fea0ad..f2e0afd 100644 --- a/nodejs.spec +++ b/nodejs.spec @@ -8,7 +8,7 @@ # This is used by both the nodejs package and the npm subpackage thar # has a separate version - the name is special so that rpmdev-bumpspec # will bump this rather than adding .1 to the end. -%global baserelease 1 +%global baserelease 2 %{?!_pkgdocdir:%global _pkgdocdir %{_docdir}/%{name}-%{version}} @@ -133,6 +133,10 @@ Patch1: 0001-Disable-running-gyp-on-shared-deps.patch # Patch to install both node and libnode.so, using the correct libdir Patch2: 0002-Install-both-binaries-and-use-libdir.patch +# Patch to fix python3 issues with icustrip.py +# https://github.com/nodejs/node/pull/31659 +Patch3: 0003-icustrip.py-fix-use-of-string-and-byte-objects.patch + BuildRequires: python3-devel BuildRequires: zlib-devel BuildRequires: gcc >= 4.9.4 @@ -594,7 +598,7 @@ end %{_rpmconfigdir}/fileattrs/nodejs_native.attr %{_rpmconfigdir}/nodejs_native.req -%doc AUTHORS CHANGELOG.md COLLABORATOR_GUIDE.md GOVERNANCE.md README.md +%doc AUTHORS CHANGELOG.md onboarding.md GOVERNANCE.md README.md %doc %{_mandir}/man1/node.1* @@ -655,11 +659,15 @@ end %files docs +%doc doc %dir %{_pkgdocdir} %{_pkgdocdir}/html %{_pkgdocdir}/npm/docs %changelog +* Tue Mar 17 2020 Stephen Gallagher - 1:13.11.0-2 +- Fix python3 issue in icustrip.py + * Mon Mar 16 2020 Stephen Gallagher - 1:13.11.0-1 - Update to 13.11.0