GNU bug report logs - #39647
[PATCH] gnu: Add unoconv.

Previous Next

Package: guix-patches;

Reported by: Tobias Geerinckx-Rice <me <at> tobias.gr>

Date: Mon, 17 Feb 2020 18:26:01 UTC

Severity: normal

Tags: patch

Done: Jakub Kądziołka <kuba <at> kadziolka.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 39647 in the body.
You can then email your comments to 39647 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#39647; Package guix-patches. (Mon, 17 Feb 2020 18:26:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Tobias Geerinckx-Rice <me <at> tobias.gr>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Mon, 17 Feb 2020 18:26:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: guix-patches <at> gnu.org
Subject: [PATCH] gnu: Add unoconv.
Date: Mon, 17 Feb 2020 19:25:09 +0100
* gnu/packages/libreoffice.scm (unoconv): New public variable.
---
 gnu/packages/libreoffice.scm | 55 +++++++++++++++++++++++++++++++++++-
 1 file changed, 54 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/libreoffice.scm b/gnu/packages/libreoffice.scm
index 04477e2082..5e9e5ebd40 100644
--- a/gnu/packages/libreoffice.scm
+++ b/gnu/packages/libreoffice.scm
@@ -31,11 +31,12 @@
 (define-module (gnu packages libreoffice)
   #:use-module (guix build-system glib-or-gtk)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system python)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses)
-                #:select (gpl2+ lgpl2.1+ lgpl3+ mpl1.1 mpl2.0
+                #:select (gpl2 gpl2+ lgpl2.1+ lgpl3+ mpl1.1 mpl2.0
                           non-copyleft x11-style bsd-3))
   #:use-module (guix packages)
   #:use-module (guix utils)
@@ -141,6 +142,58 @@ Plain Text, Gnumeric XML, Generic XML.  It also includes low-level parsers for
 CSV, CSS and XML.")
     (license mpl2.0)))
 
+(define-public unoconv
+  (package
+    (name "unoconv")
+    (version "0.9.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "unoconv" version))
+       (sha256
+        (base32 "0cb0bvyxib3xrj0jdgizhp6p057lr8kqnd3n921rin37ivcvz3ih"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'patch-find_offices
+           ;; find_offices is a convoluted cross-platform treasure hunt.
+           ;; Keep things simple and return the correct paths immediately.
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let* ((libreoffice (assoc-ref inputs "libreoffice")))
+               (substitute* "unoconv"
+                 (("def find_offices\\(\\):" match)
+                  (string-append
+                   match "\n"
+                   "    ret = []\n"
+                   "    office = Office("
+                   "'" libreoffice "/lib/libreoffice', "
+                   "'" libreoffice "/lib/libreoffice/program', "
+                   "'" libreoffice "/lib/libreoffice/program', "
+                   "'" libreoffice "/lib/libreoffice/program/pyuno.so', "
+                   "'" libreoffice "/bin/soffice', "
+                   "sys.executable, "
+                   "None)\n"
+                   "    ret.append(office)\n"
+                   "    return ret\n")))
+               #t))))))
+    (inputs
+     `(("libreoffice" ,libreoffice)))
+    (home-page "http://dag.wiee.rs/home-made/unoconv/")
+    (synopsis "Convert between any document format supported by LibreOffice")
+    (description
+     "Unoconv is a command-line utility to convert documents from any format
+that LibreOffice can import, to any format it can export.  It can be used for
+batch processing, and can apply custom style templates and filters.
+
+Unoconv can convert between over a hundred formats, including Open Document
+Format (@file{.odt}, @file{.ods}, @file{.odp})), Portable Document Format
+(@file{.pdf}), HTML and XHTML, RTF, DocBook (@file{.xml}), @file{.doc} and
+@file{.docx}), @file{.xls} and @file{.xlsx}).
+
+All required fonts must be installed on the converting system.")
+    (license gpl2)))
+
 (define-public librevenge
   (package
     (name "librevenge")
-- 
2.23.0





Information forwarded to guix-patches <at> gnu.org:
bug#39647; Package guix-patches. (Thu, 20 Feb 2020 20:47:01 GMT) Full text and rfc822 format available.

Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Jakub Kądziołka <kuba <at> kadziolka.net>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: guix-patches <at> gnu.org
Subject: Re: [PATCH] gnu: Add unoconv.
Date: Thu, 20 Feb 2020 21:47:28 +0100
[Message part 1 (text/plain, inline)]
Hi,

I tried to use the package in a `guix environment' and got:

~/guix% unoconv ~/Downloads/scheme-macro-phd.ps -o scheme-macro-phd.pdf
unoconv: format [jw4yj39s84jb4fkvqpsqwq-unoconv-0.9.0/bin/.unoconv-real] is not known to unoconv.

I feel like this might be an issue with the packaging. Does it work for
you?

On Mon, Feb 17, 2020 at 07:25:09PM +0100, Tobias Geerinckx-Rice wrote:
> +       (modify-phases %standard-phases
> +         (add-after 'unpack 'patch-find_offices
I think that the convention is to replace underscores by dashes in names
like these.

> +           ;; find_offices is a convoluted cross-platform treasure hunt.
> +           ;; Keep things simple and return the correct paths immediately.
> +           (lambda* (#:key inputs #:allow-other-keys)
> +             (let* ((libreoffice (assoc-ref inputs "libreoffice")))
> +               (substitute* "unoconv"
> +                 (("def find_offices\\(\\):" match)
> +                  (string-append
> +                   match "\n"
> +                   "    ret = []\n"
> +                   "    office = Office("
> +                   "'" libreoffice "/lib/libreoffice', "
> +                   "'" libreoffice "/lib/libreoffice/program', "
> +                   "'" libreoffice "/lib/libreoffice/program', "
> +                   "'" libreoffice "/lib/libreoffice/program/pyuno.so', "
> +                   "'" libreoffice "/bin/soffice', "
> +                   "sys.executable, "
> +                   "None)\n"
> +                   "    ret.append(office)\n"
> +                   "    return ret\n")))
> +               #t))))))
Wouldn't it be simpler to do

    return [Office(...)]

?
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#39647; Package guix-patches. (Fri, 21 Feb 2020 01:25:02 GMT) Full text and rfc822 format available.

Message #11 received at 39647 <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: Jakub Kądziołka <kuba <at> kadziolka.net>
Cc: 39647 <at> debbugs.gnu.org
Subject: Re: [PATCH] gnu: Add unoconv.
Date: Fri, 21 Feb 2020 02:24:32 +0100
[Message part 1 (text/plain, inline)]
Jakub!

Jakub Kądziołka 写道:
> unoconv: format 
> [jw4yj39s84jb4fkvqpsqwq-unoconv-0.9.0/bin/.unoconv-real] is not 
> known to unoconv.
>
> I feel like this might be an issue with the packaging. Does it 
> work for
> you?

I don't see how this could be related to packaging…  And it works 
just fine on my laptop:

[Message part 2 (text/plain, inline)]
me <at> lapdog $ guix env --{pure,ad-hoc} unoconv coreutils¹ grep¹ \
           -- unoconv test-file.odt

me <at> lapdog $ # a pretty .pdf file is born!
[Message part 3 (text/plain, inline)]
But fine, I'll try it on another machine:

[Message part 4 (text/plain, inline)]
me <at> server $ guix env --{pure,ad-hoc} unoconv coreutils grep \
           -- unoconv test-file.odt
…
[Message part 5 (text/plain, inline)]
—and here's where I must stop to thank you for reporting the 
BESTEST BUG of 2020.  Seriously.  This made my day.  I laughed!  I 
cried!

Let's take another look at your error:

[Message part 6 (text/plain, inline)]
% unoconv ~/Downloads/scheme-macro-phd.ps -o scheme-macro-phd.pdf
unoconv: format 
[jw4yj39s84jb4fkvqpsqwq-unoconv-0.9.0/bin/.unoconv-real] is not 
known to unoconv.
[Message part 7 (text/plain, inline)]
So…  it's obvious that unoconv is erroneously parsing argv0 as 
target format.  Indeed, on both my machines, using the explicit 
‘-f <format>’

[Message part 8 (text/plain, inline)]
guix <at> env $ unoconv -f pdf test-file.odt
[Message part 9 (text/plain, inline)]
returns success and a .pdf file.

So is the long /gnu/store/… name overflowing a buffer?  Perhaps 
the wrapper script is to blame?  Maybe I should look at the co—

[Message part 10 (text/plain, inline)]
       ### If no format was specified, probe it or provide it
       if not self.format:
           ### Check if the command is in the form odt2pdf
           l = sys.argv[0].split('2')
           if len(l) == 2:
               self.format = l[1]
[Message part 11 (text/plain, inline)]
Oh.  Oh my.

I'd like to bet that the character before 
‘jw4yj39s84jb4fkvqpsqwq-unoconv-0.9.0/’ in your store name is a 
‘2’.  Because that's what it is on my server.  By sheer chance, 
the store name on my lapdog has TWO 2s, and so unoconv chugs 
blissfully onward.

I'm not sure what kind of fix upstream will accept for this.  At 
least a length limit, surely.  In the mean time it's trivial to 
just substitute* this out, since we won't ship any foo2bar 
symlinks our this package anyway.

>> +         (add-after 'unpack 'patch-find_offices
> I think that the convention is to replace underscores by dashes 
> in names
> like these.

Then I gladly thwart it.

> Wouldn't it be simpler to do
>
>     return [Office(...)]
>
> ?

Yep.

My reasoning at the time was literally: ‘well…  I should closely 
emulate upstream style [they use ret = … and append()] because 
I've never written a Python in my life, and they have, so they 
obviously know what they're doing.’

Needless to say, I'm currently reconsidering that opinion.

Thanks,

T G-R

[1]: ‘coreutils’ & ‘grep’ are undeclared dependencies of ‘soffice’ 
— will fix, but not relevant here.
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#39647; Package guix-patches. (Fri, 21 Feb 2020 01:30:02 GMT) Full text and rfc822 format available.

Message #14 received at 39647 <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: 39647 <at> debbugs.gnu.org
Subject: Re: [PATCH] gnu: Add unoconv.
Date: Fri, 21 Feb 2020 02:29:35 +0100
[Message part 1 (text/plain, inline)]
Tobias Geerinckx-Rice 写道:
> I'm not sure what kind of fix upstream will accept for this.  At 
> least
> a length limit, surely.

…or to split just the basename, of course.  Not sure why that 
didn't occur to me before hitting send…

Kind regards,

T G-R
[signature.asc (application/pgp-signature, inline)]

Information forwarded to guix-patches <at> gnu.org:
bug#39647; Package guix-patches. (Fri, 21 Feb 2020 02:41:01 GMT) Full text and rfc822 format available.

Message #17 received at 39647 <at> debbugs.gnu.org (full text, mbox):

From: Tobias Geerinckx-Rice <me <at> tobias.gr>
To: 39647 <at> debbugs.gnu.org
Subject: [PATCH v2] gnu: Add unoconv.
Date: Fri, 21 Feb 2020 03:40:44 +0100
* gnu/packages/libreoffice.scm (unoconv): New public variable.
---

With a fix for the hash sniffing issue, and a simplified find_offices
substitution.

Kind regards,

T G-R

 gnu/packages/libreoffice.scm | 60 +++++++++++++++++++++++++++++++++++-
 1 file changed, 59 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/libreoffice.scm b/gnu/packages/libreoffice.scm
index 04477e2082..68bddf7e8d 100644
--- a/gnu/packages/libreoffice.scm
+++ b/gnu/packages/libreoffice.scm
@@ -31,11 +31,12 @@
 (define-module (gnu packages libreoffice)
   #:use-module (guix build-system glib-or-gtk)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system python)
   #:use-module (guix build-system trivial)
   #:use-module (guix download)
   #:use-module (guix git-download)
   #:use-module ((guix licenses)
-                #:select (gpl2+ lgpl2.1+ lgpl3+ mpl1.1 mpl2.0
+                #:select (gpl2 gpl2+ lgpl2.1+ lgpl3+ mpl1.1 mpl2.0
                           non-copyleft x11-style bsd-3))
   #:use-module (guix packages)
   #:use-module (guix utils)
@@ -141,6 +142,63 @@ Plain Text, Gnumeric XML, Generic XML.  It also includes low-level parsers for
 CSV, CSS and XML.")
     (license mpl2.0)))
 
+(define-public unoconv
+  (package
+    (name "unoconv")
+    (version "0.9.0")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "unoconv" version))
+       (sha256
+        (base32 "0cb0bvyxib3xrj0jdgizhp6p057lr8kqnd3n921rin37ivcvz3ih"))))
+    (build-system python-build-system)
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'stop-hash-sniffing
+           ;; Fixes <https://debbugs.gnu.org/cgi/bugreport.cgi?bug=39647#11>.
+           ;; Submitted upsteam: <https://github.com/unoconv/unoconv/pull/531>.
+           (lambda _
+             (substitute* "unoconv"
+               (("sys.argv\\[0\\]\\.split\\('2'\\)")
+                "os.path.basename(sys.argv[0]).split('2')"))
+             #t))
+         (add-after 'unpack 'patch-find_offices
+           ;; find_offices is a convoluted cross-platform treasure hunt.
+           ;; Keep things simple and return the correct paths immediately.
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let* ((libreoffice (assoc-ref inputs "libreoffice")))
+               (substitute* "unoconv"
+                 (("def find_offices\\(\\):" match)
+                  (string-append
+                   match "\n"
+                   "    return [Office("
+                   "'" libreoffice "/lib/libreoffice', "
+                   "'" libreoffice "/lib/libreoffice/program', "
+                   "'" libreoffice "/lib/libreoffice/program', "
+                   "'" libreoffice "/lib/libreoffice/program/pyuno.so', "
+                   "'" libreoffice "/bin/soffice', "
+                   "sys.executable, "
+                   "None)]\n")))
+               #t))))))
+    (inputs
+     `(("libreoffice" ,libreoffice)))
+    (home-page "http://dag.wiee.rs/home-made/unoconv/")
+    (synopsis "Convert between any document format supported by LibreOffice")
+    (description
+     "Unoconv is a command-line utility to convert documents from any format
+that LibreOffice can import, to any format it can export.  It can be used for
+batch processing and can apply custom style templates and filters.
+
+Unoconv converts between over a hundred formats, including Open Document
+Format (@file{.odt}, @file{.ods}, @file{.odp})), Portable Document Format
+(@file{.pdf}), HTML and XHTML, RTF, DocBook (@file{.xml}), @file{.doc} and
+@file{.docx}), @file{.xls} and @file{.xlsx}).
+
+All required fonts must be installed on the converting system.")
+    (license gpl2)))
+
 (define-public librevenge
   (package
     (name "librevenge")
-- 
2.25.1





Reply sent to Jakub Kądziołka <kuba <at> kadziolka.net>:
You have taken responsibility. (Sat, 22 Feb 2020 14:50:01 GMT) Full text and rfc822 format available.

Notification sent to Tobias Geerinckx-Rice <me <at> tobias.gr>:
bug acknowledged by developer. (Sat, 22 Feb 2020 14:50:01 GMT) Full text and rfc822 format available.

Message #22 received at 39647-done <at> debbugs.gnu.org (full text, mbox):

From: Jakub Kądziołka <kuba <at> kadziolka.net>
To: Tobias Geerinckx-Rice <me <at> tobias.gr>
Cc: 39647-done <at> debbugs.gnu.org
Subject: Re: [PATCH v2] gnu: Add unoconv.
Date: Sat, 22 Feb 2020 15:49:48 +0100
[Message part 1 (text/plain, inline)]
On Fri, Feb 21, 2020 at 03:40:44AM +0100, Tobias Geerinckx-Rice wrote:
> * gnu/packages/libreoffice.scm (unoconv): New public variable.
> ---
> 
> With a fix for the hash sniffing issue, and a simplified find_offices
> substitution.
> 
> Kind regards,
> 
> T G-R
> 
>  gnu/packages/libreoffice.scm | 60 +++++++++++++++++++++++++++++++++++-
>  1 file changed, 59 insertions(+), 1 deletion(-)
> 

LGTM, pushed as 582a79d3a9593d969757ec398c84ef8d63a94fb0.

Kind regards,
Jakub Kądziołka
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 22 Mar 2020 11:24:05 GMT) Full text and rfc822 format available.

This bug report was last modified 4 years and 7 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.