I wanted to turn my raspberry pi into a calibre ebook server. I didn't need the gui functionality, intending to just run calibre-server from the pi, and do the book adding and updating via another system with the library cross mounted with sshfs_mount.
The version of calibre that's currently available (as of 2016/10) via apt for raspberry pi is 0.8.51, which is, shall we say, a little long in the tooth. If I started the server on the pi, I could browse the library as a content server, but not download any of the books or see the metadata. So time to see if I could build it from source.
The list of dependencies is a little daunting, and there were not many posts describing the procedure. Those that I found were rather old, and not terribly descriptive.
calibre has a major dependency on Qt. Given that the version available on the pi is Qt4, and I really didn't want to build all of Qt5, I decided to stick to the 1.XX releases of calibre, and picked 1.48 as that was the last one.
There were 2 dependencies that needed to be built from scratch, as the packages available via apt were insufficiently recent:
- python (2.7.9)
- icu (49)
You could probably use a more recent version of python 2.7, but I stuck with 2.7.9 as that's what was referenced in the docs.
the main gotcha that I didn't catch until much later when building calibre (and then had to wipe out the build and restart from scratch), was to use the correct version of unicode. This is the configuration I used for building python:
./configure --prefix=/usr/local --enable-shared --enable-unicode=ucs4
it built and installed cleanly (I ignored the warnings about missing features that I didn't care about). you'll want to update your ld cache after the install, to make sure the right libraries are picked up. check with python --version.
you may need to adjust your PYTHONPATH environment variable according to where the packages were installed. eg:
export PYTHONPATH=/usr/lib/python2.7/dist-packages
icu built without incident or deviations from the instructions.
now for calibre. download the source, unpack it, and build with
python2 setup.py install
there are lots of package dependencies that I discovered by trial and error: try to build calibre, look at the error message about missing file or module, do an apt-file search, and see what comes up. install the relevant package, and try again. here is a non-comprehensive list (depending on what you already have installed, you may need more or less).
python-qt4,python-qt4-dev,libsqlite3-dev, libchm-dev,libmagickwand-dev,
libpodofo-dev,python-sip-dev,python-qt4-dev,libqt4-private-dev,libusb-1.0-0-dev,libmtp-dev,python-cssselect,python-apsw
doing an apt-get install on these will probably bring in lots of other packages too, so make sure you have plenty of space free in /usr.
next problem: the build tries to import some icu plugins before they've been built. so comment out the icu related lines (lines 178 to 181) in src/calibre/startup.py
ok now you're ready to build (but read the next paragraph first). do
python2 setup.py install
finally, some of the modules in Qt4 are not in the places that calibre thinks they are. I needed to modify src/calibre/gui2/__init__.py so that it looked like this:
from PyQt4.QtCore import (QVariant, QFileInfo, QObject, QBuffer, Qt,
QByteArray, QTranslator, QCoreApplication, QThread,
QEvent, QTimer, pyqtSignal, QDateTime,
QSettings, QUrl, QLocale)
from PyQt4.QtGui import (QDesktopServices, QFileDialog,QFileIconProvider,
QIcon, QDialog, QColor, QFont, QPalette,
QApplication, QFontDatabase)
you may or may not have to do the same. if there's a problem, there will be import errors.
towards the end of the build, you'll run into icu related issues again. so after the build fails, go back and uncomment the bits you commented out towards the start, and build again. the icu plugin has been built by this point, so it works!
that should be it. I had one final build error when it was generating the file name completions and desktop integration, as is_safe_name doesn't seem to be in cssselect.xpath any more, but I didn't care about that feature, and it didn't affect the functionality of the calibre-server binary.
after that I started calibre-server, and was able to successfully serve content to another device over the network, and view metadata, which is all that I wanted. I did not explore any of the other features.
The version of calibre that's currently available (as of 2016/10) via apt for raspberry pi is 0.8.51, which is, shall we say, a little long in the tooth. If I started the server on the pi, I could browse the library as a content server, but not download any of the books or see the metadata. So time to see if I could build it from source.
The list of dependencies is a little daunting, and there were not many posts describing the procedure. Those that I found were rather old, and not terribly descriptive.
calibre has a major dependency on Qt. Given that the version available on the pi is Qt4, and I really didn't want to build all of Qt5, I decided to stick to the 1.XX releases of calibre, and picked 1.48 as that was the last one.
There were 2 dependencies that needed to be built from scratch, as the packages available via apt were insufficiently recent:
- python (2.7.9)
- icu (49)
You could probably use a more recent version of python 2.7, but I stuck with 2.7.9 as that's what was referenced in the docs.
the main gotcha that I didn't catch until much later when building calibre (and then had to wipe out the build and restart from scratch), was to use the correct version of unicode. This is the configuration I used for building python:
./configure --prefix=/usr/local --enable-shared --enable-unicode=ucs4
it built and installed cleanly (I ignored the warnings about missing features that I didn't care about). you'll want to update your ld cache after the install, to make sure the right libraries are picked up. check with python --version.
you may need to adjust your PYTHONPATH environment variable according to where the packages were installed. eg:
export PYTHONPATH=/usr/lib/python2.7/dist-packages
icu built without incident or deviations from the instructions.
now for calibre. download the source, unpack it, and build with
python2 setup.py install
there are lots of package dependencies that I discovered by trial and error: try to build calibre, look at the error message about missing file or module, do an apt-file search, and see what comes up. install the relevant package, and try again. here is a non-comprehensive list (depending on what you already have installed, you may need more or less).
python-qt4,python-qt4-dev,libsqlite3-dev, libchm-dev,libmagickwand-dev,
libpodofo-dev,python-sip-dev,python-qt4-dev,libqt4-private-dev,libusb-1.0-0-dev,libmtp-dev,python-cssselect,python-apsw
doing an apt-get install on these will probably bring in lots of other packages too, so make sure you have plenty of space free in /usr.
next problem: the build tries to import some icu plugins before they've been built. so comment out the icu related lines (lines 178 to 181) in src/calibre/startup.py
ok now you're ready to build (but read the next paragraph first). do
python2 setup.py install
finally, some of the modules in Qt4 are not in the places that calibre thinks they are. I needed to modify src/calibre/gui2/__init__.py so that it looked like this:
from PyQt4.QtCore import (QVariant, QFileInfo, QObject, QBuffer, Qt,
QByteArray, QTranslator, QCoreApplication, QThread,
QEvent, QTimer, pyqtSignal, QDateTime,
QSettings, QUrl, QLocale)
from PyQt4.QtGui import (QDesktopServices, QFileDialog,QFileIconProvider,
QIcon, QDialog, QColor, QFont, QPalette,
QApplication, QFontDatabase)
you may or may not have to do the same. if there's a problem, there will be import errors.
towards the end of the build, you'll run into icu related issues again. so after the build fails, go back and uncomment the bits you commented out towards the start, and build again. the icu plugin has been built by this point, so it works!
that should be it. I had one final build error when it was generating the file name completions and desktop integration, as is_safe_name doesn't seem to be in cssselect.xpath any more, but I didn't care about that feature, and it didn't affect the functionality of the calibre-server binary.
after that I started calibre-server, and was able to successfully serve content to another device over the network, and view metadata, which is all that I wanted. I did not explore any of the other features.