unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#38616] emacs: fix odt export
@ 2019-12-14 23:45 Nicolò Balzarotti
  2019-12-15 14:23 ` Jelle Licht
  2019-12-15 15:07 ` [bug#38616] [Nicolò Balzarotti] [bug#38616] " Nicolò Balzarotti
  0 siblings, 2 replies; 5+ messages in thread
From: Nicolò Balzarotti @ 2019-12-14 23:45 UTC (permalink / raw)
  To: 38616

[-- Attachment #1: Type: text/plain, Size: 1334 bytes --]


Hello Guix!

Neither on NixOS or in guix I've ever been able to export an org file to
otd. The error was
'OpenDocument export failed: Buffer is read-only: #<killed buffer>'.

I've seen some report of this error on the web, like:
- https://lists.gnu.org/archive/html/emacs-orgmode/2018-05/msg00545.html
- https://github.com/syl20bnr/spacemacs/issues/1482

but also on our IRC:
- http://logs.guix.gnu.org/guix/2019-05-07.log
- http://logs.guix.gnu.org/guix/2019-07-25.log
but I was not able to find a fix for it.

Today I checked the source and figured it out. The explanation, as
written in the patch, is the following

> Files inside the guix store are read only. "styles.xml" is copied from the
> store (/share/emacs/26.3/etc/org/OrgOdtStyles.xml), so it's read only too.
> ox-odt needs this file, so if it's not writable it will fail. This patch
> adjust the permissions.

So, this patches fixes the permissions on the file.

I've two questions:
1. Is it fine to have a .patch, or should I add a phase where I fix the
   file? this seemed to be easier
2. If the same error happens for other programs, might it make sense to
   "fake" rw permissions in the store (by using a virtual fs or
   something) so that files are copied as rw, but files in the store are
   still ro?

Thanks!

Nicolò


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-gnu-packages-emascs.scm-emacs-patches-Fix-odt-export.patch --]
[-- Type: text/x-patch, Size: 2547 bytes --]

From c1ad3fff9bda5935651f26e460907a77d1b3d003 Mon Sep 17 00:00:00 2001
From: nixo <nicolo@nixo.xyz>
Date: Sat, 14 Dec 2019 15:17:11 +0100
Subject: [PATCH] * gnu/packages/emascs.scm (emacs)[patches]: Fix odt export.

ox-odt copyes the file /share/emacs/26.3/etc/org/OrgOdtStyles.xml under
/tmp/odt-*/styles.xml and tries to modify it.  Since files in the guix store
are read-only, it will fail.  This patch fixes the export by adjusting
permissions during the export.
---
 gnu/packages/emacs.scm                        |  1 +
 .../patches/emacs-fix-odt-export.patch        | 25 +++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-fix-odt-export.patch

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index eba7f88551..8183b69eb3 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -80,6 +80,7 @@
                "119ldpk7sgn9jlpyngv5y4z3i7bb8q3xp4p0qqi7i5nq39syd42d"))
              (patches (search-patches "emacs-exec-path.patch"
                                       "emacs-fix-scheme-indent-function.patch"
+                                      "emacs-fix-odt-export.patch"
                                       "emacs-source-date-epoch.patch"))
              (modules '((guix build utils)))
              (snippet
diff --git a/gnu/packages/patches/emacs-fix-odt-export.patch b/gnu/packages/patches/emacs-fix-odt-export.patch
new file mode 100644
index 0000000000..0c3c44a2e3
--- /dev/null
+++ b/gnu/packages/patches/emacs-fix-odt-export.patch
@@ -0,0 +1,25 @@
+Files inside the guix store are read only. "styles.xml" is copied from the
+store (/share/emacs/26.3/etc/org/OrgOdtStyles.xml), so it's read only too.
+ox-odt needs this file, so if it's not writable it will fail. This patch
+adjust the permissions.
+
+---
+ lisp/org/ox-odt.el | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el
+index f9c4a93cc8..61988ffcc4 100644
+--- a/lisp/org/ox-odt.el
++++ b/lisp/org/ox-odt.el
+@@ -1384,6 +1384,8 @@ original parsed data.  INFO is a plist holding export options."
+     ;; create a manifest entry for styles.xml
+     (org-odt-create-manifest-file-entry "text/xml" "styles.xml")
+ 
++    ;; guix store files are ro. This file need to be modified, make it rw
++    (set-file-modes (concat org-odt-zip-dir "styles.xml") #o600)
+     ;; FIXME: Who is opening an empty styles.xml before this point?
+     (with-current-buffer
+ 	(find-file-noselect (concat org-odt-zip-dir "styles.xml") t)
+-- 
+2.24.0
+
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [bug#38616] emacs: fix odt export
  2019-12-14 23:45 [bug#38616] emacs: fix odt export Nicolò Balzarotti
@ 2019-12-15 14:23 ` Jelle Licht
  2019-12-15 14:56   ` Nicolò Balzarotti
  2019-12-22  9:34   ` bug#38616: " Nicolò Balzarotti
  2019-12-15 15:07 ` [bug#38616] [Nicolò Balzarotti] [bug#38616] " Nicolò Balzarotti
  1 sibling, 2 replies; 5+ messages in thread
From: Jelle Licht @ 2019-12-15 14:23 UTC (permalink / raw)
  To: Nicolò Balzarotti, 38616


Hello Nicholò,

anothersms@gmail.com (Nicolò Balzarotti) writes:

> Hello Guix!
>
> Neither on NixOS or in guix I've ever been able to export an org file to
> otd. The error was
> 'OpenDocument export failed: Buffer is read-only: #<killed buffer>'.
>
> I've seen some report of this error on the web, like:
> - https://lists.gnu.org/archive/html/emacs-orgmode/2018-05/msg00545.html
> - https://github.com/syl20bnr/spacemacs/issues/1482
>
> but also on our IRC:
> - http://logs.guix.gnu.org/guix/2019-05-07.log
> - http://logs.guix.gnu.org/guix/2019-07-25.log
> but I was not able to find a fix for it.
>
> Today I checked the source and figured it out. The explanation, as
> written in the patch, is the following
>
>> Files inside the guix store are read only. "styles.xml" is copied from the
>> store (/share/emacs/26.3/etc/org/OrgOdtStyles.xml), so it's read only too.
>> ox-odt needs this file, so if it's not writable it will fail. This patch
>> adjust the permissions.
Thanks for figuring this out! I've been using my local (terrible)
workarounds for years to make this work.

>
> So, this patches fixes the permissions on the file.
>
> I've two questions:
> 1. Is it fine to have a .patch, or should I add a phase where I fix the
>    file? this seemed to be easier

I can't really advise on the best way forward here, but if you do decide
to go with the .patch route, you should probably also add your .patch
file to `dist_patch_DATA' in gnu/local.mk.

> 2. If the same error happens for other programs, might it make sense to
>    "fake" rw permissions in the store (by using a virtual fs or
>    something) so that files are copied as rw, but files in the store are
>    still ro?

IMHO, software shouldn't assume certain permissions are set, and instead
check or make-it-so. Perhaps you could upstream your patch instead of
embedding it into Guix?

Furthermore, the same issue as the one your fixed here is also present
in our `emacs-org' package. Do you think your approach would work there
as well? If so, it might make sense to fix both emacs and emacs-org.

Thanks!
- Jelle

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#38616] emacs: fix odt export
  2019-12-15 14:23 ` Jelle Licht
@ 2019-12-15 14:56   ` Nicolò Balzarotti
  2019-12-22  9:34   ` bug#38616: " Nicolò Balzarotti
  1 sibling, 0 replies; 5+ messages in thread
From: Nicolò Balzarotti @ 2019-12-15 14:56 UTC (permalink / raw)
  To: Jelle Licht, 38616

Jelle Licht <jlicht@fsfe.org> writes:

> Hello Nicholò,
Nicolò :P

>
> anothersms@gmail.com (Nicolò Balzarotti) writes:
>
>> Hello Guix!
>>
>> Neither on NixOS or in guix I've ever been able to export an org file to
>> otd. The error was
>> 'OpenDocument export failed: Buffer is read-only: #<killed buffer>'.
>>
>> I've seen some report of this error on the web, like:
>> - https://lists.gnu.org/archive/html/emacs-orgmode/2018-05/msg00545.html
>> - https://github.com/syl20bnr/spacemacs/issues/1482
>>
>> but also on our IRC:
>> - http://logs.guix.gnu.org/guix/2019-05-07.log
>> - http://logs.guix.gnu.org/guix/2019-07-25.log
>> but I was not able to find a fix for it.
>>
>> Today I checked the source and figured it out. The explanation, as
>> written in the patch, is the following
>>
>>> Files inside the guix store are read only. "styles.xml" is copied from the
>>> store (/share/emacs/26.3/etc/org/OrgOdtStyles.xml), so it's read only too.
>>> ox-odt needs this file, so if it's not writable it will fail. This patch
>>> adjust the permissions.
> Thanks for figuring this out! I've been using my local (terrible)
> workarounds for years to make this work.

I tried org -> pandoc (docx), org -> pandoc (odt), org -> html -> pandoc
(docx) ... and so on but nothing was good enough, so my last resort was
to try to fix it :D

>
>>
>> So, this patches fixes the permissions on the file.
>>
>> I've two questions:
>> 1. Is it fine to have a .patch, or should I add a phase where I fix the
>>    file? this seemed to be easier
>
> I can't really advise on the best way forward here, but if you do decide
> to go with the .patch route, you should probably also add your .patch
> file to `dist_patch_DATA' in gnu/local.mk.
Ops thanks, I missed that bit.

>
>> 2. If the same error happens for other programs, might it make sense to
>>    "fake" rw permissions in the store (by using a virtual fs or
>>    something) so that files are copied as rw, but files in the store are
>>    still ro?
>
> IMHO, software shouldn't assume certain permissions are set, and instead
> check or make-it-so. Perhaps you could upstream your patch instead of
> embedding it into Guix?

I'll write a mail to emacs-orgmode@gnu.org right now. I've never
submitted bug reports to emacs or org (tried writing them on the IRC
channel but I've never received answers).

>
> Furthermore, the same issue as the one your fixed here is also present
> in our `emacs-org' package. Do you think your approach would work there
> as well? If so, it might make sense to fix both emacs and emacs-org.
>
With a quick look, I see no differences between the two files, (and I
assume no differences between file permissions, too). But if we can get
this patched upstream it would be better (I believe it will helps nixos
users too)

> Thanks!
> - Jelle

Thanks!

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [bug#38616] [Nicolò Balzarotti] [bug#38616] emacs: fix odt export
  2019-12-14 23:45 [bug#38616] emacs: fix odt export Nicolò Balzarotti
  2019-12-15 14:23 ` Jelle Licht
@ 2019-12-15 15:07 ` Nicolò Balzarotti
  1 sibling, 0 replies; 5+ messages in thread
From: Nicolò Balzarotti @ 2019-12-15 15:07 UTC (permalink / raw)
  To: emacs-orgmode; +Cc: 38616

[-- Attachment #1: Type: text/plain, Size: 1000 bytes --]


Hello Org Mode people!

This is my first bug-report :)

I found a problem on org-odt-export-to-odt function.
The export fails with 'OpenDocument export failed: Buffer is read-only: #<killed buffer>'.

The problem happens on ox-odt, when the file OrgOdtStyles.xml
permissions are read-only (this is true especially for Guix and Nix
where all the "store" is readonly). The file gets copied to /tmp/ob-*/
directory, and is then modified. However, the file is assumed to be
read/write. When the file is not, the export fails. I've sent a one-line
patch (simply change permissions to the newly-copied file):

> (set-file-modes (concat org-odt-zip-dir "styles.xml") #o600)

to guix-patches (here in CC, I'm also forwarding my original patch
submission here), but I've been suggested to send the patch upstream.

What do you think? I can submit a proper patch if needed (but feel free
to patch it yourself)

I want to thank everybody for how wonderful Org Mode is :)

Nicolò



[-- Attachment #2: Type: message/rfc822, Size: 11834 bytes --]

[-- Attachment #2.1.1: Type: text/plain, Size: 1334 bytes --]


Hello Guix!

Neither on NixOS or in guix I've ever been able to export an org file to
otd. The error was
'OpenDocument export failed: Buffer is read-only: #<killed buffer>'.

I've seen some report of this error on the web, like:
- https://lists.gnu.org/archive/html/emacs-orgmode/2018-05/msg00545.html
- https://github.com/syl20bnr/spacemacs/issues/1482

but also on our IRC:
- http://logs.guix.gnu.org/guix/2019-05-07.log
- http://logs.guix.gnu.org/guix/2019-07-25.log
but I was not able to find a fix for it.

Today I checked the source and figured it out. The explanation, as
written in the patch, is the following

> Files inside the guix store are read only. "styles.xml" is copied from the
> store (/share/emacs/26.3/etc/org/OrgOdtStyles.xml), so it's read only too.
> ox-odt needs this file, so if it's not writable it will fail. This patch
> adjust the permissions.

So, this patches fixes the permissions on the file.

I've two questions:
1. Is it fine to have a .patch, or should I add a phase where I fix the
   file? this seemed to be easier
2. If the same error happens for other programs, might it make sense to
   "fake" rw permissions in the store (by using a virtual fs or
   something) so that files are copied as rw, but files in the store are
   still ro?

Thanks!

Nicolò


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2.1.2: 0001-gnu-packages-emascs.scm-emacs-patches-Fix-odt-export.patch --]
[-- Type: text/x-patch, Size: 2547 bytes --]

From c1ad3fff9bda5935651f26e460907a77d1b3d003 Mon Sep 17 00:00:00 2001
From: nixo <nicolo@nixo.xyz>
Date: Sat, 14 Dec 2019 15:17:11 +0100
Subject: [PATCH] * gnu/packages/emascs.scm (emacs)[patches]: Fix odt export.

ox-odt copyes the file /share/emacs/26.3/etc/org/OrgOdtStyles.xml under
/tmp/odt-*/styles.xml and tries to modify it.  Since files in the guix store
are read-only, it will fail.  This patch fixes the export by adjusting
permissions during the export.
---
 gnu/packages/emacs.scm                        |  1 +
 .../patches/emacs-fix-odt-export.patch        | 25 +++++++++++++++++++
 2 files changed, 26 insertions(+)
 create mode 100644 gnu/packages/patches/emacs-fix-odt-export.patch

diff --git a/gnu/packages/emacs.scm b/gnu/packages/emacs.scm
index eba7f88551..8183b69eb3 100644
--- a/gnu/packages/emacs.scm
+++ b/gnu/packages/emacs.scm
@@ -80,6 +80,7 @@
                "119ldpk7sgn9jlpyngv5y4z3i7bb8q3xp4p0qqi7i5nq39syd42d"))
              (patches (search-patches "emacs-exec-path.patch"
                                       "emacs-fix-scheme-indent-function.patch"
+                                      "emacs-fix-odt-export.patch"
                                       "emacs-source-date-epoch.patch"))
              (modules '((guix build utils)))
              (snippet
diff --git a/gnu/packages/patches/emacs-fix-odt-export.patch b/gnu/packages/patches/emacs-fix-odt-export.patch
new file mode 100644
index 0000000000..0c3c44a2e3
--- /dev/null
+++ b/gnu/packages/patches/emacs-fix-odt-export.patch
@@ -0,0 +1,25 @@
+Files inside the guix store are read only. "styles.xml" is copied from the
+store (/share/emacs/26.3/etc/org/OrgOdtStyles.xml), so it's read only too.
+ox-odt needs this file, so if it's not writable it will fail. This patch
+adjust the permissions.
+
+---
+ lisp/org/ox-odt.el | 2 ++
+ 1 file changed, 2 insertions(+)
+
+diff --git a/lisp/org/ox-odt.el b/lisp/org/ox-odt.el
+index f9c4a93cc8..61988ffcc4 100644
+--- a/lisp/org/ox-odt.el
++++ b/lisp/org/ox-odt.el
+@@ -1384,6 +1384,8 @@ original parsed data.  INFO is a plist holding export options."
+     ;; create a manifest entry for styles.xml
+     (org-odt-create-manifest-file-entry "text/xml" "styles.xml")
+ 
++    ;; guix store files are ro. This file need to be modified, make it rw
++    (set-file-modes (concat org-odt-zip-dir "styles.xml") #o600)
+     ;; FIXME: Who is opening an empty styles.xml before this point?
+     (with-current-buffer
+ 	(find-file-noselect (concat org-odt-zip-dir "styles.xml") t)
+-- 
+2.24.0
+
-- 
2.24.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* bug#38616: emacs: fix odt export
  2019-12-15 14:23 ` Jelle Licht
  2019-12-15 14:56   ` Nicolò Balzarotti
@ 2019-12-22  9:34   ` Nicolò Balzarotti
  1 sibling, 0 replies; 5+ messages in thread
From: Nicolò Balzarotti @ 2019-12-22  9:34 UTC (permalink / raw)
  To: Jelle Licht, 38616-done


Closing this since my commit has been merged upstream! [1]

(I read on debbugs that to close the issue I need to add -done after the
bug #, let's try)

[1] https://code.orgmode.org/bzg/org-mode/commit/6315e1e76087a013198bfc33f0ec6a444cf5e662

Jelle Licht <jlicht@fsfe.org> writes:

> Hello Nicholò,
>
> anothersms@gmail.com (Nicolò Balzarotti) writes:
>
>> Hello Guix!
>>
>> Neither on NixOS or in guix I've ever been able to export an org file to
>> otd. The error was
>> 'OpenDocument export failed: Buffer is read-only: #<killed buffer>'.
>>
>> I've seen some report of this error on the web, like:
>> - https://lists.gnu.org/archive/html/emacs-orgmode/2018-05/msg00545.html
>> - https://github.com/syl20bnr/spacemacs/issues/1482
>>
>> but also on our IRC:
>> - http://logs.guix.gnu.org/guix/2019-05-07.log
>> - http://logs.guix.gnu.org/guix/2019-07-25.log
>> but I was not able to find a fix for it.
>>
>> Today I checked the source and figured it out. The explanation, as
>> written in the patch, is the following
>>
>>> Files inside the guix store are read only. "styles.xml" is copied from the
>>> store (/share/emacs/26.3/etc/org/OrgOdtStyles.xml), so it's read only too.
>>> ox-odt needs this file, so if it's not writable it will fail. This patch
>>> adjust the permissions.
> Thanks for figuring this out! I've been using my local (terrible)
> workarounds for years to make this work.
>
>>
>> So, this patches fixes the permissions on the file.
>>
>> I've two questions:
>> 1. Is it fine to have a .patch, or should I add a phase where I fix the
>>    file? this seemed to be easier
>
> I can't really advise on the best way forward here, but if you do decide
> to go with the .patch route, you should probably also add your .patch
> file to `dist_patch_DATA' in gnu/local.mk.
>
>> 2. If the same error happens for other programs, might it make sense to
>>    "fake" rw permissions in the store (by using a virtual fs or
>>    something) so that files are copied as rw, but files in the store are
>>    still ro?
>
> IMHO, software shouldn't assume certain permissions are set, and instead
> check or make-it-so. Perhaps you could upstream your patch instead of
> embedding it into Guix?
>
> Furthermore, the same issue as the one your fixed here is also present
> in our `emacs-org' package. Do you think your approach would work there
> as well? If so, it might make sense to fix both emacs and emacs-org.
>
> Thanks!
> - Jelle

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-12-22  9:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-12-14 23:45 [bug#38616] emacs: fix odt export Nicolò Balzarotti
2019-12-15 14:23 ` Jelle Licht
2019-12-15 14:56   ` Nicolò Balzarotti
2019-12-22  9:34   ` bug#38616: " Nicolò Balzarotti
2019-12-15 15:07 ` [bug#38616] [Nicolò Balzarotti] [bug#38616] " Nicolò Balzarotti

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).