calibre/calibre.spec

299 lines
12 KiB
RPMSpec

Summary: E-book converter and library management
Name: calibre
Version: 1.15.0
Release: 2
License: GPLv3+
Group: Office
Url: http://calibre-ebook.com/
Source0: http://iweb.dl.sourceforge.net/project/%{name}/%{version}/%{name}-%{version}.tar.xz
Source2: %{name}-mount-helper
Source100: %{name}.rpmlintrc
Patch1: %{name}-no-update-0.8.6.patch
Patch3: %{name}-0.7.27-python-fix.patch
Patch4: %{name}-python2-env-fix.patch
Patch5: %{name}-web-control.patch
BuildRequires: chrpath
BuildRequires: desktop-file-utils
BuildRequires: pythonegg(apsw) >= 3.7.17
BuildRequires: pythonegg(beautifulsoup) >= 3.0.5
BuildRequires: pythonegg(cssutils) >= 0.9.9
BuildRequires: pythonegg(python-dateutil) >= 1.4.1
BuildRequires: pythonegg(pil) >= 1.1.6
BuildRequires: pythonegg(lxml) >= 2.2.1
BuildRequires: pythonegg(mechanize) >= 0.1.11
BuildRequires: python-setuptools
BuildRequires: pythonegg(six)
BuildRequires: unzip
BuildRequires: xdg-utils >= 1.0.2
BuildRequires: chmlib-devel >= 0.40
BuildRequires: icu-devel >= 4.4
BuildRequires: libwmf-devel >= 0.2.8
BuildRequires: podofo-devel >= 0.8.2
BuildRequires: python-qt4-devel >= 4.9.6
BuildRequires: qt4-devel >= 4.8.0
BuildRequires: qt4-devel-private
BuildRequires: pkgconfig(ImageMagick) >= 6.5.9
BuildRequires: pkgconfig(libmtp) >= 1.1.5
BuildRequires: pkgconfig(poppler-glib)
BuildRequires: pkgconfig(poppler-qt4) >= 0.12
BuildRequires: pkgconfig(python)
BuildRequires: pkgconfig(sqlite3)
Requires: fonts-ttf-liberation
Requires: imagemagick
Requires: poppler >= 0.20.2
Requires: pythonegg(apsw) >= 3.7.17
Requires: pythonegg(beautifulsoup) >= 3.0.5
Requires: pythonegg(cherrypy)
Requires: pythonegg(cssselect) >= 0.7.1
Requires: pythonegg(cssutils) >= 0.9.9
Requires: pythonegg(python-dateutil) >= 1.4.1
Requires: pythonegg(django-tagging)
Requires: pythonegg(dnspython) >= 1.6.0
Requires: pythonegg(genshi)
Requires: pythonegg(pil) >= 1.1.6
Requires: pythonegg(lxml) >= 2.2.1
Requires: pythonegg(mechanize) >= 0.1.11
Requires: pythonegg(netifaces) >= 0.8
Requires: pythonegg(odfpy)
Requires: pythonegg(pypdf)
Requires: python-qt4 >= 4.9.6
Requires: python-qt4-help
%description
Calibre is meant to be a complete e-library solution. It includes library
management, format conversion, news feeds to e-book conversion as well as
e-book reader sync features.
Calibre is primarily a e-book cataloging program. It manages your e-book
collection for you. It is designed around the concept of the logical book,
i.e. a single entry in the database that may correspond to e-books in several
formats. It also supports conversion to and from a dozen different e-book
formats.
Supported input formats are: MOBI, LIT, PRC, EPUB, CHM, ODT, HTML, CBR, CBZ,
RTF, TXT, PDF and LRS.
%files
%doc COPYRIGHT LICENSE Changelog.yaml
%{_bindir}/calibre
%{_bindir}/calibre-complete
%{_bindir}/calibre-customize
%{_bindir}/calibre-debug
%{_bindir}/calibre-parallel
%{_bindir}/calibre-server
%{_bindir}/calibre-smtp
%{_bindir}/calibre-mount-helper
%{_bindir}/calibredb
%{_bindir}/ebook-convert
%{_bindir}/ebook-device
%{_bindir}/ebook-meta
%{_bindir}/ebook-viewer
%{_bindir}/ebook-polish
%{_bindir}/fetch-ebook-metadata
%{_bindir}/lrf2lrs
%{_bindir}/lrfviewer
%{_bindir}/lrs2lrf
%{_bindir}/markdown-calibre
%{_bindir}/web2disk
%{_bindir}/ebook-edit
%config(noreplace) %{_sysconfdir}/bash_completion.d/%{name}
%{_libdir}/%{name}
%{_datadir}/%{name}
%{_datadir}/pixmaps/*
%{_datadir}/applications/*.desktop
%{_datadir}/mime/packages/*
%{_datadir}/icons/hicolor/scalable/mimetypes/*
%{_datadir}/icons/hicolor/*/apps/*
%{python_sitelib}/init_calibre.py*
#--------------------------------------------------------------------
%prep
%setup -q -n %{name}
# remove redundant / non-free fonts
rm -rf resources/fonts/*/
# don't check for new upstream version (that's what packagers do)
# otherwise the plugins are safe to be updated in ~/.config/calibre/plugins/
%patch1 -F 2 -p1 -b .no-update
# libs
%patch3 -p1 -b .python-fix
# there is no python2 symlink to python2.7
# but just python, as opposed to python3
%patch4 -p1 -b .python2-env-fix
# import from QtNetwork, not Qt
%patch5 -p1 -b .python-web-control
# dos2unix newline conversion
sed -i -e 's/\r//' src/calibre/web/feeds/recipes/*
# fix the location of liberation default font
# sed -i -e "s:P('fonts/liberation/LiberationSerif:('%{_datadir}/fonts/TTF/liberation/LiberationSerif:" \
# src/calibre/library/catalog.py
sed -i -e "s:P('fonts/liberation/LiberationSerif:('%{_datadir}/fonts/TTF/liberation/LiberationSerif:" \
src/calibre/utils/magick/draw.py
sed -i -e "s:P('fonts/liberation/LiberationSerif:('%{_datadir}/fonts/TTF/liberation/LiberationSerif:" \
src/calibre/web/feeds/news.py
sed -i -e "s:P('fonts/liberation/LiberationSerif:('%{_datadir}/fonts/TTF/liberation/LiberationSerif:" \
recipes/*_ke.recipe
# remove shebangs
sed -i -e '/^#!\//, 1d' src/calibre/*/*/*/*.py
sed -i -e '/^#!\//, 1d' src/calibre/*/*/*.py
sed -i -e '/^#![ ]*\//, 1d' src/calibre/*/*.py
sed -i -e '/^#!\//, 1d' src/calibre/*.py
sed -i -e '/^#!\//, 1d' src/templite/*.py
sed -i -e '/^#!\//, 1d' resources/default_tweaks.py
sed -i -e '/^#!\//, 1d' recipes/*.recipe
chmod -x src/calibre/*/*/*/*.py
chmod -x src/calibre/*/*/*.py
chmod -x src/calibre/*/*.py
chmod -x src/calibre/*.py
chmod -x recipes/*.recipe
%build
OVERRIDE_CFLAGS="%{optflags}" LANG='en_US.UTF-8' python setup.py build
LANG='en_US.UTF-8' python setup.py translations
%install
mkdir -p %{buildroot}%{_datadir}
# create directories for xdg-utils
mkdir -p %{buildroot}%{_datadir}/icons
mkdir -p %{buildroot}%{_datadir}/icons/hicolor
mkdir -p %{buildroot}%{_datadir}/packages
mkdir -p %{buildroot}%{_datadir}/mime
mkdir -p %{buildroot}%{_datadir}/mime/packages
mkdir -p %{buildroot}%{_datadir}/applications
mkdir -p %{buildroot}%{_datadir}/desktop-directories
# create directory for calibre environment module
# the install script assumes it's there.
mkdir -p %{buildroot}%{python_sitelib}
XDG_DATA_DIRS="%{buildroot}%{_datadir}" \
XDG_UTILS_INSTALL_MODE="system" \
LIBPATH="%{_libdir}" \
python setup.py install --root=%{buildroot}%{_prefix} \
--prefix=%{_prefix} \
--libdir=%{_libdir} \
--staging-libdir=%{buildroot}%{_libdir} \
# remove shebang from init_calibre.py here because
# it just got spawned by the install script
sed -i -e '/^#!\//, 1d' %{buildroot}%{python_sitelib}/init_calibre.py
# icons
mkdir -p %{buildroot}%{_datadir}/pixmaps/
cp -p resources/images/library.png \
%{buildroot}%{_datadir}/pixmaps/%{name}-gui.png
cp -p resources/images/viewer.png \
%{buildroot}%{_datadir}/pixmaps/calibre-viewer.png
# every file is empty here
find %{buildroot}%{_datadir}/mime -maxdepth 1 -type f|xargs rm -f
# the portable batch (>=0.8.5) is not needed
rm -f %{buildroot}%{_bindir}/calibre-portable.bat
# packages aren't allowed to register mimetypes like this
rm -f %{buildroot}%{_datadir}/applications/defaults.list
rm -f %{buildroot}%{_datadir}/applications/mimeinfo.cache
rm -f %{buildroot}%{_datadir}/mime/application/*.xml
rm -f %{buildroot}%{_datadir}/mime/text/*.xml
desktop-file-validate \
%{buildroot}%{_datadir}/applications/calibre-ebook-viewer.desktop
desktop-file-validate \
%{buildroot}%{_datadir}/applications/calibre-gui.desktop
desktop-file-validate \
%{buildroot}%{_datadir}/applications/calibre-lrfviewer.desktop
# mimetype icon for lrf
rm -rf %{buildroot}%{_datadir}/icons/hicolor/128x128
mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable
mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/mimetypes
mkdir -p %{buildroot}%{_datadir}/icons/hicolor/scalable/apps
cp -p resources/images/mimetypes/lrf.png \
%{buildroot}%{_datadir}/icons/hicolor/scalable/mimetypes/application-x-sony-bbeb.png
cp -p resources/images/viewer.png \
%{buildroot}%{_datadir}/icons/hicolor/scalable/apps/calibre-viewer.png
# don't put bash completions in /usr/etc
mkdir -p %{buildroot}%{_sysconfdir}/bash_completion.d
mv %{buildroot}%{_prefix}%{_sysconfdir}/bash_completion.d/%{name} %{buildroot}%{_sysconfdir}/bash_completion.d
rmdir %{buildroot}%{_prefix}%{_sysconfdir}/bash_completion.d
# these are provided as separate packages
rm -rf %{buildroot}%{_libdir}/%{name}/{odf,cherrypy,pyPdf,encutils,cssutils}
rm -rf %{buildroot}%{_libdir}/%{name}/cal/utils/genshi
rm -rf %{buildroot}%{_libdir}/%{name}/cal/trac
# link to system fonts after we have deleted the non-free ones
# http://oldbugs.calibre-ebook.com/ticket/3832
mkdir -p %{buildroot}%{_datadir}/%{name}/fonts/prs500
ln -s %{_datadir}/fonts/TTF/liberation/LiberationSans-Regular.ttf \
%{buildroot}%{_datadir}/%{name}/fonts/prs500/tt0003m_.ttf
ln -s %{_datadir}/fonts/TTF/liberation/LiberationSerif-Regular.ttf \
%{buildroot}%{_datadir}/%{name}/fonts/prs500/tt0011m_.ttf
ln -s %{_datadir}/fonts/TTF/liberation/LiberationMono-Regular.ttf \
%{buildroot}%{_datadir}/%{name}/fonts/prs500/tt0419m_.ttf
# delete locales, calibre stores them in a zip file now
rm -rf %{buildroot}%{_datadir}/%{name}/localization/locales/
rm -f %{buildroot}%{_bindir}/%{name}-uninstall
install -m 0755 %{SOURCE2} %{buildroot}%{_bindir}/
# fix linting section :)
# script-without-shebang
find %{buildroot}%{_libdir}/%{name}/chardet -name '*.py' -exec sed -i -e '1i#!/usr/bin/python' {} \;
# wrong-script-interpreter
find %{buildroot}%{_libdir}/%{name}/calibre/ebooks/markdown/extensions/meta.py -exec sed -i -e '1i#!/usr/bin/python' {} \;
# non-executable-script
chmod a+x %{buildroot}%{_libdir}/%{name}/qtcurve/test_rendering.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/djvu/djvubzzdec.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/utils/fonts/sfnt/cff/table.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/djvu/djvu.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/display/test-cfi/run.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/devices/mtp/unix/upstream/update.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/utils/fonts/sfnt/cff/__init__.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/utils/fonts/sfnt/cff/dict_data.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/utils/fonts/sfnt/cff/constants.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/markdown/extensions/meta.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/utils/fonts/sfnt/cff/writer.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/tests/main.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/tests/base.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/tests/container.py
chmod a+x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/tests/__init__.py
chmod a+x %{buildroot}%{_datadir}/%{name}/catalog/section_list_templates.py
chmod a+x %{buildroot}%{_datadir}/%{name}/calibre-portable.sh
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/check/base.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/check/parsing.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/check/main.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/check/__init__.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/gui2/tweak_book/editor/syntax/base.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/check/images.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/check/links.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/gui2/tweak_book/editor/syntax/css.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/check/fonts.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/gui2/tweak_book/editor/syntax/__init__.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/ebooks/oeb/polish/tests/parsing.py
chmod +x %{buildroot}%{_libdir}/%{name}/calibre/gui2/tweak_book/editor/syntax/html.py
# rpath fix
chrpath -d %{buildroot}%{_libdir}/%{name}/calibre/plugins/pictureflow.so
chrpath -d %{buildroot}%{_libdir}/%{name}/calibre/plugins/progress_indicator.so
chrpath -d %{buildroot}%{_libdir}/%{name}/calibre/plugins/qt_hack.so