gnu: docbook-xsl: Refactor package.
* gnu/packages/docbook.scm (docbook-xsl)[source]: Patch in snippet. [arguments]: Use sxml representation for xmlc file. Use xmlcatalog to manipulate catalog.xml instead of substitute*. Use #:install-plan instead of replacing 'install phase. [native-inputs]: Add docbook-xml-4.4 and libxml2, required for tests. Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
This commit is contained in:
parent
77404fd0aa
commit
d55feb010d
@ -205,9 +205,16 @@ by no means limited to these applications.) This package provides XML DTDs.")
|
|||||||
(url "https://github.com/docbook/xslt10-stylesheets")
|
(url "https://github.com/docbook/xslt10-stylesheets")
|
||||||
(commit commit)))
|
(commit commit)))
|
||||||
(file-name (git-file-name name version))
|
(file-name (git-file-name name version))
|
||||||
;; Multiple .jar files are bundled with the sources.
|
|
||||||
(modules '((guix build utils)))
|
(modules '((guix build utils)))
|
||||||
(snippet '(for-each delete-file (find-files "." "\\.jar$")))
|
(snippet
|
||||||
|
#~(begin
|
||||||
|
;; Multiple .jar files are bundled with the sources.
|
||||||
|
(for-each delete-file
|
||||||
|
(find-files "." "\\.jar$"))
|
||||||
|
;; Do not build webhelp files, as they require a Saxon from
|
||||||
|
;; 2005, which is not packaged in Guix.
|
||||||
|
(substitute* "xsl/Makefile"
|
||||||
|
((" webhelp") ""))))
|
||||||
(sha256
|
(sha256
|
||||||
(base32
|
(base32
|
||||||
"1bl8dwrcy7skrlh80fpsmiw045bv2j0aym231ikcv3hvm2pi98dj"))))
|
"1bl8dwrcy7skrlh80fpsmiw045bv2j0aym231ikcv3hvm2pi98dj"))))
|
||||||
@ -215,8 +222,13 @@ by no means limited to these applications.) This package provides XML DTDs.")
|
|||||||
(arguments
|
(arguments
|
||||||
(list
|
(list
|
||||||
#:make-flags #~(list "XSLTENGINE=xsltproc")
|
#:make-flags #~(list "XSLTENGINE=xsltproc")
|
||||||
|
#:modules '((guix build gnu-build-system)
|
||||||
|
(guix build utils)
|
||||||
|
(sxml simple))
|
||||||
#:phases
|
#:phases
|
||||||
#~(modify-phases %standard-phases
|
#~(let ((dest-path (format #f "~a/xml/xsl/~a-~a"
|
||||||
|
#$output #$name #$version)))
|
||||||
|
(modify-phases %standard-phases
|
||||||
(replace 'configure
|
(replace 'configure
|
||||||
(lambda _
|
(lambda _
|
||||||
;; The build systems insist on a ~/.xmlc, and it is simpler to
|
;; The build systems insist on a ~/.xmlc, and it is simpler to
|
||||||
@ -225,57 +237,91 @@ by no means limited to these applications.) This package provides XML DTDs.")
|
|||||||
(setenv "HOME" "/tmp")
|
(setenv "HOME" "/tmp")
|
||||||
(call-with-output-file "/tmp/.xmlc"
|
(call-with-output-file "/tmp/.xmlc"
|
||||||
(lambda (port)
|
(lambda (port)
|
||||||
(format port "\
|
(sxml->xml
|
||||||
<?xml version='1.0' encoding='utf-8'?> <!-- -*- nxml -*- -->
|
'(*TOP*
|
||||||
<config>
|
(*PI* xml "version='1.0'")
|
||||||
<java xml:id=\"bigmem\">
|
(config
|
||||||
<java-option name=\"Xmx512m\"/>
|
(java (@ (xml:id "bigmem"))
|
||||||
</java>
|
(java-options (@ (name "Xmx512m"))))
|
||||||
<xsltproc xml:id=\"xsltproc\" exec=\"xsltproc\"></xsltproc>
|
(xsltproc (@ (xml:id "xsltproc")
|
||||||
<xmllint xml:id=\"xmllint\" exec=\"xmllint\"></xmllint>
|
(exec "xsltproc")))
|
||||||
</config>\n")))
|
(xmllint (@ (xml:id "xmllint")
|
||||||
(substitute* "xsl/Makefile"
|
(exec "xmllint")))))
|
||||||
;; Do not build webhelp files, as they require a Saxon from
|
port)))))
|
||||||
;; 2005, which is not packaged in Guix.
|
|
||||||
((" webhelp") ""))))
|
|
||||||
(add-before 'install 'generate-catalog.xml
|
(add-before 'install 'generate-catalog.xml
|
||||||
(lambda* (#:key make-flags #:allow-other-keys)
|
(lambda* (#:key make-flags #:allow-other-keys)
|
||||||
(apply invoke "make" "-C" "xsl" "catalog.xml" make-flags)))
|
(apply invoke "make" "-C" "xsl" "catalog.xml" make-flags)))
|
||||||
|
(add-before 'install 'patch-catalog-xml
|
||||||
|
(lambda* (#:key inputs #:allow-other-keys)
|
||||||
|
(let ((xmlcatalog (search-input-file inputs
|
||||||
|
"/bin/xmlcatalog"))
|
||||||
|
(catalog-files (find-files "." "catalog\\.xml$"))
|
||||||
|
(store-uri (string-append "file://" dest-path "/")))
|
||||||
|
(for-each
|
||||||
|
(lambda (catalog)
|
||||||
|
;; Replace /snapshot/ reference with one based on
|
||||||
|
;; BASE-VERSION.
|
||||||
|
(let ((versioned-uri
|
||||||
|
(format
|
||||||
|
#f "https://cdn.docbook.org/release/xsl/~a/"
|
||||||
|
#$base-version)))
|
||||||
|
(invoke xmlcatalog "--noout"
|
||||||
|
"--del"
|
||||||
|
"https://cdn.docbook.org/release/xsl/snapshot/"
|
||||||
|
catalog)
|
||||||
|
(for-each
|
||||||
|
(lambda (type)
|
||||||
|
(invoke xmlcatalog "--noout"
|
||||||
|
"--add" type
|
||||||
|
versioned-uri
|
||||||
|
store-uri
|
||||||
|
catalog))
|
||||||
|
(list "rewriteSystem" "rewriteURI")))
|
||||||
|
|
||||||
|
;; Patch /current/ references to point to /gnu/store/….
|
||||||
|
(for-each
|
||||||
|
(lambda (type)
|
||||||
|
(invoke xmlcatalog "--noout"
|
||||||
|
"--add" type
|
||||||
|
"https://cdn.docbook.org/release/xsl/current/"
|
||||||
|
store-uri
|
||||||
|
catalog))
|
||||||
|
(list "rewriteSystem" "rewriteURI"))
|
||||||
|
|
||||||
|
;; Re-add the no longer present compatibility entries for
|
||||||
|
;; v.1.79.1 or earlier URIs.
|
||||||
|
(for-each
|
||||||
|
(lambda (type)
|
||||||
|
(invoke xmlcatalog "--noout"
|
||||||
|
"--add" type
|
||||||
|
"http://docbook.sourceforge.net/release/xsl/current/"
|
||||||
|
store-uri
|
||||||
|
catalog))
|
||||||
|
(list "rewriteSystem" "rewriteURI")))
|
||||||
|
catalog-files))))
|
||||||
(replace 'install
|
(replace 'install
|
||||||
(lambda _
|
(lambda _
|
||||||
(let ((xml (string-append #$output "/xml/xsl/"
|
(let ((select-rx (make-regexp
|
||||||
#$name "-" #$version))
|
|
||||||
(select-rx (make-regexp
|
|
||||||
"(\\.xml$|\\.xsl$|\\.dtd$|\\.ent$)")))
|
"(\\.xml$|\\.xsl$|\\.dtd$|\\.ent$)")))
|
||||||
;; Install catalog.
|
;; Install catalog.
|
||||||
(chdir "xsl")
|
(chdir "xsl")
|
||||||
(install-file "catalog.xml" xml)
|
(install-file "catalog.xml" dest-path)
|
||||||
(install-file "VERSION.xsl" xml)
|
(install-file "VERSION.xsl" dest-path)
|
||||||
(substitute* (string-append xml "/catalog.xml")
|
|
||||||
;; Re-add the no longer present compatibility entries.
|
|
||||||
((".*</catalog>.*" anchor)
|
|
||||||
(string-append "\
|
|
||||||
<!-- Also support old URI of v1.79.1 or earlier -->
|
|
||||||
<rewriteURI uriStartString=\"http://docbook.sourceforge.net\
|
|
||||||
/release/xsl/current/\" rewritePrefix=\"./\"/>
|
|
||||||
<rewriteSystem systemIdStartString=\"http://docbook.sourceforge.net\
|
|
||||||
/release/xsl/current/\" rewritePrefix=\"./\"/>\n" anchor))
|
|
||||||
(("/snapshot/")
|
|
||||||
(string-append "/" #$base-version "/"))
|
|
||||||
(("rewritePrefix=\"./")
|
|
||||||
(string-append "rewritePrefix=\"file://" xml "/")))
|
|
||||||
;; Install style sheets.
|
;; Install style sheets.
|
||||||
(for-each (lambda (dir)
|
(for-each
|
||||||
|
(lambda (dir)
|
||||||
(for-each (lambda (f)
|
(for-each (lambda (f)
|
||||||
(install-file
|
(install-file
|
||||||
f (string-append xml "/" (dirname f))))
|
f
|
||||||
|
(string-append dest-path "/" (dirname f))))
|
||||||
(find-files dir select-rx)))
|
(find-files dir select-rx)))
|
||||||
'("assembly" "common" "eclipse" "epub" "epub3" "fo"
|
'("assembly" "common" "eclipse" "epub" "epub3" "fo"
|
||||||
"highlighting" "html" "htmlhelp" "javahelp" "lib"
|
"highlighting" "html" "htmlhelp" "javahelp" "lib"
|
||||||
"manpages" "params" "profiling" "roundtrip"
|
"manpages" "params" "profiling" "roundtrip"
|
||||||
"template" "website"
|
"template" "website"
|
||||||
"xhtml" "xhtml-1_1" "xhtml5"))))))))
|
"xhtml" "xhtml-1_1" "xhtml5")))))))))
|
||||||
(native-inputs (list libxml2
|
(native-inputs (list docbook-xml-4.4 ; for tests
|
||||||
|
libxml2
|
||||||
libxslt
|
libxslt
|
||||||
perl
|
perl
|
||||||
perl-xml-xpath))
|
perl-xml-xpath))
|
||||||
|
Loading…
Reference in New Issue
Block a user