Index | Thread | Search

From:
Stuart Henderson <stu@spacehopper.org>
Subject:
py3 dblatex (more work needed)
To:
ports <ports@openbsd.org>
Date:
Wed, 16 Jul 2025 15:44:47 +0100

Download raw body.

Thread
  • Stuart Henderson:

    py3 dblatex (more work needed)

I found a py3 version of textproc/dblatex, but haven't been able to
get it to find XSLT properly during build. Posting what I have in case
anyone fancies picking it up.

Index: Makefile
===================================================================
RCS file: /cvs/ports/textproc/dblatex/Makefile,v
diff -u -p -r1.20 Makefile
--- Makefile	7 Nov 2023 14:19:46 -0000	1.20
+++ Makefile	16 Jul 2025 14:44:05 -0000
@@ -1,6 +1,9 @@
 COMMENT =		convert DocBook to LaTeX, DVI, PostScript, and PDF
-DISTNAME =		dblatex-0.3
-REVISION =		10
+
+V =			0.3.11
+DISTNAME =		dblatex-${V}py3
+PKGNAME =		dblatex-${V}
+
 CATEGORIES =		textproc

 # GPLv2+
@@ -11,8 +14,14 @@ SITES =			${SITE_SOURCEFORGE:=dblatex/}
 EXTRACT_SUFX =		.tar.bz2

 MODULES =		lang/python
-MODPY_VERSION =	${MODPY_DEFAULT_VERSION_2}
-MODPY_DISTUTILS_INSTALL =install --prefix=${LOCALBASE} \
+MODPY_PYBUILD =		setuptools
+
+post-extract:
+	sed -i 's,${V}py3,${V},' ${WRKSRC}/xsl/version.xsl
+
+MAKE_ENV =		SGML_CATALOG_FILES=${LOCALBASE}/share/xsl/docbook
+
+xxMODPY_DISTUTILS_INSTALL =install --prefix=${LOCALBASE} \
 				--root=${DESTDIR} \
 				--catalogs=${LOCALBASE}/share/xsl/docbook

@@ -26,10 +35,7 @@ NO_TEST =		Yes

 SUBST_VARS +=		LOCALBASE MODPY_BIN

-post-extract:
-	@cd ${WRKSRC}/docs/manpage/ && gunzip dblatex.1.gz
-
-post-install:
+xxpost-install:
 	@rm -r ${PREFIX}/lib/python${MODPY_VERSION}/site-packages/contrib
 	${SUBST_PROGRAM} ${FILESDIR}/dblatex ${PREFIX}/bin/dblatex

Index: distinfo
===================================================================
RCS file: /cvs/ports/textproc/dblatex/distinfo,v
diff -u -p -r1.2 distinfo
--- distinfo	4 May 2013 09:41:32 -0000	1.2
+++ distinfo	16 Jul 2025 14:44:05 -0000
@@ -1,2 +1,2 @@
-SHA256 (dblatex-0.3.tar.bz2) = 4baaRQORi9pQF5vjMYScWwDhknwHHlPYrnCcJ5HSccc=
-SIZE (dblatex-0.3.tar.bz2) = 1129409
+SHA256 (dblatex-0.3.11py3.tar.bz2) = 9XxbUQPY+A6cYxELY7Mr/2kVYi4l54+0TLsBvLmnlIY=
+SIZE (dblatex-0.3.11py3.tar.bz2) = 1671505
Index: patches/patch-latex_style_dbk_table_sty
===================================================================
RCS file: patches/patch-latex_style_dbk_table_sty
diff -N patches/patch-latex_style_dbk_table_sty
--- patches/patch-latex_style_dbk_table_sty	11 Mar 2022 20:02:27 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,30 +0,0 @@
-Remove use of private internal macro; fixes compatibility problem with texlive
-https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=840189
-Index: latex/style/dbk_table.sty
---- latex/style/dbk_table.sty.orig
-+++ latex/style/dbk_table.sty
-@@ -9,7 +9,6 @@
- \usepackage{longtable}
- \usepackage{lscape}
- \usepackage{colortbl}
--\usepackage{multirow}
- \usepackage{calc}
- \usepackage{hhline}
-
-@@ -20,16 +19,6 @@
- \expandafter\renewcommand\expandafter\multicolumn
-   \expandafter[\expandafter3\expandafter]\expandafter{%
-   \multicolumn{#1}{#2}{#3}}
--
--% Make \@xmultirow long
--\expandafter\long\expandafter\def%
--\expandafter\@xmultirow%
--\expandafter#\expandafter1%
--\expandafter[\expandafter#\expandafter2\expandafter]%
--\expandafter#\expandafter3%
--\expandafter[\expandafter#\expandafter4\expandafter]%
--\expandafter#\expandafter5%
--\expandafter{\@xmultirow{#1}[#2]{#3}[#4]{#5}}
-
- % For the newtbl code
- \newdimen\newtblstarfactor%
Index: patches/patch-lib_dbtexmf_core_dbtex_py
===================================================================
RCS file: patches/patch-lib_dbtexmf_core_dbtex_py
diff -N patches/patch-lib_dbtexmf_core_dbtex_py
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-lib_dbtexmf_core_dbtex_py	16 Jul 2025 14:44:05 -0000
@@ -0,0 +1,30 @@
+Index: lib/dbtexmf/core/dbtex.py
+--- lib/dbtexmf/core/dbtex.py.orig
++++ lib/dbtexmf/core/dbtex.py
+@@ -15,7 +15,8 @@ try:
+ except ImportError:
+     from urllib.request import pathname2url
+ import glob
+-import imp
++#import importlib.util
++import importlib
+ from optparse import OptionParser
+ from io import open
+
+@@ -541,13 +542,13 @@ class DbTexCommand:
+     def load_plugin(self, pathname):
+         moddir, modname = os.path.split(pathname)
+         try:
+-            filemod, path, descr = imp.find_module(modname, [moddir])
++            filemod, path, descr = importlib.util.find_spec(modname, [moddir])
+         except ImportError:
+             try:
+-                filemod, path, descr = imp.find_module(modname)
++                filemod, path, descr = importlib.util.find_spec(modname)
+             except ImportError:
+                 failed_exit("Error: '%s' module not found" % modname)
+-        mod = imp.load_module(modname, filemod, path, descr)
++        mod = importlib.import_module(modname, filemod, path, descr)
+         filemod.close()
+         return mod
+
Index: patches/patch-lib_dbtexmf_dblatex_grubber_bibtex_py
===================================================================
RCS file: patches/patch-lib_dbtexmf_dblatex_grubber_bibtex_py
diff -N patches/patch-lib_dbtexmf_dblatex_grubber_bibtex_py
--- patches/patch-lib_dbtexmf_dblatex_grubber_bibtex_py	11 Mar 2022 20:02:27 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,10 +0,0 @@
---- lib/dbtexmf/dblatex/grubber/bibtex.py.orig	Mon Apr  5 02:07:53 2010
-+++ lib/dbtexmf/dblatex/grubber/bibtex.py	Sun Nov 28 12:56:31 2010
-@@ -261,6 +261,7 @@ class BibTex(TexModule):
-         if len(self.bst_path) != 1:
-             os.environ["BSTINPUTS"] = string.join(self.bst_path +
-                 [os.getenv("BSTINPUTS", "")], ":")
-+        os.environ['TEXMFOUTPUT'] = dirname(self.base)
-         rc = subprocess.call(["bibtex", self.base])
-         if rc != 0:
-             msg.info(_("There were errors making the bibliography."))
Index: patches/patch-lib_dbtexmf_dblatex_grubber_index_py
===================================================================
RCS file: patches/patch-lib_dbtexmf_dblatex_grubber_index_py
diff -N patches/patch-lib_dbtexmf_dblatex_grubber_index_py
--- patches/patch-lib_dbtexmf_dblatex_grubber_index_py	11 Mar 2022 20:02:27 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,10 +0,0 @@
---- lib/dbtexmf/dblatex/grubber/index.py.orig	Mon Apr  5 02:07:53 2010
-+++ lib/dbtexmf/dblatex/grubber/index.py	Sun Nov 28 12:56:37 2010
-@@ -150,6 +150,7 @@ class Index(TexModule):
-             env = {}
-
-         msg.debug(" ".join(cmd))
-+        os.environ['TEXMFOUTPUT'] = dirname(self.pbase)
-         rc = subprocess.call(cmd)
-         if (rc != 0):
-             msg.error(_("could not make index %s") % self.target)
Index: patches/patch-lib_dbtexmf_dblatex_grubber_plugins_py
===================================================================
RCS file: patches/patch-lib_dbtexmf_dblatex_grubber_plugins_py
diff -N patches/patch-lib_dbtexmf_dblatex_grubber_plugins_py
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-lib_dbtexmf_dblatex_grubber_plugins_py	16 Jul 2025 14:44:05 -0000
@@ -0,0 +1,32 @@
+Index: lib/dbtexmf/dblatex/grubber/plugins.py
+--- lib/dbtexmf/dblatex/grubber/plugins.py.orig
++++ lib/dbtexmf/dblatex/grubber/plugins.py
+@@ -4,7 +4,8 @@
+ Mechanisms to dynamically load extra modules to help the LaTeX compilation.
+ All the modules must be derived from the TexModule class.
+ """
+-import imp
++#import importlib.util
++import importlib
+
+ from os.path import *
+ from dbtexmf.dblatex.grubber.msg import _, msg
+@@ -109,15 +110,15 @@ class Plugins (object):
+         if name in self.modules:
+             return 2
+         try:
+-            file, path, descr = imp.find_module(name, [""])
++            file, path, descr = importlib.util.find_spec(name, [""])
+         except ImportError:
+             if not self.path:
+                 return 0
+             try:
+-                file, path, descr = imp.find_module(name, self.path)
++                file, path, descr = importlib.util.find_spec(name, self.path)
+             except ImportError:
+                 return 0
+-        module = imp.load_module(name, file, path, descr)
++        module = importlib.import_module(name, file, path, descr)
+         file.close()
+         self.modules[name] = module
+         return 1
Index: patches/patch-lib_dbtexmf_xslt_xslt_py
===================================================================
RCS file: patches/patch-lib_dbtexmf_xslt_xslt_py
diff -N patches/patch-lib_dbtexmf_xslt_xslt_py
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ patches/patch-lib_dbtexmf_xslt_xslt_py	16 Jul 2025 14:44:05 -0000
@@ -0,0 +1,28 @@
+Index: lib/dbtexmf/xslt/xslt.py
+--- lib/dbtexmf/xslt/xslt.py.orig
++++ lib/dbtexmf/xslt/xslt.py
+@@ -2,19 +2,20 @@
+ # Very simple plugin loader for Xslt classes
+ #
+ import os
+-import imp
++#import importlib.util
++import importlib
+ import glob
+
+ def load(modname):
+     try:
+-        file, path, descr = imp.find_module(modname, [""])
++        file, path, descr = importlib.util.find_spec(modname, [""])
+     except ImportError:
+         try:
+-            file, path, descr = imp.find_module(modname,
++            file, path, descr = importlib.util.find_spec(modname,
+                                                 [os.path.dirname(__file__)])
+         except ImportError:
+             raise ValueError("Xslt '%s' not found" % modname)
+-    mod = imp.load_module(modname, file, path, descr)
++    mod = importlib.import_module(modname, file, path, descr)
+     file.close()
+     o = mod.Xslt()
+     return o
Index: patches/patch-setup_py
===================================================================
RCS file: /cvs/ports/textproc/dblatex/patches/patch-setup_py,v
diff -u -p -r1.2 patch-setup_py
--- patches/patch-setup_py	11 Mar 2022 20:02:27 -0000	1.2
+++ patches/patch-setup_py	16 Jul 2025 14:44:05 -0000
@@ -1,13 +1,14 @@
 Install the unzipped manpage in the right place.

---- setup.py.orig	Fri Sep 24 10:51:29 2010
-+++ setup.py	Fri Sep 24 10:52:44 2010
-@@ -405,7 +405,7 @@ if __name__ == "__main__":
-         data_files=[('share/dblatex', ['xsl', 'latex']),
+Index: setup.py
+--- setup.py.orig
++++ setup.py
+@@ -515,7 +515,7 @@ if __name__ == "__main__":
+         data_files=[('share/dblatex', ['xsl', 'latex', 'etc/schema']),
                      ('share/doc/dblatex', pdfdocs),
                      ('share/doc/dblatex', htmldoc),
 -                    ('share/man/man1', ['docs/manpage/dblatex.1.gz'])],
 +                    ('man/man1', ['docs/manpage/dblatex.1'])],
          scripts=['scripts/dblatex'],
-         cmdclass={'build_scripts': BuildScripts,
-                   'install': Install,
+         cmdclass={'build': Build,
+                   'build_scripts': BuildScripts,
Index: patches/patch-xsl_url_xsl
===================================================================
RCS file: patches/patch-xsl_url_xsl
diff -N patches/patch-xsl_url_xsl
--- patches/patch-xsl_url_xsl	11 Mar 2022 20:02:27 -0000	1.2
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,11 +0,0 @@
---- xsl/url.xsl.orig	Mon Apr  5 02:07:53 2010
-+++ xsl/url.xsl	Sat Nov 27 17:44:19 2010
-@@ -68,7 +68,7 @@
-   <xsl:variable name="url2">
-     <xsl:choose>
-       <!-- Behaviour depending on the texlive version -->
--      <xsl:when test="contains($texlive.version, '2009')">
-+      <xsl:when test="$texlive.version >= 2009">
-         <xsl:call-template name="string-replace">
-           <xsl:with-param name="string" select="$url"/>
-           <xsl:with-param name="from" select="'\'"/>