debian swirl logo

Back to the packages list calibre

#!/usr/bin/make -f

SETUP= python2.7 setup.py

# This filters out *.so for the package "calibre". With this, we can
# install usr/lib in calibre.install and just leave out the binary
# bits.
DEB_DH_INSTALL_ARGS = -Xusr/etc/bash_completion.d $(if $(findstring -bin,$(cdbs_curpkg)),,-X*.so) --fail-missing
DEB_DH_GENCONTROL_ARGS = -- -Vpyqt:Version=$(shell dpkg-query -f'$${Version}' -W python-qt4)

include /usr/share/cdbs/1/rules/debhelper.mk

common-build-arch::
		[ -d build ] || $(SETUP) build

common-install-arch common-install-indep:: debian/tmp
		dh_buildinfo
		dh_sip

debian/tmp:
	env -u LANG -u LC_ALL -u LANGUAGE -u LC_MESSAGES CALIBRE_CONFIG_DIRECTORY= debian/tmp/config $(SETUP) install --root=debian/tmp/usr

	# remove bundled python libraries which are provided by system
	# packages
		rm -r debian/tmp/usr/lib/calibre/cherrypy
		rm -r debian/tmp/usr/lib/calibre/routes
		rm -r debian/tmp/usr/lib/calibre/chardet

		rm debian/tmp/usr/lib/calibre/calibre/utils/pyparsing.py
		rm debian/tmp/usr/lib/calibre/calibre/web/feeds/feedparser.py
		find debian/tmp/ -name '*.py' | xargs sed -i 's/calibre.utils.pyparsing/pyparsing/g'
		find debian/tmp/ -name '*.py' | xargs sed -i 's/calibre.ebooks.markdown/markdown/g'

	# not needed
		rm debian/tmp/usr/bin/calibre-uninstall

	# do not ship a copy of fonts-liberation
		rm -r debian/tmp/usr/share/calibre/fonts/liberation/
		ln -s /usr/share/fonts/truetype/liberation/ debian/tmp/usr/share/calibre/fonts/liberation

	# use system mathjax
		rm -rf debian/tmp/usr/share/calibre/viewer/mathjax
		ln -s /usr/share/javascript/mathjax debian/tmp/usr/share/calibre/viewer/mathjax

	# fix executable permissions
		find debian/tmp/usr/lib/calibre/calibre -type f | xargs chmod a-x
		find debian/tmp/usr/share/calibre/images -type f | xargs chmod a-x

	# add icon
		mkdir -p debian/tmp/usr/share/pixmaps/
		cp manual/resources/logo.png debian/tmp/usr/share/pixmaps/calibre-gui.png

	# remove bogus files on KFreeBSD installation
		rm -rf debian/tmp/config

	# fix "env python2" style hashbangs
		find debian/tmp -type f | xargs sed -i '1 { /^#!.*python/ s_^.*$$_#!/usr/bin/python2.7_ }'

install/calibre::
	# Create and install some of the man pages
	env -u LANG -u LC_ALL -u LANGUAGE -u LC_MESSAGES $(MAKE) -C debian/man VERSION= "$(MAIN_VERSION)"

clean::
		rm -rf debian/orig
		[ ! -d build ] || $(SETUP) build -c
		$(MAKE) -C debian/man clean
		find . -name *.pyc -delete
		find . -name *.so -delete
		find . -name *.qrc -delete
		find . -name *_ui.py -delete

# Downloads the current upstream release according to debian/changelog, removes
# some bundled software copies, non-free image and replaces the non-free prs500
# TTFs with symlinks to their free liberation fonts counterparts. This also
# updates the unpacked source tree to the new upstream version and adds the
# original non-minimized javascript source for jquery.
get-orig-source:
		set -e; \
	V= `dpkg-parsechangelog | sed -rn '/^Version:/ {s/^Version: ([0-9.]+).*$$/\1/; p}'`; \
		mkdir -p debian/orig; cd debian/orig; \
		wget -O - https://downloads.sourceforge.net/project/calibre/$$V/calibre-$$V.tar.xz | xz -cd | tar x; \
		\
		wget -O - https://github.com/ehynds/jquery-ui-multiselect-widget/archive/1.5.tar.gz | tar zx; \
		\
		cp jquery-ui-multiselect-widget-1.5/src/jquery.multiselect.js calibre/resources/content_server/jquery.multiselect.min.js.orig; \
		rm -rf 1.5.tar.gz jquery-ui-multiselect-widget-1.5; \
		\
		wget https://jqueryui.com/resources/download/jquery-ui-1.8.5.zip && unzip jquery-ui-1.8.5.zip; \
		cp jquery-ui-1.8.5/ui/jquery-ui.js calibre/resources/content_server/jquery_ui/js/jquery-ui-1.8.5.custom.js.orig; \
		rm -rf jquery-ui-1.8.5; \
		rm jquery-ui-1.8.5.zip; \
		\
	D= `pwd`; rm -f calibre*/src/odf/thumbnail.py; \
		rm -rf calibre*/src/unrar; \
		rm -rf calibre*/resources/viewer/mathjax; \
		rm -rf calibre*/src/calibre/ebooks/markdown; \
		cd $$D; tar c . | xz -9 > ../../../calibre_$$V+dfsg.orig.tar.xz; \
		cd ../..; rm -r debian/orig; \
		find -mindepth 1 -maxdepth 1 ! -name '.bzr*' ! -name debian | xargs rm -rf; \
		[ ! -e setup.py ] || tar xf ../calibre_$$V+dfsg.orig.tar.xz --strip-components 2

Builds:

calibre-bin
e-book converter and library management
calibre
e-book converter and library management