| 1 |
zmedico |
1.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.64.ebuild,v 1.1 2012/08/10 22:20:13 zmedico Exp $ |
| 4 |
|
|
|
| 5 |
|
|
EAPI=4 |
| 6 |
|
|
PYTHON_DEPEND=2:2.7 |
| 7 |
|
|
PYTHON_USE_WITH="ssl sqlite" |
| 8 |
|
|
|
| 9 |
|
|
inherit python 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 |
|
|
media-libs/libmtp |
| 41 |
|
|
virtual/libusb:0 |
| 42 |
|
|
x11-libs/qt-dbus:4 |
| 43 |
|
|
x11-libs/qt-svg:4 |
| 44 |
|
|
>=x11-misc/xdg-utils-1.0.2-r2" |
| 45 |
|
|
|
| 46 |
|
|
RDEPEND="${COMMON_DEPEND} |
| 47 |
|
|
udisks? ( sys-fs/udisks:0 )" |
| 48 |
|
|
|
| 49 |
|
|
DEPEND="${COMMON_DEPEND} |
| 50 |
|
|
>=dev-python/setuptools-0.6_rc5" |
| 51 |
|
|
|
| 52 |
|
|
S=${WORKDIR}/${PN} |
| 53 |
|
|
|
| 54 |
|
|
pkg_setup() { |
| 55 |
|
|
python_set_active_version 2.7 |
| 56 |
|
|
python_pkg_setup |
| 57 |
|
|
} |
| 58 |
|
|
|
| 59 |
|
|
src_prepare() { |
| 60 |
|
|
# Fix outdated version constant. |
| 61 |
|
|
#sed -e "s#\\(^numeric_version =\\).*#\\1 (${PV//./, })#" \ |
| 62 |
|
|
# -i src/calibre/constants.py || \ |
| 63 |
|
|
# die "sed failed to patch constants.py" |
| 64 |
|
|
|
| 65 |
|
|
# Avoid sandbox violation in /usr/share/gnome/apps when linux.py |
| 66 |
|
|
# calls xdg-* (bug #258938). |
| 67 |
|
|
sed -e "s|'xdg-desktop-menu', 'install'|\\0, '--mode', 'user'|" \ |
| 68 |
|
|
-e "s|check_call(\\['xdg-desktop-menu', 'forceupdate'\\])|#\\0|" \ |
| 69 |
|
|
-e "s|\\(CurrentDir(tdir)\\), \\\\\$|\\1:|" \ |
| 70 |
|
|
-e "s|PreserveMIMEDefaults():||" \ |
| 71 |
|
|
-e "s|xdg-icon-resource install|\\0 --mode user|" \ |
| 72 |
|
|
-e "s|cc(\\['xdg-desktop-menu', 'forceupdate'\\])|#\\0|" \ |
| 73 |
|
|
-e "s|xdg-mime install|\\0 --mode user|" \ |
| 74 |
|
|
-i src/calibre/linux.py || die "sed failed to patch linux.py" |
| 75 |
|
|
|
| 76 |
|
|
# Disable unnecessary privilege dropping for bug #287067. |
| 77 |
|
|
sed -e "s:if os.geteuid() == 0:if False and os.geteuid() == 0:" \ |
| 78 |
|
|
-i setup/install.py || die "sed failed to patch install.py" |
| 79 |
|
|
|
| 80 |
|
|
sed -e "/^ self\\.check_call(qmc + \\[.*\\.pro'\\])$/a\ |
| 81 |
|
|
\\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ self.check_call(['sed', \ |
| 82 |
|
|
'-e', 's|^CFLAGS .*|\\\\\\\\0 ${CFLAGS}|', \ |
| 83 |
|
|
'-e', 's|^CXXFLAGS .*|\\\\\\\\0 ${CXXFLAGS}|', \ |
| 84 |
|
|
'-e', 's|^LFLAGS .*|\\\\\\\\0 ${LDFLAGS}|', \ |
| 85 |
|
|
'-i', 'Makefile'])" \ |
| 86 |
|
|
-e "s:if not opts.only:if True:" \ |
| 87 |
|
|
-i setup/extensions.py || die "sed failed to patch extensions.py" |
| 88 |
|
|
} |
| 89 |
|
|
|
| 90 |
|
|
src_install() { |
| 91 |
|
|
|
| 92 |
|
|
# Bypass kbuildsycoca and update-mime-database in order to |
| 93 |
|
|
# avoid sandbox violations if xdg-mime tries to call them. |
| 94 |
|
|
cat - > "${T}/kbuildsycoca" <<-EOF |
| 95 |
|
|
#!${BASH} |
| 96 |
|
|
exit 0 |
| 97 |
|
|
EOF |
| 98 |
|
|
|
| 99 |
|
|
cp "${T}"/{kbuildsycoca,update-mime-database} |
| 100 |
|
|
chmod +x "${T}"/{kbuildsycoca,update-mime-database} |
| 101 |
|
|
|
| 102 |
|
|
# Unset DISPLAY in order to prevent xdg-mime from triggering a sandbox |
| 103 |
|
|
# violation with kbuildsycoca as in bug #287067, comment #13. |
| 104 |
|
|
export -n DISPLAY |
| 105 |
|
|
|
| 106 |
|
|
# Bug #352625 - Some LANGUAGE values can trigger the following ValueError: |
| 107 |
|
|
# File "/usr/lib/python2.6/locale.py", line 486, in getdefaultlocale |
| 108 |
|
|
# return _parse_localename(localename) |
| 109 |
|
|
# File "/usr/lib/python2.6/locale.py", line 418, in _parse_localename |
| 110 |
|
|
# raise ValueError, 'unknown locale: %s' % localename |
| 111 |
|
|
#ValueError: unknown locale: 46 |
| 112 |
|
|
export -n LANGUAGE |
| 113 |
|
|
|
| 114 |
|
|
# Bug #295672 - Avoid sandbox violation in ~/.config by forcing |
| 115 |
|
|
# variables to point to our fake temporary $HOME. |
| 116 |
|
|
export HOME="${T}/fake_homedir" |
| 117 |
|
|
export XDG_CONFIG_HOME="${HOME}/.config" |
| 118 |
|
|
export XDG_DATA_HOME="${HOME}/.local/share" |
| 119 |
|
|
export CALIBRE_CONFIG_DIRECTORY="${XDG_CONFIG_HOME}/calibre" |
| 120 |
|
|
mkdir -p "${XDG_CONFIG_HOME}" "${CALIBRE_CONFIG_DIRECTORY}" |
| 121 |
|
|
|
| 122 |
|
|
# Bug #334243 - respect LDFLAGS when building calibre-mount-helper |
| 123 |
|
|
export OVERRIDE_CFLAGS="$CFLAGS" OVERRIDE_LDFLAGS="$LDFLAGS" |
| 124 |
|
|
local libdir=$(get_libdir) |
| 125 |
|
|
[[ -n $libdir ]] || die "get_libdir returned an empty string" |
| 126 |
|
|
|
| 127 |
|
|
dodir "$(python_get_sitedir)" # for init_calibre.py |
| 128 |
|
|
PATH=${T}:${PATH} PYTHONPATH=${S}/src${PYTHONPATH:+:}${PYTHONPATH} \ |
| 129 |
|
|
python setup.py install \ |
| 130 |
|
|
--root="${D}" \ |
| 131 |
|
|
--prefix="${EPREFIX}/usr" \ |
| 132 |
|
|
--libdir="${EPREFIX}/usr/${libdir}" \ |
| 133 |
|
|
--staging-root="${ED}usr" \ |
| 134 |
|
|
--staging-libdir="${ED}usr/${libdir}" || die |
| 135 |
|
|
|
| 136 |
|
|
grep -rlZ "${ED}" "${ED}" | xargs -0 sed -e "s:${D}:/:g" -i || |
| 137 |
|
|
die "failed to fix harcoded \$D in paths" |
| 138 |
|
|
|
| 139 |
|
|
# Remove dummy calibre-mount-helper which is unused since calibre-0.8.25 |
| 140 |
|
|
# due to bug #389515 (instead, calibre now calls udisks via dbus). |
| 141 |
|
|
rm "${ED}usr/bin/calibre-mount-helper" || die |
| 142 |
|
|
|
| 143 |
|
|
# The menu entries end up here due to '--mode user' being added to |
| 144 |
|
|
# xdg-* options in src_prepare. |
| 145 |
|
|
dodir /usr/share/mime/packages |
| 146 |
|
|
chmod -fR a+rX,u+w,g-w,o-w "${HOME}"/.local |
| 147 |
|
|
mv "${HOME}"/.local/share/mime/packages/* "${ED}"usr/share/mime/packages/ || |
| 148 |
|
|
die "failed to register mime types" |
| 149 |
|
|
dodir /usr/share/icons |
| 150 |
|
|
mv "${HOME}"/.local/share/icons/* "${ED}"usr/share/icons/ || |
| 151 |
|
|
die "failed to install icon files" |
| 152 |
|
|
|
| 153 |
|
|
domenu "${HOME}"/.local/share/applications/*.desktop || |
| 154 |
|
|
die "failed to install .desktop menu files" |
| 155 |
|
|
|
| 156 |
|
|
dobashcomp "${ED}"usr/etc/bash_completion.d/calibre |
| 157 |
|
|
rm -r "${ED}"usr/etc/bash_completion.d |
| 158 |
|
|
find "${ED}"usr/etc -type d -empty -delete |
| 159 |
|
|
|
| 160 |
|
|
python_convert_shebangs -r $(python_get_version) "${ED}" |
| 161 |
|
|
|
| 162 |
|
|
newinitd "${FILESDIR}"/calibre-server.init calibre-server |
| 163 |
|
|
newconfd "${FILESDIR}"/calibre-server.conf calibre-server |
| 164 |
|
|
} |
| 165 |
|
|
|
| 166 |
|
|
pkg_postinst() { |
| 167 |
|
|
fdo-mime_desktop_database_update |
| 168 |
|
|
fdo-mime_mime_database_update |
| 169 |
|
|
python_mod_optimize /usr/$(get_libdir)/${PN} |
| 170 |
|
|
} |
| 171 |
|
|
|
| 172 |
|
|
pkg_postrm() { |
| 173 |
|
|
python_mod_cleanup /usr/$(get_libdir)/${PN} |
| 174 |
|
|
} |