2014-03-24 138 views
0

使用此命令a2x创建EPUB创建一个有效的.epub文件(book.epub):与A2X与ZIP

$ 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 

但是,如果我尝试手动创建使用文物的.epub档案(包含在在a2x命令和zip命令book.epub.d),产生的.epub文件是无效的:

$ 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%) 

我怀疑这是因为归档的文件包括book.epub.d在路径中。有没有办法排除这个?

回答

2

这里是我已经成功地使用命令:

zip -Xr epubfilename.ePUB mimetype META-INF OEBPS -x \*.DS_Store 

该文件放置在正确的顺序(MIME类型,然后再META-INF与container.xml中下一个,最后一切),并排除.DS_store因为它看起来像你在Mac上。

请注意,您需要在示例的book.epub.d目录内执行此操作以生成正确的输出。

如果您还没有这样做,我还建议使用epubcheck(https://github.com/IDPF/epubcheckhttp://validator.idpf.org)进行双重检查。

+0

为我工作。我不得不谷歌.DS_Store(不适用于我的情况)。 +1用于epubcheck。这是我每天使用的重要工具。 – Paulb

+0

这可以工作:'zip -rr epubfilename.ePUB mimetype META-INF OEBPS'就像'zip -r epubfilename.ePUB mimetype META-INF OEBPS -x \ *。DS_Store'一样。你可以使用'-x'来排除特定的文件('.DS_Store'); '-X'排除所有'额外的文件属性(包括'.DS_Store')。 – craig

+0

解决问题的关键似乎是指定要包含的文件和子文件夹的名称;我没有测试过订单,所以我会接受你的话。 – craig

2

我做拉链一连串命令来压缩的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 

我有时间最长的麻烦,直到我想通了-X是在mimetype拉链至关重要。

我注意到您的拉链排除是小写x ..可能会切换到大写?

+0

'-x'不包括指定的文件; '-X'不包括'额外的文件属性'。因为'.DS_Store'只存在于根目录('book.epub.d')中,所以第一行的'-X'标志起作用。这个文件不存在于两个子目录('META-INF'和'OEBPS')中。 – craig