==== SIMPLIFIED =====
To unzip and epub book:
Rename example-book.epub to example-book.zip
/usr/bin/unzip example-book.zip
Note: '/usr/bin' is already in the system path so you can get away with just typing 'unzip' instead of '/usr/bin/unzip'
--
To create an epub:
/usr/bin/zip example-book.epub -DX0 mimetype
/usr/bin/zip example-book.epub -rDX9 META-INF OEBPS
Note: '/usr/bin' is already in the system path so you can get away with just typing 'zip' instead of '/usr/bin/zip'
--
To install kindlegen, simply unzip it and then drag the kindlegen app into the Applications folder. You can run this from the command line like so:
/Applications/kindlegen example-book.epub -c1 -verbose
or, if you'd rather capture messages into a text file for future study:
/Applications/kindlegen example-book.epub -c1 -verbose > errors.txt > 2&1
--
epubcheck takes a little more work to install, but not much...
Simply unzip the epubcheck archive and then drag the entire folder into the Applications folder. In this case, the folder name was: epubcheck-3.0.1. On my machine I renamed it to epubcheck.
The reason that you need to drag the entire folder is because of a lib directory within the epubcheck-3.0.1 folder. epubcheck.jar (also in this folder), needs it in order to run properly.
To run this from the command line, using the new directory name (remember, I renamed mine to epubcheck):
/usr/bin/java -jar /Applications/epubcheck/epubcheck-3.0.1.jar example-book.epub > errors.txt > 2&1
Naturally, java needs to be installed. Also, '/usr/bin' is already in the system path so you can get away with just typing 'java' instead of '/usr/bin/java'
===== COMPLETE =====
===== Unzip an EPUB file =====
In your posted notes, you have instructions and switches needed to zip an EPUB file, but none on how to unzip it. On my Windows machine, I have to change the extension from .epub to .zip before I can unpack a book. On my Linux machine, I don't have to do that.
What follows is the command used and the output. I copied both of your samples into a directory named, 'epub_test' and unzipped the mobi sample:
~/epub_test$ unzip EPUB201-Sample-forMOBIBuild-BBeBooks.epub
Use the ls command to view the contents of the directory...
~/epub_test$ ls -l
total 456
-rw-rw-r-- 1 bdyer bdyer 143018 Mar 31 00:42 EPUB201-Sample-BBeBooks.epub
-rw-rw-r-- 1 bdyer bdyer 149522 Mar 31 00:43 EPUB201-Sample-forMOBIBuild-BBeBooks.epub
drwxrwxr-x 2 bdyer bdyer 4096 Mar 31 00:54 META-INF
-rw-rw-r-- 1 bdyer bdyer 20 Mar 31 00:49 mimetype
drwxrwxr-x 6 bdyer bdyer 4096 Mar 31 00:54 OEBPS
~/epub_test$
===== kindlegen install and test =====
I downloaded kindlegen from <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211">here</a>:
It was downloaded into a directory called: Downloads (I used Firefox to download it and this is a default download area).
I brought up a shell and made a directory called: kindlegen (note: normally, I'd do this in /opt rather than in my home directory, but for brevity, I'll use my home for now. Later, I'll install it in /opt)...
$ mkdir kindlegen
Copy the downloaded file from Downloads to the kindlegen directory (note that the filename is slightly different from the example on bbebooksthailand.com as kindlegen has since been updated since the post was made on bbebooksthailand.com)...
$ cp Downloads/kindlegen_linux_2.6_i386_v2_8.tar.gz kindlegen
Change directory to kindlegen...
$ cd kindlegen
Extract the contents of the file...
~/kindlegen$ tar xvfz kindlegen_linux_2.6_i386_v2_8.tar.gz
Now run it to see if it works (the './' in front of the kindlegen command is there because the kindlegen directory isn't in my path yet)...
~/kindlegen$ ./kindlegen
*************************************************************
Amazon kindlegen(Linux) V2.8 build 0208-797bf75
A command line e-book compiler
Copyright Amazon.com and its Affiliates 2013
*************************************************************
Usage : kindlegen [filename.opf/.htm/.html/.epub/.zip or directory] [-c0 or -c1 or c2] [-verbose] [-western] [-o <file name>]
Note:
zip/directory formats are supported for XMDF sources
Options:
-c0: no compression
-c1: standard DOC compression
-c2: Kindle huffdic compression
-o <file name>: Specifies the output file name. Output file will be created in the same directory as that of input file. <file name> should not contain directory path.
-verbose: provides more information during ebook conversion
-western: force build of Windows-1252 book
-releasenotes: display release notes
-gif: images are converted to GIF format (no JPEG in the book)
-locale <locale option> : To display messages in selected language
en: English
de: German
fr: French
it: Italian
es: Spanish
zh: Chinese
ja: Japanese
pt: Portuguese
~/kindlegen$
Initial run was a success. With no work to do (none specified on the command line), a help page was displayed.
===== kindlegen test (creating a MOBI/KF8 ebook) =====
~$ mkdir kindle_test
~$ cd kindle_test
~/kindle_test$ ls -l
total 0
After copying the sample book into the kindle_test directory and unzipping it...
~/kindle_test$ ls -l
total 148
-rw-rw-r-- 1 bdyer bdyer 149589 Mar 30 21:02 EPUB201-Sample-forMOBIBuild-BBeBooks.epub
~/kindle_test$ unzip EPUB*
Archive: EPUB201-Sample-forMOBIBuild-BBeBooks.epub
extracting: mimetype
inflating: META-INF/container.xml
inflating: OEBPS/content/content001.html
inflating: OEBPS/content/content002.html
inflating: OEBPS/content/content003.html
inflating: OEBPS/content/content004.html
inflating: OEBPS/content/content005.html
inflating: OEBPS/content/htmltoc.html
inflating: OEBPS/content.opf
inflating: OEBPS/cover.jpg
inflating: OEBPS/css/bbstylesheet-kindle.css
inflating: OEBPS/fonts/Chunkfive.otf
inflating: OEBPS/images/BBeBooks.jpg
inflating: OEBPS/images/someimage.jpg
inflating: OEBPS/toc.ncx
~/kindle_test$ ls -l
total 160
-rw-rw-r-- 1 bdyer bdyer 149589 Mar 30 21:02 EPUB201-Sample-forMOBIBuild-BBeBooks.epub
drwxrwxr-x 2 bdyer bdyer 4096 Mar 31 13:29 META-INF
-rw-rw-r-- 1 bdyer bdyer 20 Jul 9 2012 mimetype
drwxrwxr-x 6 bdyer bdyer 4096 Mar 31 13:29 OEBPS
Now, remove the original EPUB201-Sample-forMOBIBuild-BBeBooks.epub file so it won't be in the way for the test...
~/kindle_test$ rm EPUB201-Sample-forMOBIBuild-BBeBooks.epub
~/kindle_test$ ls -l
total 12
drwxrwxr-x 2 bdyer bdyer 4096 Mar 31 13:29 META-INF
-rw-rw-r-- 1 bdyer bdyer 20 Jul 9 2012 mimetype
drwxrwxr-x 6 bdyer bdyer 4096 Mar 31 13:29 OEBPS
Create the EPUB book (I'll call it tempmobi.epub)...
~/kindle_test$ zip tempmobi.epub -DX0 mimetype
adding: mimetype (stored 0%)
~/kindle_test$ zip tempmobi.epub -rDX9 META-INF OEBPS
adding: META-INF/container.xml (deflated 32%)
adding: OEBPS/content.opf (deflated 66%)
adding: OEBPS/cover.jpg (deflated 1%)
adding: OEBPS/fonts/Chunkfive.otf (deflated 18%)
adding: OEBPS/toc.ncx (deflated 67%)
adding: OEBPS/content/content001.html (deflated 41%)
adding: OEBPS/content/htmltoc.html (deflated 53%)
adding: OEBPS/content/content002.html (deflated 43%)
adding: OEBPS/content/content003.html (deflated 42%)
adding: OEBPS/content/content005.html (deflated 47%)
adding: OEBPS/content/content004.html (deflated 44%)
adding: OEBPS/css/bbstylesheet-kindle.css (deflated 63%)
adding: OEBPS/images/someimage.jpg (deflated 2%)
adding: OEBPS/images/BBeBooks.jpg (deflated 1%)
Now, run kindlegen (note: here, kindlegen in in a directory called kindlegen, within my home directory. I'll move it to /opt later, but just did a quick install here so I could run the test more quickly)...
~/kindle_test$ ../kindlegen/kindlegen tempmobi.epub -c1 -verbose
*************************************************************
Amazon kindlegen(Linux) V2.8 build 0208-797bf75
A command line e-book compiler
Copyright Amazon.com and its Affiliates 2013
*************************************************************
Info:I9006:option: -c1: Standard DOC compression
Info:I9014:option: -verbose: Verbose output
Info(prcgen):I1048: Unpacking ePub file
Info(prcgen):I1047: Added metadata dc:Title "Sample EPUB 2.0.1 File - MOBI/KF8 build for Developers"
Info(prcgen):I1047: Added metadata dc:Date "2012-07-09"
Info(prcgen):I1047: Added metadata dc:Creator "BB eBooks"
Info(prcgen):I1047: Added metadata dc:Publisher "BB eBooks"
Info(prcgen):I1047: Added metadata dc:Subject "eBook"
Info(prcgen):I1047: Added metadata dc:Subject "Design"
Info(prcgen):I1047: Added metadata dc:Subject "Formatting"
Info(prcgen):I1047: Added metadata dc:Subject "Help"
Info(prcgen):I1047: Added metadata dc:Subject "Kindle"
Info(prcgen):I1047: Added metadata dc:Contributor "Paul Salvette"
Info(prcgen):I1047: Added metadata dc:Rights "Public Domain"
Info(prcgen):I1047: Added metadata dc:Type "Text"
Info(prcgen):I1047: Added metadata dc:Source "http://bbebooksthailand.com"
Info(prcgen):I1047: Added metadata dc:Description "This EPUB file is designed to teach eBook developers how the EPUB 2.0.1 standard works and how to build a MOBI/KF8 file from KindleGen. Feedback is welcome."
Info(prcgen):I1002: Parsing files 0000006
Info(prcgen):I1003: Parsing file URL: content001.html
Info(prcgen):I1003: Parsing file URL: htmltoc.html
Info(prcgen):I1003: Parsing file URL: content002.html
Info(prcgen):I1003: Parsing file URL: content003.html
Info(prcgen):I1003: Parsing file URL: content004.html
Info(prcgen):I1003: Parsing file URL: content005.html
Info(prcgen):I1016: Building enhanced PRC file
Info(prcgen):I1006: Resolving hyperlinks
Info(prcgen):I1010: Writing hyperlinks
Info(prcgen):I1007: Resolving mediaidlinks
Info(prcgen):I1011: Writing mediaidlinks
Info(prcgen):I1009: Resolving guide items
Info(prcgen):I1008: Resolving start reading location
Info(prcgen):I1049: Building table of content URL: /tmp/mobi-btFw3n/OEBPS/toc.ncx
Info(prcgen):I1015: Building PRC file
Info(prcgen):I1013: Converting and merging image file "/tmp/mobi-btFw3n/OEBPS/images/BBeBooks.jpg"
Info(prcgen):I1014: Converting and merging media file "/tmp/mobi-btFw3n/OEBPS/fonts/Chunkfive.otf"
Warning(prcfile):W14029: CFF/Type1 (Postscript) embedded font included in your source may not render clearly on all Kindle readers. Please refer to Kindle Publishing Guidelines on the recommended usage of embedded fonts. Font File : /tmp/mobi-btFw3n/OEBPS/fonts/Chunkfive.otf
Info(prcgen):I1013: Converting and merging image file "/tmp/mobi-btFw3n/OEBPS/images/someimage.jpg"
Info(prcgen):I1013: Converting and merging image file "/tmp/mobi-btFw3n/OEBPS/cover.jpg"
Info(prcgen):I1014: Converting and merging media file "/tmp/mbt-Ly3Mij7DD_3_1F_D_21_2_205_2469_B335860_6"
Info(pagemap):I8000: No Page map found in the book
Info(prcgen/inflections):I1012: Compiling inflections
Info(prcgen):I1019: Building index into record 0000000 Index name: $NCX
Info(prcgen):I1026: Unicode index using utf-8 encoding
Info(prcgen):I1045: Computing UNICODE ranges used in the book
Info(prcgen):I1046: Found UNICODE range: Basic Latin [20..7E]
Info(prcgen):I1046: Found UNICODE range: General Punctuation - Windows 1252 [2013..2014]
Info(prcgen):I1017: Building PRC file, record count: 0000002
Info(prcgen):I1018: Building PRC file record 0000000
Info(prcgen):I1018: Building PRC file record 0000001
Info(prcgen):I1044: Uncompressed record size: 0004096
Info(prcgen):I2001: Final stats - TEXT: 000003639 bytes 000000002 records
Info(prcgen):I2002: Final stats - PICTURES: 000000000 bytes 000000000 records
Info(prcgen):I2003: Final stats - INDEXES: 000000636 bytes 000000003 records
Info(prcgen):I2004: Final stats - TRAILING: 000000010 bytes 000000002 records
Info(prcgen):I2005: Final stats - FRAMES: 000000088 bytes 000000002 records
Info(prcgen):I2006: Final stats - OTHER: 000306276 bytes 000000012 records
Info(prcgen):I2007: Final stats - TOTAL: 000310649 bytes 000000019 records
Info(prcgen):I1039: Final stats - text compressed to (in % of original size): 49.52%
Info(prcgen):I1040: The document identifier is: "Sample_EPUB_-for_Developers"
Info(prcgen):I1041: The file format version is V6
Info(prcgen):I1031: Saving PRC file
Info(prcgen):I1033: PRC built with WARNINGS!
Info(prcgen):I1014: Converting and merging media file "/tmp/mobi-btFw3n/OEBPS/images/BBeBooks.jpg"
Info(prcgen):I1014: Converting and merging media file "/tmp/mobi-btFw3n/OEBPS/images/someimage.jpg"
Info(prcgen):I1014: Converting and merging media file "/tmp/mobi-btFw3n/OEBPS/cover.jpg"
Info(prcgen):I1019: Building index into record 0000000 Index name: $FRAG
Info(prcgen):I1019: Building index into record 0000003 Index name: $SKEL
Info(prcgen):I1019: Building index into record 0000005 Index name: $GUIDE
Info(prcgen):I1019: Building index into record 0000008 Index name: $NCX
Info(prcgen):I1029: The default lookup index is: "$FRAG"
Info(prcgen):I1017: Building PRC file, record count: 0000004
Info(prcgen):I1018: Building PRC file record 0000002
Info(prcgen):I1018: Building PRC file record 0000003
Info(prcgen):I2001: Final stats - TEXT: 000006173 bytes 000000004 records
Info(prcgen):I2003: Final stats - INDEXES: 000002416 bytes 000000011 records
Info(prcgen):I2004: Final stats - TRAILING: 000000016 bytes 000000004 records
Info(prcgen):I2005: Final stats - FRAMES: 000000116 bytes 000000003 records
Info(prcgen):I2006: Final stats - OTHER: 000009167 bytes 000000003 records
Info(prcgen):I2007: Final stats - TOTAL: 000017888 bytes 000000021 records
Info(prcgen):I1039: Final stats - text compressed to (in % of original size): 48.78%
Info(prcgen):I1041: The file format version is V8
Info(prcgen):I1032: PRC built successfully
Info(prcgen):I15000: Approximate Standard Mobi Deliverable file size : 0000143KB
Info(prcgen):I15001: Approximate KF8 Deliverable file size : 0000156KB
Info(prcgen):I1037: Mobi file built with WARNINGS!
Here, looking at the directory listing, I can see both the .epub (from the earlier zip commands) and .mobi (from the kindlegen run) files.
~/kindle_test$ ls -l
total 484
drwxrwxr-x 2 bdyer bdyer 4096 Mar 31 13:29 META-INF
-rw-rw-r-- 1 bdyer bdyer 20 Jul 9 2012 mimetype
drwxrwxr-x 6 bdyer bdyer 4096 Mar 31 13:29 OEBPS
-rw-rw-r-- 1 bdyer bdyer 149589 Mar 31 13:32 tempmobi.epub
-rw-rw-r-- 1 bdyer bdyer 329589 Mar 31 13:33 tempmobi.mobi
~/kindle_test$
I don't have the Kindle Previewer installed, but I have Calibre. It sees, and adds, the book as a mobi and even shows the cover. However, it won't display the book due to an invalid start bit error.
Figuring it was a bad initial load, I deleted the book and then re-added/reopened it with success.
===== epub test (creating an EPUB ebook) =====
Starting with a clean directory, I copied the standard epub file into epub_test...
~/epub_test$ ls -l
total 140
-rw-rw-r-- 1 bdyer bdyer 143018 Mar 30 21:02 EPUB201-Sample-BBeBooks.epub
Unzip the file...
~/epub_test$ unzip EPUB201-Sample-BBeBooks.epub
Archive: EPUB201-Sample-BBeBooks.epub
extracting: mimetype
inflating: META-INF/container.xml
inflating: OEBPS/content/content001.html
inflating: OEBPS/content/content002.html
inflating: OEBPS/content/content003.html
inflating: OEBPS/content/content004.html
inflating: OEBPS/content/content005.html
inflating: OEBPS/content/htmltoc.html
inflating: OEBPS/content.opf
inflating: OEBPS/cover.jpg
inflating: OEBPS/coverpage.html
inflating: OEBPS/css/bbstylesheet-epub.css
inflating: OEBPS/fonts/Chunkfive.otf
inflating: OEBPS/images/BBeBooks.jpg
inflating: OEBPS/images/someimage.jpg
inflating: OEBPS/toc.ncx
~/epub_test$ ls -l
total 152
-rw-rw-r-- 1 bdyer bdyer 143018 Mar 30 21:02 EPUB201-Sample-BBeBooks.epub
drwxrwxr-x 2 bdyer bdyer 4096 Mar 31 13:15 META-INF
-rw-rw-r-- 1 bdyer bdyer 20 Jul 9 2012 mimetype
drwxrwxr-x 6 bdyer bdyer 4096 Mar 31 13:15 OEBPS
Remove the original EPUB201-Sample-BBeBooks.epub file so it won't be in the way of the test...
~/epub_test$ rm EPUB201-Sample-BBeBooks.epub
~/epub_test$ ls -l
total 12
drwxrwxr-x 2 bdyer bdyer 4096 Mar 31 13:15 META-INF
-rw-rw-r-- 1 bdyer bdyer 20 Jul 9 2012 mimetype
drwxrwxr-x 6 bdyer bdyer 4096 Mar 31 13:15 OEBPS
Now let's creat a new EPUB. I'll name it temp.epub...
~/epub_test$ zip temp.epub -DX0 mimetype
adding: mimetype (stored 0%)
~/epub_test$ zip temp.epub -rDX9 META-INF OEBPS
adding: META-INF/container.xml (deflated 32%)
adding: OEBPS/content.opf (deflated 68%)
adding: OEBPS/cover.jpg (deflated 1%)
adding: OEBPS/coverpage.html (deflated 42%)
adding: OEBPS/fonts/Chunkfive.otf (deflated 18%)
adding: OEBPS/toc.ncx (deflated 68%)
adding: OEBPS/content/content001.html (deflated 46%)
adding: OEBPS/content/htmltoc.html (deflated 53%)
adding: OEBPS/content/content002.html (deflated 44%)
adding: OEBPS/content/content003.html (deflated 43%)
adding: OEBPS/content/content005.html (deflated 40%)
adding: OEBPS/content/content004.html (deflated 44%)
adding: OEBPS/css/bbstylesheet-epub.css (deflated 61%)
adding: OEBPS/images/someimage.jpg (deflated 2%)
adding: OEBPS/images/BBeBooks.jpg (deflated 1%)
~/epub_test$ ls -l
total 152
drwxrwxr-x 2 bdyer bdyer 4096 Mar 31 13:15 META-INF
-rw-rw-r-- 1 bdyer bdyer 20 Jul 9 2012 mimetype
drwxrwxr-x 6 bdyer bdyer 4096 Mar 31 13:15 OEBPS
-rw-rw-r-- 1 bdyer bdyer 143018 Mar 31 13:19 temp.epub
Here, I ran various readers, such as FBReader, Okular, Calibre and Firefox's EPUBReader plugin on the generated EPUB file - all with success!
===== epubcheck =====
~$ ./epubcheck epub_test/temp.epub > errors.txt 2>&1
[NOTE: On versions with csh shells (such as FreeBSD) change the command to the following]:
~$ ./epubcheck epub_test/temp.epub > errors.txt
There is a bit of a lag time as the check is performed. Once done, the prompt will reappear...
~$ ls -l
total 56
drwxrwxr-x 3 bdyer bdyer 4096 Mar 31 13:40 Calibre Library
drwxr-xr-x 2 bdyer bdyer 4096 Mar 31 13:01 Desktop
drwxr-xr-x 2 bdyer bdyer 4096 Mar 31 13:42 Documents
drwxr-xr-x 2 bdyer bdyer 4096 Mar 31 13:09 Downloads
-rwxr-xr-x 1 bdyer bdyer 59 Mar 31 01:52 epubcheck
drwxrwxr-x 4 bdyer bdyer 4096 Mar 31 13:19 epub_test
-rw-rw-r-- 1 bdyer bdyer 91 Mar 31 13:56 errors.txt
drwxrwxr-x 3 bdyer bdyer 4096 Mar 30 19:27 kindlegen
drwxrwxr-x 4 bdyer bdyer 4096 Mar 31 13:33 kindle_test
drwxr-xr-x 2 bdyer bdyer 4096 Mar 29 14:48 Music
drwxr-xr-x 2 bdyer bdyer 4096 Mar 29 14:48 Pictures
drwxr-xr-x 2 bdyer bdyer 4096 Mar 29 14:48 Public
drwxr-xr-x 2 bdyer bdyer 4096 Mar 29 14:48 Templates
drwxr-xr-x 2 bdyer bdyer 4096 Mar 29 14:48 Videos
Looking at the contents of the error file (the cat command can be used to display output without using an editor)...
~$ cat errors.txt
Epubcheck Version 3.0
Validating against EPUB version 2.0
No errors or warnings detected.
To run this check, I used a script I named 'epubcheck' which is why the command line shows only that one word (no call to java is obvious). The contents of the script is as follows (note, I made it a point, earlier, to install epubcheck in /opt):
~$ cat epubcheck
java -jar /opt/epubcheck/epubcheck-3.0/epubcheck-3.0.jar $1