问题
Using this a2x
command creates a valid .epub file (book.epub):
$ a2x -v -k -f epub -d book book.asc
a2x: archiving: mimetype
a2x: archiving: META-INF/container.xml
a2x: archiving: OEBPS/ch01.html
a2x: archiving: OEBPS/ch02.html
a2x: archiving: OEBPS/content.opf
a2x: archiving: OEBPS/docbook-xsl.css
a2x: archiving: OEBPS/index.html
a2x: archiving: OEBPS/pr01.html
a2x: archiving: OEBPS/toc.ncx
However, if I try to manually create an .epub archive using the artifacts (contained in book.epub.d) of the a2x
command and zip
command, the resulting .epub file is not valid:
$ zip -vr book.epub book.epub.d/ -x "*.DS_Store"
adding: book.epub.d/ (in=0) (out=0) (stored 0%)
adding: book.epub.d/META-INF/ (in=0) (out=0) (stored 0%)
adding: book.epub.d/META-INF/container.xml (in=255) (out=175) (deflated 31%)
adding: book.epub.d/mimetype (in=20) (out=20) (stored 0%)
adding: book.epub.d/OEBPS/ (in=0) (out=0) (stored 0%)
adding: book.epub.d/OEBPS/ch01.html (in=1161) (out=686) (deflated 41%)
adding: book.epub.d/OEBPS/ch02.html (in=679) (out=414) (deflated 39%)
adding: book.epub.d/OEBPS/content.opf (in=1288) (out=476) (deflated 63%)
adding: book.epub.d/OEBPS/docbook-xsl.css (in=5738) (out=1518) (deflated 74%)
adding: book.epub.d/OEBPS/index.html (in=1156) (out=590) (deflated 49%)
adding: book.epub.d/OEBPS/pr01.html (in=770) (out=485) (deflated 37%)
adding: book.epub.d/OEBPS/toc.ncx (in=772) (out=325) (deflated 58%)
I suspect this is because the archive's files include book.epub.d
in the paths. Is there a way to exclude this?
回答1:
Here is the command I have used successfully:
zip -Xr epubfilename.ePUB mimetype META-INF OEBPS -x \*.DS_Store
This places files in the right order (mime type first, then META-INF with container.xml next, finally everything else) and excludes .DS_store since it looks like you are on a Mac.
Note that you will need to do this from within the book.epub.d directory in your example to produce the correct output.
I also recommend double checking results with epubcheck (https://github.com/IDPF/epubcheck or http://validator.idpf.org) if you are not already doing so.
回答2:
I do a succession of zip commands to zip an EPUB:
cd /home/bookdirectory (where mimetype, OEBPS and META-INF are subdirectories)
zip -X book.epub mimetype
zip -r book.epub META-INF
zip -r book.epub OEBPS
I had trouble for the longest time, until I figured that the -X
was essential on the mimetype
zip.
I notice your zip exclude is a lowercase x
..maybe switch that to upper-case?
来源:https://stackoverflow.com/questions/22620183/creating-epub-with-a2x-versus-zip