LibreOffice 6.0 unzip - zip open document file?

In LibreOffice 5.0 I used to be able to open an Open Document file (e.g. *.ods or *.odb) on a low level by unzipping it. Then I could change something there on the “low level”, zip it again and use it. I used the Ubuntu archive manager to do that.

Since Ubuntu 18.4 and LibreOffice 6.0 this does not work any more. The archive manager does not open it (“archive type is not supported”). However, if I open it with the utility “unzip” into a folder (that still works!) and, without changing anything, zip it again (put it into a zip-archive “Filename.zip” and change the extension from “.zip” to e.g., “.odb”), then LibreOffice cannot open it; it considers the file corrupt.

a) Did the file format change?

b) What can I do if I need to make low level changes to an Open Document file?

Thanks for an answer!

Xenon1

Likely that version of archive manager has some broken means what could be a zip file… the file format did not change, it still is a zip container, otherwise the unzip utility would refuse to run on it.

When (re)zipping an ODF document you must ensure that the mimetype file is the very first file in the archive and not compressed, it must be plain text. If that is not the case (compressed file or different position in the zip directory) then it is not a valid ODF file.

To achieve that, easiest is to freshen the existing zip with the modified file(s) instead of creating a new zip, i.e. use the -f option, for example zip -f /path/to/filename.ods content.xml

When creating a new zip, add and store only the mimetype file first using the -0 (numeric zero, not letter O) option. Then add other files using the -u option.

Fwiw, I just tried with file-roller 3.22.3 (which is Archive Manager) and indeed already that doesn’t accept for example an .ods document, and also not one that is 10 years old.

“When (re)zipping an ODF document you must ensure that the mimetype file is the very first file in the archive and not compressed, it must be plain text.” How do I do that? - And thank you for your fast answer, erAck!

Maybe saving those, with the flat format can make easy edit the files (only fodt, fods, fodp).

I updated my answer with “how to do that”.

Hi! The method mentioned below xenon1: rename .odt to .zip and use Engrampa is working to me too but the “zip” command from terminal not freshening neither updating the context.xml in it. If I just run the zip without -f or -u option then the .odt (or the .zip) updated but seems to be corrupted as xenon1 mentioned in the question.
Unfortunately I think I should use the “zip” command later to do the changes. (I plan to call it from PHP by shell_exec)
So someone have tips what could be the problem and what the solution with “zip”?
(I use Ubuntu 18.04.4 LTS, Libreoffice Writer 6.0.7.3, ODF1.2 .odt)

Thanks!
Roland

What command exactly do you use to freshen the zip, and does the content.xml file you want to freshen in the zip actually have a newer timestamp than the one in the .odt zip container?

Hi!
I tried it some way. At the end - because i read somewhere that it important to use the same folder to compress where the .odt created (for some internal relative path reason?) i used the following method:

  1. SavedAs the .odt to a “decompresslib” library.
  2. Decompressed with unzip
  3. Edited the contetnt.xml and saved it
  4. run the zip: zip -f ./decompresslib/X.odt ./decompresslib/content.xml
    When i tried to open with LibreOffice it denied to open it because it find that it corrupted.
    Last time i changed the working directory and surprisingly the zip echoed CRC warning:

$ zip -f ./ModX.odt ./content.xml
freshening: content.xml
zip warning: Local Entry CRC does not match CD: content.xml
(deflated 90%)
I don’t know how can correct this i don’t find CRC related option in man zip…

The zip -f ./decompresslib/X.odt ./decompresslib/content.xml is wrong, content.xml must be without path, otherwise there’s noting to refresh (and adding the file would be wrong). So either the zip command be invoked in its (content.xml) actual directory decompresslib/ and omitting the directory, or the -j junk directory names option be used, so zip -f -j ./decompresslib/X.odt ./decompresslib/content.xml (be careful you don’t use that with other files that actually need a correct directory prefix).

The non-matching CRC does not harm, it will be corrected with freshening the zip.

Thanks you erAck! That’s wokr!

Just found the solution:
Rename file:
a) replace *.ods with *.zip.
Or, even easier:
b) add .zip to file name.

Now the archive program opens it easily!
It seems that the Linux-program archive does not want to open files with the “wrong” file extension.