Patch to xml-rewrite-2.py to switch from direct Expat usage to Sax. Gives proper...
authorPetteri Räty <betelgeuse@gentoo.org>
Sun, 31 Dec 2006 19:21:27 +0000 (19:21 +0000)
committerPetteri Räty <betelgeuse@gentoo.org>
Sun, 31 Dec 2006 19:21:27 +0000 (19:21 +0000)
Package-Manager: portage-2.1.2_rc4-r1

dev-java/javatoolkit/ChangeLog
dev-java/javatoolkit/Manifest
dev-java/javatoolkit/files/0.2.0-use-sax.patch [new file with mode: 0644]
dev-java/javatoolkit/files/digest-javatoolkit-0.2.0-r1 [new file with mode: 0644]
dev-java/javatoolkit/javatoolkit-0.2.0-r1.ebuild [new file with mode: 0644]

index a765659d0bbcba663c144828c1da4807b23e1e53..024b871477d817ecf7dcc76a808cae0efed9c5b3 100644 (file)
@@ -1,6 +1,13 @@
 # ChangeLog for dev-java/javatoolkit
 # Copyright 1999-2006 Gentoo Foundation; Distributed under the GPL v2
-# $Header: /var/cvsroot/gentoo-x86/dev-java/javatoolkit/ChangeLog,v 1.22 2006/12/30 20:58:19 caster Exp $
+# $Header: /var/cvsroot/gentoo-x86/dev-java/javatoolkit/ChangeLog,v 1.23 2006/12/31 19:21:27 betelgeuse Exp $
+
+*javatoolkit-0.2.0-r1 (31 Dec 2006)
+
+  31 Dec 2006; Petteri Räty <betelgeuse@gentoo.org>
+  +files/0.2.0-use-sax.patch, +javatoolkit-0.2.0-r1.ebuild:
+  Patch to xml-rewrite-2.py to switch from direct Expat usage to Sax. Gives
+  proper support for for example entities and preserving doctypes.
 
   30 Dec 2006; Vlastimil Babka <caster@gentoo.org> javatoolkit-0.1.9.ebuild,
   javatoolkit-0.1.9-r1.ebuild, javatoolkit-0.2.0.ebuild:
index 7a4aec15d08ef57b163021a3e9f53fe64faa1523..28770c5b1fac86957361b8a8e85770658025e2a5 100644 (file)
@@ -1,3 +1,10 @@
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+AUX 0.2.0-use-sax.patch 6162 RMD160 b9e3923267ae550ed94f86a21a7d861a0d32aece SHA1 5d5f2d97d12b56df4319c31027bccc88496e86ec SHA256 d65e3d284c018352e1f38de0c6147f218fe55229e2b7ba1aa22d4294639c3d41
+MD5 c5c9abad6a545d89fcf4eeec0aa69df2 files/0.2.0-use-sax.patch 6162
+RMD160 b9e3923267ae550ed94f86a21a7d861a0d32aece files/0.2.0-use-sax.patch 6162
+SHA256 d65e3d284c018352e1f38de0c6147f218fe55229e2b7ba1aa22d4294639c3d41 files/0.2.0-use-sax.patch 6162
 AUX javatoolkit-0.1.9-make.patch 1168 RMD160 9a7fe61e8820d71a60d7a0b7fa472e26ee9154fa SHA1 c49b14cc15753da2fac6d37ffb365808da03caa9 SHA256 d488bec2b639a668eb58ba8ad64f9de81fb68a68db85eb75523b24ae7f53991e
 MD5 16d95a92cdc3ba0a23b07965aff309ef files/javatoolkit-0.1.9-make.patch 1168
 RMD160 9a7fe61e8820d71a60d7a0b7fa472e26ee9154fa files/javatoolkit-0.1.9-make.patch 1168
@@ -12,14 +19,18 @@ EBUILD javatoolkit-0.1.9.ebuild 796 RMD160 be7e2cef62c3f290e241cc140fe1e6c39b7cb
 MD5 05ed17aef49851581abeddb89594708d javatoolkit-0.1.9.ebuild 796
 RMD160 be7e2cef62c3f290e241cc140fe1e6c39b7cb5e6 javatoolkit-0.1.9.ebuild 796
 SHA256 821acd76218b3148395e6a395ed49daa0e5d42700fe0a5a50588f68fe4aae7e1 javatoolkit-0.1.9.ebuild 796
+EBUILD javatoolkit-0.2.0-r1.ebuild 864 RMD160 6116d8ee529dc2621663de8ab502c0f6b73f933b SHA1 9227504e076913659c031b5a7d5eea86e8b73ece SHA256 1dbda91cbbfc81f68dce06a19cd23f12bb181ae00f0e3ff69f9ac632457abf74
+MD5 291d882f465d9b5f144f99b964b3edbd javatoolkit-0.2.0-r1.ebuild 864
+RMD160 6116d8ee529dc2621663de8ab502c0f6b73f933b javatoolkit-0.2.0-r1.ebuild 864
+SHA256 1dbda91cbbfc81f68dce06a19cd23f12bb181ae00f0e3ff69f9ac632457abf74 javatoolkit-0.2.0-r1.ebuild 864
 EBUILD javatoolkit-0.2.0.ebuild 716 RMD160 4f78df128c559ced1b4ef35d96b6d05bb174c480 SHA1 062e28ca4500f3ecfcdc83edd8d9e19690791c7c SHA256 fed84ca9a94cd15c8e85fd0e3a4315f3122801878ecdfa87a6d85cadf5d6be6f
 MD5 799088af5af9ad607c7acd2921339037 javatoolkit-0.2.0.ebuild 716
 RMD160 4f78df128c559ced1b4ef35d96b6d05bb174c480 javatoolkit-0.2.0.ebuild 716
 SHA256 fed84ca9a94cd15c8e85fd0e3a4315f3122801878ecdfa87a6d85cadf5d6be6f javatoolkit-0.2.0.ebuild 716
-MISC ChangeLog 3132 RMD160 920421b3c2246faa488a6c8b1aa2717cd4a7a460 SHA1 27f51e6a42f1b278c52fec5bc29a5f61138cd4be SHA256 5c5f007dcf4e09094c0547ca55773db52cf376bcccb6c69ee3bb5b3f990003a1
-MD5 73fbeb85c1af6c7da9210da0dea8f720 ChangeLog 3132
-RMD160 920421b3c2246faa488a6c8b1aa2717cd4a7a460 ChangeLog 3132
-SHA256 5c5f007dcf4e09094c0547ca55773db52cf376bcccb6c69ee3bb5b3f990003a1 ChangeLog 3132
+MISC ChangeLog 3430 RMD160 58776bb4df7b66fde42a9d4f9dce7435c4203ac2 SHA1 ce27fbf47036c6150896f3141ae030a6881b0a72 SHA256 59de149d213a2f58c74fac9ff795e7344508e66097234318506b5baf30787655
+MD5 0754bf0238d0d30dfd34eeee784f15b9 ChangeLog 3430
+RMD160 58776bb4df7b66fde42a9d4f9dce7435c4203ac2 ChangeLog 3430
+SHA256 59de149d213a2f58c74fac9ff795e7344508e66097234318506b5baf30787655 ChangeLog 3430
 MISC metadata.xml 159 RMD160 8da0afd0f687b8985b7f0432fec737950271e354 SHA1 1d089c3afbfafd09e371d7806cc0c72a5c76e5a1 SHA256 da2aaa3223c5418688dfbba6f899648c5bcb2e4610126519a1a862913c4f8fa6
 MD5 1a27d03fe84c50463e67139ac818e84c metadata.xml 159
 RMD160 8da0afd0f687b8985b7f0432fec737950271e354 metadata.xml 159
@@ -33,3 +44,13 @@ SHA256 d06f1db3fb0ad5dc2d408c8890bea56e72dda47640572ce65033149ee741a4c3 files/di
 MD5 a7ee385c1073b0497d84ebaa67260098 files/digest-javatoolkit-0.2.0 253
 RMD160 be0f9b3066d53e8ef30c85a1266d9adbf9aa60b0 files/digest-javatoolkit-0.2.0 253
 SHA256 1027e8adba272e243524ce25c602ae29453a2a80a1e84b2cb9833b8e04f14303 files/digest-javatoolkit-0.2.0 253
+MD5 a7ee385c1073b0497d84ebaa67260098 files/digest-javatoolkit-0.2.0-r1 253
+RMD160 be0f9b3066d53e8ef30c85a1266d9adbf9aa60b0 files/digest-javatoolkit-0.2.0-r1 253
+SHA256 1027e8adba272e243524ce25c602ae29453a2a80a1e84b2cb9833b8e04f14303 files/digest-javatoolkit-0.2.0-r1 253
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.6 (GNU/Linux)
+
+iD8DBQFFmA3icxLzpIGCsLQRAuwNAKCG0Q/JcmL+4JL+0AafkuGlT5kGyACghBNJ
+b/lN/DKNEEpy1Zxq0h8ecKA=
+=iy8q
+-----END PGP SIGNATURE-----
diff --git a/dev-java/javatoolkit/files/0.2.0-use-sax.patch b/dev-java/javatoolkit/files/0.2.0-use-sax.patch
new file mode 100644 (file)
index 0000000..337b290
--- /dev/null
@@ -0,0 +1,187 @@
+Index: src/bsfix/xml-rewrite-2.py
+===================================================================
+--- src/bsfix/xml-rewrite-2.py (revision 3421)
++++ src/bsfix/xml-rewrite-2.py (revision 3432)
+@@ -3,15 +3,17 @@
+ # Copyright 2004-2006 Gentoo Foundation
+ # Distributed under the terms of the GNU General Public Licence v2
+-# $Header: /var/cvsroot/gentoo-x86/dev-java/javatoolkit/files/0.2.0-use-sax.patch,v 1.1 2006/12/31 19:21:27 betelgeuse Exp $
+-# Author: Saleem Abdulrasool <compnerd@compnerd.org>
++# Authors: 
++#     Saleem Abdulrasool <compnerd@compnerd.org>
++#     Petteri Räty <betelgeuse@gentoo.org>
+ # Maintainer: Gentoo Java Herd <java@gentoo.org>
+ # Python based XML modifier
+ # ChangeLog
+ # Petteri Räty <betelgeuse@gentoo.org
+ #        December 06, 2006 - Changed to use xml.parsers.expat and basically rewrote the whole file
++#        December 29, 2006 - Added a SAX based implementation to handle entities etc ( test on dev-java/skinlf )
+ # Saleem A. <compnerd@compnerd.org>
+ #        December 23, 2004 - Initial Write
+ #        December 24, 2004 - Added usage information
+@@ -26,6 +28,11 @@
+ __version__ = "$Revision: 1.1 $"[11:-2]
+ class DomRewriter:
++      """
++      The old DOM rewriter is still around for index based stuff. It can
++      be used for all the complex stuff but portage needed features should
++      be in StreamRewriterBase subclasses as they are much faster.
++      """
+       from xml.dom import NotFoundErr
+       def __init__(self, modifyElems, attributes, values=None, index=None):
+@@ -61,40 +68,32 @@
+       def write(self,stream):
+               stream.write(self.document.toxml())
+-class ExpatRewriter:
++class StreamRewriterBase:
+       def __init__(self, elems, attributes, values, index):
+               self.buffer = StringIO.StringIO()
+-              self.p = self.buffer.write
++              self.__write = self.buffer.write
+               self.elems = elems
+               self.attributes = attributes
+               self.values = values
+-      def process(self, in_stream):
+-              from xml.parsers.expat import ParserCreate
+-              parser = ParserCreate()
++      def p(self,str):
++              self.__write(str.encode('utf8'))
+-              parser.StartElementHandler = self.start_element
+-              parser.EndElementHandler = self.end_element
+-              parser.CharacterDataHandler = self.char_data
+-              parser.ParseFile(in_stream)
+-              self.p('\n')
+-
+       def write(self, out_stream):
+-              out_stream.write(self.buffer.getvalue())
+-              self.buffer.close()
+-              self.buffer = StringIO.StringIO()
+-              self.p = self.buffer.write
++              value = self.buffer.getvalue()
++              out_stream.write(value)
++              self.buffer.truncate(0)
+       def write_attr(self,a,v):
+-              self.buffer.write('%s=%s ' % (a,quoteattr(v)))
++              self.p(u'%s=%s ' % (a,quoteattr(v, {u'©':'&#169;'})))
+       def start_element(self, name, attrs):
+-              self.p('<%s ' % name)
++              self.p(u'<%s ' % name)
+               match = ( name in self.elems )
+               
+-              for a,v in attrs.iteritems():
++              for a,v in attrs:
+                       if not ( match and a in self.attributes ):
+                               self.write_attr(a,v)
+               
+@@ -102,14 +101,50 @@
+                       for i, attr in enumerate(self.attributes):
+                               self.write_attr(attr, self.values[i])
+-              self.p('>')
++              self.p(u'>')
++class ExpatRewriter(StreamRewriterBase):
++      """
++      The only problem with this Expat based implementation is that it does not
++      handle entities doctypes etc properly so for example dev-java/skinlf fails.
++      """
++      def process(self, in_stream):
++              from xml.parsers.expat import ParserCreate
++              parser = ParserCreate()
++
++              parser.StartElementHandler = self.start_element
++              parser.EndElementHandler = self.end_element
++              parser.CharacterDataHandler = self.char_data
++              parser.ParseFile(in_stream)
++              self.p(u'\n')
++      
++      def start_element(self, name, attrs):
++              StreamRewriterBase(self, name, attrs.iteritems())
++
+       def end_element(self,name):
+-              self.p('</%s>' % name)
++              self.p(u'</%s>' % name)
+       def char_data(self,data):
+               self.p(escape(data))
++from xml.sax.saxutils import XMLGenerator
++class SaxRewriter(XMLGenerator, StreamRewriterBase):
++      """
++      Using Sax gives us the support for writing back doctypes and all easily
++      and is only marginally slower than expat as it is just a tight layer over it
++      """
++      def __init__(self, elems, attributes, values, index):
++              StreamRewriterBase.__init__(self, elems, attributes, values, index)
++              XMLGenerator.__init__(self, self.buffer, 'UTF-8')
++
++      def process(self, in_stream):
++              from xml.sax import parse
++              parse(in_stream, self)
++              self.p(u'\n')
++
++      def startElement(self, name, attrs):
++              self.start_element(name, attrs.items())
++
+ if __name__ == '__main__':
+       usage = "XML Rewrite Python Module Version " + __version__ + "\n"
+       usage += "Copyright 2004 Gentoo Foundation\n"
+@@ -166,8 +201,6 @@
+               error("You must give value for every attribute you are changing.")
+       # End Invalid Arguments Check
+       
+-      import codecs
+-      
+       def get_rewriter(options):
+               if options.index or options.doDelete:
+                       # java-ant-2.eclass does not use these options so we can optimize the ExpatWriter 
+@@ -175,23 +208,32 @@
+                       rewriter = DomRewriter(options.elements, options.attributes, options.values, options.index)
+                       print "Using DOM to rewrite the build.xml files"
+               else:
+-                      rewriter = ExpatRewriter(options.elements, options.attributes, options.values, options.index)
+-                      print "Using Expat to rewrite the build.xml files"
++                      rewriter = SaxRewriter(options.elements, options.attributes, options.values, options.index)
++                      print "Using Sax to rewrite the build.xml files"
+               return rewriter
+       
+       rewriter = get_rewriter(options)
+       if options.files:
++              import os
+               for file in options.files:
+                       print "Rewriting %s" % file
+-                      f = open(file,"r")
++                      # First parse the file into memory
++                      # Tricks with cwd are needed for relative includes of other xml files to build.xml files
++                      cwd = os.getcwd()
++                      dirname = os.path.dirname(file)
++                      if dirname != '': # for file = build.xml comes out as ''
++                              os.chdir(os.path.dirname(file))
++                      f = open(os.path.basename(file),"r")
+                       rewriter.process(f)
++                      os.chdir(cwd)
+                       f.close()               
++                      # Then write it back to the file
+                       f = open(file, "w")
+-                      rewriter.write(codecs.getwriter('utf-8')(f))
++                      rewriter.write(f)
+                       f.close()
+       else:
+               rewriter.process(sys.stdin)
+-              rewriter.write(codecs.getwriter('utf-8')(sys.stdout))
++              rewriter.write(sys.stdout)
diff --git a/dev-java/javatoolkit/files/digest-javatoolkit-0.2.0-r1 b/dev-java/javatoolkit/files/digest-javatoolkit-0.2.0-r1
new file mode 100644 (file)
index 0000000..3d9c1e5
--- /dev/null
@@ -0,0 +1,3 @@
+MD5 db572e8dffdc2856c16fdad23809e8f6 javatoolkit-0.2.0.tar.bz2 19539
+RMD160 0a33da24eddb61d6a1fcb518a9f373c3f835a511 javatoolkit-0.2.0.tar.bz2 19539
+SHA256 3307cec9df6d40ef1dcd2b3a4db2d42df6e61e620774e82e201c0f480635d724 javatoolkit-0.2.0.tar.bz2 19539
diff --git a/dev-java/javatoolkit/javatoolkit-0.2.0-r1.ebuild b/dev-java/javatoolkit/javatoolkit-0.2.0-r1.ebuild
new file mode 100644 (file)
index 0000000..fb2e495
--- /dev/null
@@ -0,0 +1,37 @@
+# Copyright 1999-2006 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/dev-java/javatoolkit/javatoolkit-0.2.0-r1.ebuild,v 1.1 2006/12/31 19:21:27 betelgeuse Exp $
+
+inherit eutils python
+
+DESCRIPTION="Collection of Gentoo-specific tools for Java"
+HOMEPAGE="http://www.gentoo.org/proj/en/java/"
+SRC_URI="mirror://gentoo/${P}.tar.bz2"
+LICENSE="GPL-2"
+SLOT="0"
+KEYWORDS="~amd64 ~ia64 ~ppc ~ppc64 ~sparc ~x86 ~x86-fbsd"
+
+DEPEND="virtual/python"
+RDEPEND="virtual/python"
+
+IUSE=""
+
+src_unpack() {
+       unpack "${A}"
+       cd "${S}"
+       epatch "${FILESDIR}/0.2.0-use-sax.patch"
+       # Fix version
+       sed -i -e s/${PV}/${PVR}/ makedefs.mak
+}
+
+src_install() {
+       make DESTDIR=${D} install || die
+}
+
+pkg_postinst() {
+       python_mod_optimize /usr/share/javatoolkit
+}
+
+pkg_postrm() {
+       python_mod_cleanup /usr/share/javatoolkit
+}