diff mbox series

[bug#57337,2/2] gnu: Add docxbox.

Message ID 20220822093651.31574-2-wz@freeshell.de
State New
Headers show
Series Add docxbox | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success
cbaines/issue success View issue
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

Wiktor Żelazny Aug. 22, 2022, 9:36 a.m. UTC
From: Wiktor Żelazny <wzelazny@vurv.cz>

* gnu/packages/textutils.scm (docxbox): New variable.
---
 gnu/packages/textutils.scm | 73 ++++++++++++++++++++++++++++++++++++--
 1 file changed, 71 insertions(+), 2 deletions(-)

Comments

Ludovic Courtès Sept. 8, 2022, 12:49 p.m. UTC | #1
Wiktor Żelazny <wz@freeshell.de> skribis:

> From: Wiktor Żelazny <wzelazny@vurv.cz>
>
> * gnu/packages/textutils.scm (docxbox): New variable.

[...]

> +              (snippet '(begin
> +                          (for-each delete-file-recursively
> +                                    '("bin" "vendor/json" "vendor/miniz-cpp"
> +                                      "vendor/tinyxml2")) #t))))

You can remove the trailing #t, it’s no longer necessary.

> +    (build-system cmake-build-system)
> +    ;; (native-inputs (list bats)) ; Enable after fixing tests, use bash module
> +    (inputs `(("json-modern-cxx-source" ,(package-source json-modern-cxx))
> +              ("miniz-cpp-source" ,(package-source miniz-cpp))
> +              ("tinyxml2-source" ,(package-source tinyxml2))))

I’d suggest using the new style, which is to refer to those right in the
code, like so:

  (arguments
    (list #:phases #~(modify-phases …
                       …
                       (invoke "tar" "xf" #$(package-source whatever)))))

However, it would be best if, instead of re-building those three
libraries, docxbox would instead link against the .so provided by their
respective packages.

> +    (synopsis "CLI tool for MS Word DOCX templating and analysis")

s/CLI/Command-line/ (in general, avoid acronyms)

s/DOCX/@file{.docx}/ I would say.

Could you send updated patches?

Thanks,
Ludo’.
Wiktor Żelazny Sept. 23, 2022, 6:04 p.m. UTC | #2
On Thu, Sep 08, 2022 at 02:49:15PM +0200, Ludovic Courtès wrote:
> Wiktor Żelazny <wz@freeshell.de> skribis:
>
> > * gnu/packages/textutils.scm (docxbox): New variable.
>
> Could you send updated patches?

I will see what I can do about this one.

WŻ
diff mbox series

Patch

diff --git a/gnu/packages/textutils.scm b/gnu/packages/textutils.scm
index 7898d520f0..41a75c727d 100644
--- a/gnu/packages/textutils.scm
+++ b/gnu/packages/textutils.scm
@@ -18,7 +18,7 @@ 
 ;;; Copyright © 2018 Meiyo Peng <meiyo.peng@gmail.com>
 ;;; Copyright © 2019 Yoshinori Arai <kumagusu08@gmail.com>
 ;;; Copyright © 2019 Mădălin Ionel Patrașcu <madalinionel.patrascu@mdc-berlin.de>
-;;; Copyright © 2019 Wiktor Żelazny <wzelazny@vurv.cz>
+;;; Copyright © 2019, 2022 Wiktor Żelazny <wzelazny@vurv.cz>
 ;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Jean-Baptiste Volatier <jbv@pm.me>
 ;;; Copyright © 2021 Simon Tournier <zimon.toutoune@gmail.com>
@@ -58,6 +58,7 @@  (define-module (gnu packages textutils)
   #:use-module (gnu packages autotools)
   #:use-module (gnu packages base)
   #:use-module (gnu packages compression)
+  #:use-module (gnu packages cpp)
   #:use-module (gnu packages gcc)
   #:use-module (gnu packages golang)
   #:use-module (gnu packages gettext)
@@ -73,7 +74,8 @@  (define-module (gnu packages textutils)
   #:use-module (gnu packages ruby)
   #:use-module (gnu packages slang)
   #:use-module (gnu packages syncthing)
-  #:use-module (gnu packages web))
+  #:use-module (gnu packages web)
+  #:use-module (gnu packages xml))
 
 (define-public dos2unix
   (package
@@ -1502,3 +1504,70 @@  (define-public ack
 easily specify file types, match highlighting, Perl-Compatible Regular
 Expressions, and being faster to type than grep.")
     (license license:artistic2.0)))
+
+(define-public docxbox
+  (package
+    (name "docxbox")
+    (version "0.0.5")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append
+                    "https://github.com/gyselroth/docxbox/archive/refs/tags/"
+                    version ".tar.gz"))
+              (sha256
+               (base32
+                "19ik3jhyyk26bj8x2adaxwwj8l4sg1h2kf2d0hw43yhsqki176cb"))
+              (modules '((guix build utils)))
+              (snippet '(begin
+                          (for-each delete-file-recursively
+                                    '("bin" "vendor/json" "vendor/miniz-cpp"
+                                      "vendor/tinyxml2")) #t))))
+    (build-system cmake-build-system)
+    ;; (native-inputs (list bats)) ; Enable after fixing tests, use bash module
+    (inputs `(("json-modern-cxx-source" ,(package-source json-modern-cxx))
+              ("miniz-cpp-source" ,(package-source miniz-cpp))
+              ("tinyxml2-source" ,(package-source tinyxml2))))
+    (arguments
+     `(#:phases (modify-phases %standard-phases
+                  (add-after 'unpack 'unpack-json-modern-cxx
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (mkdir-p "vendor/json-modern-cxx")
+                      (copy-recursively (assoc-ref inputs
+                                                   "json-modern-cxx-source")
+                                        "vendor/json") #t))
+                  (add-after 'unpack 'unpack-miniz-cpp
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (mkdir-p "vendor/miniz-cpp")
+                      (copy-recursively (assoc-ref inputs "miniz-cpp-source")
+                                        "vendor/miniz-cpp") #t))
+                  (add-after 'unpack 'unpack-tinyxml2
+                    (lambda* (#:key inputs #:allow-other-keys)
+                      (mkdir-p "vendor/tinyxml2")
+                      (copy-recursively (assoc-ref inputs "tinyxml2-source")
+                                        "vendor/tinyxml2") #t))
+                  (replace 'install
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (let* ((out (assoc-ref outputs "out"))
+                             (bin (string-append out "/usr/bin")))
+                        (install-file "bin/linux/docxbox" bin)))))
+       #:configure-flags (let* ((out (assoc-ref %outputs "out")))
+                           '("-DCMAKE_CXX_FLAGS=-fpermissive -Wno-error"))
+       ;; Tests depend on a bundled binary in bin/linux/, and even with the
+       ;; binary in place, I could not get them to run. To my understanding,
+       ;; the setup() function in test/functional/_helper.bash is supposed to
+       ;; copy the binary to the test suite directory. However, this does not
+       ;; seem to happen when invoking ./test.sh (make check is not
+       ;; supported), and the script complains about the missing binary in the
+       ;; directory. The fix could be to copy the binary built by the Guix
+       ;; daemon to the test suite directory before invoking ./test.sh, but
+       ;; this is beyond my skills.
+       #:tests? #f))
+    (home-page "https://github.com/gyselroth/docxbox/")
+    (synopsis "CLI tool for MS Word DOCX templating and analysis")
+    (description
+     "@command{docxbox} enables direct and convenient inspection and
+manipulation of XML and media files making up a DOCX file.  The
+capabilities include batch editing, unpacking and indentation for manual
+editing in a text editor and subsequent unindentation and repacking,
+operations on metadata, and diffing")
+    (license license:expat)))