Compile Docbook documents for Kindle

by mks

I wanted to have the Linux from Scratch book on my Kindle, but didn't find a current version of it online. Here are the steps I had to do in Ubuntu 12.04 in order to create one. Maybe it helps somebody.

# First, install svn, xsltproc and docbook-xsl
sudo apt-get install svn xsltproc docbook-xsl

# Get current LFS (or get the source for a release)
svn co svn:// lfs

# Finally create the book
mkdir lfsbook
cd lfsbook
xsltproc --xinclude /usr/share/xml/docbook/stylesheet/docbook-xsl/epub/docbook.xsl ../lfs/index.xml
echo "application/epub+zip" > mimetype
zip -0Xq  lfsbook.epub mimetype
zip -Xr9D lfsbook.epub *

# Convert to Kindle format using Calibre; sudo apt-get install calibre if you need this
ebook-convert lfsbook.epub