Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[SOLVED] fop2.0 and hyphenation
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
lindegur
Apprentice
Apprentice


Joined: 14 Aug 2004
Posts: 269
Location: Swiss mountains

PostPosted: Sat Jan 13, 2018 11:19 am    Post subject: [SOLVED] fop2.0 and hyphenation Reply with quote

I'd like to get rid of the following error when I run fop2:
Code:
SEVERE: Couldn't find hyphenation pattern for lang="en".

I did
Code:
emerge offo-hyphenation
that fixed this issue in the past.

I also played around with things as editing fop.xconf telling where the patterns are
Code:
 <key>hyphenation-dir</key>
  <value>/usr/share/offo-hyphenation/hyph</value>
</entry>

Nothing helped :(

Now I found in the debian forum https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=780579 that /usr/share/fop/lib/fop-hyph.jar might be empty.
(After emerge -1 atool) I checked this on my gentoo installation
Code:
aunpack -l /usr/share/fop/lib/fop-hyph.jar
---------  ---------- -----   ----
        0  01-13-2018 09:43   META-INF/
      374  01-13-2018 09:43   META-INF/MANIFEST.MF
---------                     -------
      374                     2 files
and yes also I have this empty. 8O
So the questions:
    Is this the bug?
    How to fix it? (modify ebuild)


Last edited by lindegur on Fri Jan 19, 2018 12:43 pm; edited 1 time in total
Back to top
View user's profile Send private message
lindegur
Apprentice
Apprentice


Joined: 14 Aug 2004
Posts: 269
Location: Swiss mountains

PostPosted: Sat Jan 13, 2018 2:02 pm    Post subject: Reply with quote

I understand the following: The xml files from offo-hyphenation are not directly used they are actually compiled into fop-hyph.jar
Re-emerging fop after offo-hyphenation got emerged did not help.

So I tried successfully the following hack:

    Exchange this file with the one in /usr/share/fop/lib

    Verify it
    Code:
    aunpack -l /usr/share/fop/lib/fop-hyph.jar
    Archive:  /usr/share/fop/lib/fop-hyph.jar
      Length      Date    Time    Name
    ---------  ---------- -----   ----
            0  02-23-2016 10:37   META-INF/
          214  02-23-2016 10:37   META-INF/MANIFEST.MF
       302070  02-22-2016 16:15   hyph/af.hyp
       121999  02-22-2016 16:15   hyph/as.hyp
       143149  02-22-2016 16:15   hyph/bg.hyp
       121999  02-22-2016 16:15   hyph/bn.hyp
       134596  02-22-2016 16:15   hyph/ca.hyp
       129126  02-22-2016 16:15   hyph/cop.hyp
       173302  02-22-2016 16:15   hyph/cs.hyp
       219414  02-22-2016 16:15   hyph/cy.hyp
       138002  02-22-2016 16:15   hyph/da.hyp
       334119  02-22-2016 16:15   hyph/de.hyp
       341144  02-22-2016 16:15   hyph/de_1901.hyp
       337599  02-22-2016 16:15   hyph/de_CH.hyp
       128589  02-22-2016 16:15   hyph/el.hyp
       139546  02-22-2016 16:15   hyph/el_Polyton.hyp
       197541  02-22-2016 16:15   hyph/en.hyp
       245387  02-22-2016 16:15   hyph/en_GB.hyp
       158610  02-22-2016 16:15   hyph/eo.hyp
       176871  02-22-2016 16:15   hyph/es.hyp
       175990  02-22-2016 16:15   hyph/et.hyp
       123703  02-22-2016 16:15   hyph/eu.hyp
       125381  02-22-2016 16:15   hyph/fi.hyp
       141201  02-22-2016 16:15   hyph/fr.hyp
       127049  02-22-2016 16:15   hyph/fur.hyp
       216166  02-22-2016 16:15   hyph/ga.hyp
       157989  02-22-2016 16:15   hyph/gl.hyp
       187982  02-22-2016 16:15   hyph/grc.hyp
       121903  02-22-2016 16:15   hyph/gu.hyp
       121967  02-22-2016 16:15   hyph/hi.hyp
       140745  02-22-2016 16:15   hyph/hr.hyp
       145565  02-22-2016 16:15   hyph/hsb.hyp
       140903  02-22-2016 16:15   hyph/hy.hyp
       131145  02-22-2016 16:15   hyph/ia.hyp
       126864  02-22-2016 16:15   hyph/id.hyp
       180705  02-22-2016 16:15   hyph/is.hyp
       126260  02-22-2016 16:15   hyph/it.hyp
       150376  02-22-2016 16:15   hyph/ka.hyp
       125302  02-22-2016 16:15   hyph/kmr.hyp
       122015  02-22-2016 16:15   hyph/kn.hyp
       126035  02-22-2016 16:15   hyph/la.hyp
       132937  02-22-2016 16:15   hyph/la_CL.hyp
       142629  02-22-2016 16:15   hyph/lt.hyp
       286724  02-22-2016 16:15   hyph/lv.hyp
       122235  02-22-2016 16:15   hyph/ml.hyp
       136090  02-22-2016 16:15   hyph/mn.hyp
       121967  02-22-2016 16:15   hyph/mr.hyp
       127065  02-22-2016 16:15   hyph/mul_ET.hyp
       513795  02-22-2016 16:15   hyph/nb.hyp
       305589  02-22-2016 16:15   hyph/nl.hyp
       513795  02-22-2016 16:15   hyph/nn.hyp
       124913  02-22-2016 16:15   hyph/oc.hyp
       121887  02-22-2016 16:15   hyph/or.hyp
       121819  02-22-2016 16:15   hyph/pa.hyp
       178507  02-22-2016 16:15   hyph/pl.hyp
       126350  02-22-2016 16:15   hyph/pms.hyp
       125376  02-22-2016 16:15   hyph/pt.hyp
       126688  02-22-2016 16:15   hyph/rm.hyp
       130590  02-22-2016 16:15   hyph/ro.hyp
       232344  02-22-2016 16:15   hyph/ru.hyp
       131506  02-22-2016 16:15   hyph/sa.hyp
       159080  02-22-2016 16:15   hyph/sk.hyp
       136793  02-22-2016 16:15   hyph/sl.hyp
       167784  02-22-2016 16:15   hyph/sr_Cyrl.hyp
       166484  02-22-2016 16:15   hyph/sr_Latn.hyp
       189898  02-22-2016 16:15   hyph/sv.hyp
       121906  02-22-2016 16:15   hyph/ta.hyp
       121999  02-22-2016 16:15   hyph/te.hyp
       184120  02-22-2016 16:15   hyph/th.hyp
       152578  02-22-2016 16:15   hyph/tk.hyp
       128717  02-22-2016 16:15   hyph/tr.hyp
       184506  02-22-2016 16:15   hyph/uk.hyp
       123659  02-22-2016 16:15   hyph/zh_Latn.hyp
    ---------                     -------
     12218853                     73 files


And finally fop runs without hyphenation error. :lol:

Now since I got the confirmation that the trouble is not on my fop hyphenation configuration I look for a clean and gentoo like solution.
Time to https://bugs.gentoo.org/? Or is there a step to let fop know about offo-hyphenation?

In fact, the offo-hyphenation ebuild has:
Code:
elog "To compile the patterns, install dev-java/fop with USE=hyphenation."
   elog "Alternatively, use the uncompiled patterns via the <hyphenation-base>"
   elog "configuration option. See the documentation for more details."

However fop has no more a "hyphenation" useflag. So I need to test the alternative way.
Back to top
View user's profile Send private message
lindegur
Apprentice
Apprentice


Joined: 14 Aug 2004
Posts: 269
Location: Swiss mountains

PostPosted: Tue Jan 16, 2018 5:46 pm    Post subject: Reply with quote

I tried to modify the ebuild. It finds the en.xml file and starts processing it but then a error comes:
Code:
compile:

compile-hyphenation:
    [mkdir] Created dir: /var/tmp/portage/dev-java/fop-2.0-r999/work/fop-2.0/build/classes/hyph
     [java] Processing /var/tmp/portage/dev-java/fop-2.0-r999/work/fop-2.0/hyph/en.xml
     [java] Exception in thread "main" java.lang.StackOverflowError
     [java]    at org.apache.fop.hyphenation.TernaryTree.insert(TernaryTree.java:180)

I have to admit, my java know how is far to low to troubleshoot and fix this. :oops:

Download fop source and try compiling it with ant fails
Code:
ant
Buildfile: /home/lindegur/fop/fop-2.0/build.xml
Trying to override old definition of task javac

init-avail:
     [echo] ------------------- Apache FOP 2.0 [1999-2015] ----------------
     [echo] See build.properties and build-local.properties for additional build settings
     [echo] Apache Ant(TM) version 1.9.1 compiled on December 17 2017
     [echo] VM: 25.151-b12, Oracle Corporation
     [echo] JAVA_HOME: /opt/icedtea-bin-3.6.0
     [echo] JAI Support NOT Present
     [echo] JCE Support PRESENT
     [echo] JUnit Support NOT Present - Committers are required to have JUnit working
     [echo] XMLUnit Support NOT Present - you can get it from http://xmlunit.sourceforge.net

Java JDK is supposed to be required. Gentoo has oracle-jdk-bin a bin package that needs to be downloaded manually and accepting a special licenses and following the link does not lead to the desired binary :evil:

Downloading as regular user the fop binary and adding fop-hyph.jar to the lib directory. Works well (even for fop-2.1 and fop-2.2). So I would be able doing fop-bin ebuild(s). Sorry about mentioning this option :roll:

Ok there is still the options to try the <hyphenation-base>. Currently I do not know where to set this?


Last edited by lindegur on Sat Jan 20, 2018 1:39 pm; edited 1 time in total
Back to top
View user's profile Send private message
lindegur
Apprentice
Apprentice


Joined: 14 Aug 2004
Posts: 269
Location: Swiss mountains

PostPosted: Tue Jan 16, 2018 7:16 pm    Post subject: Reply with quote

:lol: Ok I got it :lol:
In fop build.xml the hyph.stacksize value must be increased and then it compiles fine.
Code:
aunpack -l /var/tmp/portage/dev-java/fop-2.0-r999/image/usr/share/fop/lib/fop-hyph.jar
Archive:  /var/tmp/portage/dev-java/fop-2.0-r999/image/usr/share/fop/lib/fop-hyph.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  01-16-2018 20:08   META-INF/
      371  01-16-2018 20:08   META-INF/MANIFEST.MF
        0  01-16-2018 20:08   hyph/
   197541  01-16-2018 20:08   hyph/en.hyp
---------                     -------
   197912                     4 files

A patch can modify this file and then the source ebuild works hopefully :( .
It is late at night so I do it an other day. :roll:
Back to top
View user's profile Send private message
lindegur
Apprentice
Apprentice


Joined: 14 Aug 2004
Posts: 269
Location: Swiss mountains

PostPosted: Fri Jan 19, 2018 1:00 pm    Post subject: Reply with quote

Ebuild modified and tested. Here the relevant lines from it:
Code:

EAPI="5"
JAVA_PKG_IUSE="doc examples source test"
inherit eutils java-pkg-2 java-ant-2

DESCRIPTION="Formatting Objects Processor is a print formatter driven by XSL"
HOMEPAGE="https://xmlgraphics.apache.org/fop/"
SRC_URI="mirror://apache/xmlgraphics/${PN}/source/${P}-src.zip"

KEYWORDS="amd64 ppc64 x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~sparc-solaris ~x86-solaris"
LICENSE="Apache-2.0"
SLOT="0"
IUSE="hyphenation"

# Tests are broken even in 2.0
RESTRICT="test"

CDEPEND="
   dev-java/batik:1.9
   dev-java/ant-core:0
   dev-java/fontbox:1.7
   dev-java/commons-io:1
   dev-java/commons-logging:0
   java-virtuals/servlet-api:3.0
   dev-java/avalon-framework:4.2
   dev-java/xmlgraphics-commons:2
   dev-java/xml-commons-external:1.3
   dev-java/qdox:1.12
        "
RDEPEND=">=virtual/jre-1.6
   ${CDEPEND}"

DEPEND=">=virtual/jdk-1.6
   app-arch/unzip

        hyphenation? (
                >=dev-java/offo-hyphenation-2.0
        )

   ${CDEPEND}"

JAVA_ANT_ENCODING="ISO-8859-1"
JAVA_ANT_REWRITE_CLASSPATH="true"

EANT_GENTOO_CLASSPATH="
   ant-core
   batik-1.9
   fontbox-1.7
   commons-io-1
   commons-logging
   servlet-api-3.0
   avalon-framework-4.2
   xmlgraphics-commons-2
   xml-commons-external-1.3
"

TARGETS=(
   resourcegen
   jar-hyphenation
   jar-sandbox
   jar-main
)

java_prepare() {
   find "${S}"/lib -type f | xargs rm -v
}

src_configure() {

 if use hyphenation; then
  elog "make hyphenation xml patterns available"
  rm -r ${WORKDIR}/${P}/hyph
  ln -s /usr/share/offo-hyphenation/hyph/ ${WORKDIR}/${P}/hyph

  einfo "increase stack for hyphenation"
  sed -i -e 's/512k/2048k/g' build.xml || \
  die "sed broke"
  elog "aunpack -l /usr/share/fop/lib/fop-hyph.jar shows what hyphenation patterns are now compiled to fop"

 fi

}

src_compile() {
   # https://bugs.gentoo.org/show_bug.cgi?id=554386
   # http://wiki.apache.org/xmlgraphics-fop/HowTo/BuildFOPAlternatively
   java-pkg_jar-from --into lib qdox-1.12 qdox.jar
   java-pkg_jar-from --into lib xmlgraphics-commons-2 xmlgraphics-commons.jar
   java-pkg_jar-from --into lib commons-logging commons-logging.jar
   java-pkg_jar-from --into lib commons-io-1 commons-io.jar
   java-pkg_jar-from --into lib fontbox-1.7 fontbox.jar
   java-pkg_jar-from --into lib xml-commons-external-1.3 xml-apis-ext.jar
   java-pkg_jar-from --into lib xml-commons-external-1.3 xml-apis.jar
   java-pkg_jar-from --into lib avalon-framework-4.2 avalon-framework.jar
   java-pkg_jar-from --virtual --into lib servlet-api-3.0 servlet-api.jar

   for target in ${TARGETS[@]}; do
      EANT_BUILD_TARGET="${target}" \
         java-pkg-2_src_compile
   done

   if use doc; then
      sed -i -e 's/failonerror=\"true\"/failonerror=\"false\"/;' ./build.xml
      EANT_BUILD_TARGET="javadocs" \
         java-pkg-2_src_compile
   fi
       
}

src_install() {
   java-pkg_dojar \
      build/${PN}.jar \
      build/${PN}-sandbox.jar \
      build/${PN}-hyph.jar

   java-pkg_dolauncher \
      ${PN} --main org.apache.fop.cli.Main \
      -pre "${FILESDIR}/headless-launcher.bash"

   dodoc NOTICE README

   if use doc; then
      java-pkg_dojavadoc \
         build/javadocs
   fi

   if use examples; then
      java-pkg_doexamples \
         examples/* conf
   fi

   if use source; then
      java-pkg_dosrc \
         src/java/org \
         src/sandbox/org
   fi
    
}


I added r100 to the name to avoid conflicts between the overlay and the official portage ebuilds.
Further I reactivated the useflag hyphenation support. Setting this useflag is required to get hyphenation.
I did not file a bug to https://bugs.gentoo.org/ since hyphenation can also be understood as additional feature.
The ebuild can be found on my overlay http://www.linurs.org/overlay.git/linurs.xml
Here how to install it:http://www.linurs.org/linux/Overlays.html#LinursOverlay

In this overlay I added also experimental binary fop versions: fop-bin-2.0, fop-bin-2.1, fop-bin-2.2, offo-hyphenation-bin-2.2
I also added offo-hyphenation-2.2 source version to it.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum