| 1 |
# Copyright 1999-2012 Gentoo Foundation
|
| 2 |
# Distributed under the terms of the GNU General Public License v2
|
| 3 |
# $Header: /var/cvsroot/gentoo-x86/app-text/calibre/calibre-0.8.56.ebuild,v 1.1 2012/06/15 21:35:36 zmedico Exp $
|
| 4 |
|
| 5 |
EAPI=4
|
| 6 |
PYTHON_DEPEND=2:2.7
|
| 7 |
PYTHON_USE_WITH="ssl sqlite"
|
| 8 |
|
| 9 |
inherit python distutils eutils fdo-mime bash-completion-r1 multilib
|
| 10 |
|
| 11 |
DESCRIPTION="Ebook management application."
|
| 12 |
HOMEPAGE="http://calibre-ebook.com/"
|
| 13 |
SRC_URI="http://sourceforge.net/projects/calibre/files/${PV}/${P}.tar.xz"
|
| 14 |
|
| 15 |
LICENSE="GPL-2"
|
| 16 |
|
| 17 |
KEYWORDS="~amd64 ~x86"
|
| 18 |
|
| 19 |
SLOT="0"
|
| 20 |
|
| 21 |
IUSE="+udisks"
|
| 22 |
|
| 23 |
COMMON_DEPEND="
|
| 24 |
>=app-text/podofo-0.8.2
|
| 25 |
>=app-text/poppler-0.12.3-r3[qt4,xpdf-headers]
|
| 26 |
>=dev-libs/chmlib-0.40
|
| 27 |
>=dev-libs/icu-4.4
|
| 28 |
>=dev-python/beautifulsoup-3.0.5:python-2
|
| 29 |
dev-python/python-dateutil
|
| 30 |
>=dev-python/dnspython-1.6.0
|
| 31 |
>=dev-python/cssutils-0.9.9
|
| 32 |
>=dev-python/dbus-python-0.82.2
|
| 33 |
>=dev-python/imaging-1.1.6
|
| 34 |
>=dev-python/lxml-2.2.1
|
| 35 |
>=dev-python/mechanize-0.1.11
|
| 36 |
>=dev-python/python-dateutil-1.4.1
|
| 37 |
>=dev-python/PyQt4-4.9.1[X,svg,webkit]
|
| 38 |
>=media-gfx/imagemagick-6.5.9[jpeg,png]
|
| 39 |
>=media-libs/libwmf-0.2.8
|
| 40 |
virtual/libusb:0
|
| 41 |
x11-libs/qt-dbus:4
|
| 42 |
x11-libs/qt-svg:4
|
| 43 |
>=x11-misc/xdg-utils-1.0.2-r2"
|
| 44 |
|
| 45 |
RDEPEND="${COMMON_DEPEND}
|
| 46 |
udisks? ( sys-fs/udisks:0 )"
|
| 47 |
|
| 48 |
DEPEND="${COMMON_DEPEND}
|
| 49 |
>=dev-python/setuptools-0.6_rc5"
|
| 50 |
|
| 51 |
S=${WORKDIR}/${PN}
|
| 52 |
|
| 53 |
pkg_setup() {
|
| 54 |
python_set_active_version 2.7
|
| 55 |
python_pkg_setup
|
| 56 |
}
|
| 57 |
|
| 58 |
src_prepare() {
|
| 59 |
# Fix outdated version constant.
|
| 60 |
#sed -e "s#\\(^numeric_version =\\).*#\\1 (${PV//./, })#" \
|
| 61 |
# -i src/calibre/constants.py || \
|
| 62 |
# die "sed failed to patch constants.py"
|
| 63 |
|
| 64 |
# Avoid sandbox violation in /usr/share/gnome/apps when linux.py
|
| 65 |
# calls xdg-* (bug #258938).
|
| 66 |
sed -e "s:'xdg-desktop-menu', 'install':\\0, '--mode', 'user':" \
|
| 67 |
-e "s:check_call(\\['xdg-desktop-menu', 'forceupdate'\\]):#\\0:" \
|
| 68 |
-e "s|\\(CurrentDir(tdir)\\), \\\\\$|\\1:|" \
|
| 69 |
-e "s|PreserveMIMEDefaults():||" \
|
| 70 |
-e "s:xdg-icon-resource install:\\0 --mode user:" \
|
| 71 |
-e "s:xdg-mime install:\\0 --mode user:" \
|
| 72 |
-i src/calibre/linux.py || die "sed failed to patch linux.py"
|
| 73 |
|
| 74 |
# Disable unnecessary privilege dropping for bug #287067.
|
| 75 |
sed -e "s:if os.geteuid() == 0:if False and os.geteuid() == 0:" \
|
| 76 |
-i setup/install.py || die "sed failed to patch install.py"
|
| 77 |
|
| 78 |
sed -e "/^ self\\.check_call(qmc + \\[.*\\.pro'\\])$/a\
|
| 79 |
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ self.check_call(['sed', \
|
| 80 |
'-e', 's|^CFLAGS .*|\\\\\\\\0 ${CFLAGS}|', \
|
| 81 |
'-e', 's|^CXXFLAGS .*|\\\\\\\\0 ${CXXFLAGS}|', \
|
| 82 |
'-e', 's|^LFLAGS .*|\\\\\\\\0 ${LDFLAGS}|', \
|
| 83 |
'-i', 'Makefile'])" \
|
| 84 |
-i setup/extensions.py || die "sed failed to patch extensions.py"
|
| 85 |
|
| 86 |
distutils_src_prepare
|
| 87 |
}
|
| 88 |
|
| 89 |
src_install() {
|
| 90 |
|
| 91 |
# Bypass kbuildsycoca and update-mime-database in order to
|
| 92 |
# avoid sandbox violations if xdg-mime tries to call them.
|
| 93 |
cat - > "${T}/kbuildsycoca" <<-EOF
|
| 94 |
#!${BASH}
|
| 95 |
exit 0
|
| 96 |
EOF
|
| 97 |
|
| 98 |
cp "${T}"/{kbuildsycoca,update-mime-database}
|
| 99 |
chmod +x "${T}"/{kbuildsycoca,update-mime-database}
|
| 100 |
|
| 101 |
# Unset DISPLAY in order to prevent xdg-mime from triggering a sandbox
|
| 102 |
# violation with kbuildsycoca as in bug #287067, comment #13.
|
| 103 |
export -n DISPLAY
|
| 104 |
|
| 105 |
# Bug #352625 - Some LANGUAGE values can trigger the following ValueError:
|
| 106 |
# File "/usr/lib/python2.6/locale.py", line 486, in getdefaultlocale
|
| 107 |
# return _parse_localename(localename)
|
| 108 |
# File "/usr/lib/python2.6/locale.py", line 418, in _parse_localename
|
| 109 |
# raise ValueError, 'unknown locale: %s' % localename
|
| 110 |
#ValueError: unknown locale: 46
|
| 111 |
export -n LANGUAGE
|
| 112 |
|
| 113 |
# Bug #295672 - Avoid sandbox violation in ~/.config by forcing
|
| 114 |
# variables to point to our fake temporary $HOME.
|
| 115 |
export HOME="${T}/fake_homedir"
|
| 116 |
export XDG_CONFIG_HOME="${HOME}/.config"
|
| 117 |
export XDG_DATA_HOME="${HOME}/.local/share"
|
| 118 |
export CALIBRE_CONFIG_DIRECTORY="${XDG_CONFIG_HOME}/calibre"
|
| 119 |
mkdir -p "${XDG_CONFIG_HOME}" "${CALIBRE_CONFIG_DIRECTORY}"
|
| 120 |
|
| 121 |
# Bug #334243 - respect LDFLAGS when building calibre-mount-helper
|
| 122 |
export OVERRIDE_CFLAGS="$CFLAGS" OVERRIDE_LDFLAGS="$LDFLAGS"
|
| 123 |
local libdir=$(get_libdir)
|
| 124 |
[[ -n $libdir ]] || die "get_libdir returned an empty string"
|
| 125 |
|
| 126 |
dodir "$(python_get_sitedir)" # for init_calibre.py
|
| 127 |
PATH=${T}:${PATH} PYTHONPATH=${S}/src${PYTHONPATH:+:}${PYTHONPATH} \
|
| 128 |
distutils_src_install \
|
| 129 |
--prefix="${EPREFIX}/usr" \
|
| 130 |
--libdir="${EPREFIX}/usr/${libdir}" \
|
| 131 |
--staging-root="${ED}usr" \
|
| 132 |
--staging-libdir="${ED}usr/${libdir}"
|
| 133 |
|
| 134 |
grep -rlZ "${ED}" "${ED}" | xargs -0 sed -e "s:${D}:/:g" -i ||
|
| 135 |
die "failed to fix harcoded \$D in paths"
|
| 136 |
|
| 137 |
# Remove dummy calibre-mount-helper which is unused since calibre-0.8.25
|
| 138 |
# due to bug #389515 (instead, calibre now calls udisks via dbus).
|
| 139 |
rm "${ED}usr/bin/calibre-mount-helper" || die
|
| 140 |
|
| 141 |
# The menu entries end up here due to '--mode user' being added to
|
| 142 |
# xdg-* options in src_prepare.
|
| 143 |
dodir /usr/share/mime/packages
|
| 144 |
chmod -fR a+rX,u+w,g-w,o-w "${HOME}"/.local
|
| 145 |
mv "${HOME}"/.local/share/mime/packages/* "${ED}"usr/share/mime/packages/ ||
|
| 146 |
die "failed to register mime types"
|
| 147 |
dodir /usr/share/icons
|
| 148 |
mv "${HOME}"/.local/share/icons/* "${ED}"usr/share/icons/ ||
|
| 149 |
die "failed to install icon files"
|
| 150 |
|
| 151 |
domenu "${HOME}"/.local/share/applications/*.desktop ||
|
| 152 |
die "failed to install .desktop menu files"
|
| 153 |
|
| 154 |
dobashcomp "${ED}"usr/etc/bash_completion.d/calibre
|
| 155 |
rm -r "${ED}"usr/etc/bash_completion.d
|
| 156 |
find "${ED}"usr/etc -type d -empty -delete
|
| 157 |
|
| 158 |
python_convert_shebangs -r $(python_get_version) "${ED}"
|
| 159 |
|
| 160 |
newinitd "${FILESDIR}"/calibre-server.init calibre-server
|
| 161 |
newconfd "${FILESDIR}"/calibre-server.conf calibre-server
|
| 162 |
}
|
| 163 |
|
| 164 |
pkg_postinst() {
|
| 165 |
fdo-mime_desktop_database_update
|
| 166 |
fdo-mime_mime_database_update
|
| 167 |
python_mod_optimize /usr/$(get_libdir)/${PN}
|
| 168 |
}
|
| 169 |
|
| 170 |
pkg_postrm() {
|
| 171 |
python_mod_cleanup /usr/$(get_libdir)/${PN}
|
| 172 |
}
|