diff --git a/0001-Handle-non-utf-8-poms-in-pom_editor.patch b/0001-Handle-non-utf-8-poms-in-pom_editor.patch deleted file mode 100644 index 79cd13e..0000000 --- a/0001-Handle-non-utf-8-poms-in-pom_editor.patch +++ /dev/null @@ -1,173 +0,0 @@ -From 854ae6dc07cac5b497f545bcb3c4e65c5b38fd9f Mon Sep 17 00:00:00 2001 -From: Michael Simacek -Date: Mon, 16 Feb 2015 17:32:03 +0100 -Subject: [PATCH] Handle non-utf-8 poms in pom_editor - ---- - java-utils/pom_editor.py | 5 +++-- - test/data/pom_macros/pom_non_unicode.xml | 14 ++++++++++++++ - test/data/pom_macros/pom_non_unicode.xml-want | 14 ++++++++++++++ - test/data/pom_macros/pom_unicode.xml | 16 ++++++++++++++++ - test/data/pom_macros/pom_unicode.xml-want | 16 ++++++++++++++++ - test/pom_macros_test.py | 21 ++++++++++++++++++--- - 6 files changed, 81 insertions(+), 5 deletions(-) - create mode 100644 test/data/pom_macros/pom_non_unicode.xml - create mode 100644 test/data/pom_macros/pom_non_unicode.xml-want - create mode 100644 test/data/pom_macros/pom_unicode.xml - create mode 100644 test/data/pom_macros/pom_unicode.xml-want - -diff --git a/java-utils/pom_editor.py b/java-utils/pom_editor.py -index 1c30878..fd7125c 100644 ---- a/java-utils/pom_editor.py -+++ b/java-utils/pom_editor.py -@@ -207,12 +207,13 @@ class XmlFile(object): - - def __init__(self, xmlpath): - self.xmlpath = xmlpath -- with io.open(self.xmlpath, encoding='UTF-8') as raw_xml: -+ encoding = etree.parse(xmlpath).docinfo.encoding -+ with io.open(self.xmlpath, encoding=encoding) as raw_xml: - raw_xml = raw_xml.read() - raw_xml = self._preprocess_raw(raw_xml) - self.xml_declaration = re.match(r'\<\?xml\s[^?]*\?\>', raw_xml) - tmpfile = self.xmlpath + '.tmp' -- with io.open(tmpfile, 'w') as prepared: -+ with io.open(tmpfile, 'w', encoding=encoding) as prepared: - prepared.write(raw_xml) - self.document = etree.parse(tmpfile) - self.tab = get_indent(self.root) -diff --git a/test/data/pom_macros/pom_non_unicode.xml b/test/data/pom_macros/pom_non_unicode.xml -new file mode 100644 -index 0000000..1d8b103 ---- /dev/null -+++ b/test/data/pom_macros/pom_non_unicode.xml -@@ -0,0 +1,14 @@ -+ -+ -+ -+ org.apache.commons -+ commons-parent -+ 17 -+ -+ 4.0.0 -+ commons-lang -+ commons-lang -+ 2.6 -+ C�mm�ns L�ng -+ -+ -diff --git a/test/data/pom_macros/pom_non_unicode.xml-want b/test/data/pom_macros/pom_non_unicode.xml-want -new file mode 100644 -index 0000000..37960df ---- /dev/null -+++ b/test/data/pom_macros/pom_non_unicode.xml-want -@@ -0,0 +1,14 @@ -+ -+ -+ -+ org.apache.commons -+ commons-parent -+ 17 -+ -+ 4.0.0 -+ commons-lang -+ commons-lang -+ 2.7 -+ C�mm�ns L�ng -+ -+ -diff --git a/test/data/pom_macros/pom_unicode.xml b/test/data/pom_macros/pom_unicode.xml -new file mode 100644 -index 0000000..8c45d7c ---- /dev/null -+++ b/test/data/pom_macros/pom_unicode.xml -@@ -0,0 +1,16 @@ -+ -+ -+ -+ org.apache.commons -+ commons-parent -+ 17 -+ -+ 4.0.0 -+ commons-lang -+ commons-lang -+ 2.6 -+ Commons Lang -+ -+ 猫耳 -+ -+ -diff --git a/test/data/pom_macros/pom_unicode.xml-want b/test/data/pom_macros/pom_unicode.xml-want -new file mode 100644 -index 0000000..4e916fa ---- /dev/null -+++ b/test/data/pom_macros/pom_unicode.xml-want -@@ -0,0 +1,16 @@ -+ -+ -+ -+ org.apache.commons -+ commons-parent -+ 17 -+ -+ 4.0.0 -+ commons-lang -+ commons-lang -+ 2.7 -+ Commons Lang -+ -+ 猫耳 -+ -+ -diff --git a/test/pom_macros_test.py b/test/pom_macros_test.py -index 7abe7f4..08dedb4 100644 ---- a/test/pom_macros_test.py -+++ b/test/pom_macros_test.py -@@ -1,5 +1,6 @@ - import unittest - import os -+import io - - from shutil import copytree - from shutil import rmtree -@@ -36,12 +37,12 @@ def check_result(pom_path): - res = not report - return report, res - --def get_result_literally(pom_path): -- with open(pom_path, 'r') as gotfile: -+def get_result_literally(pom_path, encoding='UTF-8'): -+ with io.open(pom_path, 'r', encoding=encoding) as gotfile: - got = gotfile.read().split('\n') - - wantpath = '{pom}-want'.format(pom=os.path.basename(pom_path)) -- with open(wantpath, 'r') as wantfile: -+ with io.open(wantpath, 'r', encoding=encoding) as wantfile: - want = wantfile.read().split('\n') - return got, want - -@@ -546,6 +547,20 @@ class PomMacrosTest(unittest.TestCase): - got, want = get_result_literally(pom_path) - self.assertEqual(got, want) - -+ @exec_macro("pom_xpath_set pom:project/pom:version 2.7", "pom_unicode.xml") -+ def test_unicode(self, stdin, stderr, returncode, pom_path): -+ self.assertEqual(returncode, 0, stderr) -+ -+ got, want = get_result_literally(pom_path) -+ self.assertEqual(got, want) -+ -+ @exec_macro("pom_xpath_set pom:project/pom:version 2.7", "pom_non_unicode.xml") -+ def test_non_unicode(self, stdin, stderr, returncode, pom_path): -+ self.assertEqual(returncode, 0, stderr) -+ -+ got, want = get_result_literally(pom_path, encoding='ISO-8859-1') -+ self.assertEqual(got, want) -+ - @exec_macro("pom_remove_parent", "unparsable_xml.pom") - def test_unparsable_xml(self, stdin, stderr, returncode, pom_path): - self.assertEqual(returncode, 1, stderr) --- -2.1.0 - diff --git a/javapackages-tools.spec b/javapackages-tools.spec index 74b1ed9..4431a7f 100644 --- a/javapackages-tools.spec +++ b/javapackages-tools.spec @@ -17,8 +17,6 @@ License: BSD URL: https://git.fedorahosted.org/git/javapackages.git Source0: https://fedorahosted.org/released/javapackages/javapackages-%{version}.tar.xz -Patch0: 0001-Handle-non-utf-8-poms-in-pom_editor.patch - BuildArch: noarch %if 0%{?with_python3} @@ -26,13 +24,13 @@ BuildRequires: python3-devel BuildRequires: python3-lxml BuildRequires: python3-setuptools BuildRequires: python3-nose -BuildRequires: python3-PyXB = 1.2.4 +BuildRequires: python3-six %else BuildRequires: python2-devel BuildRequires: python-lxml BuildRequires: python-setuptools BuildRequires: python-nose -BuildRequires: PyXB = 1.2.4 +BuildRequires: python-six %endif BuildRequires: make BuildRequires: asciidoc @@ -127,8 +125,8 @@ artifact resolution using XMvn resolver. %if 0%{?with_python3} %package -n python3-javapackages Summary: Module for handling various files for Java packaging -Requires: python3-PyXB = 1.2.4 Requires: python3-lxml +Requires: python3-six Obsoletes: python-javapackages < %{version}-%{release} %description -n python3-javapackages @@ -138,8 +136,8 @@ packaging in Linux distributions %else # python2 %package -n python-javapackages Summary: Module for handling various files for Java packaging -Requires: PyXB = 1.2.4 Requires: python-lxml +Requires: python-six Obsoletes: python3-javapackages < %{version}-%{release} %description -n python-javapackages @@ -175,8 +173,6 @@ This package provides non-essential macros and scripts to support Java packaging %prep %setup -q -n javapackages-%{version} -%patch0 -p1 - %build %if 0%{?with_python3} %configure --pyinterpreter=%{__python3}