desktop/calibre/PKGBUILD
2011-01-29 17:30:28 +00:00

87 lines
3.9 KiB
Bash

#
# Apps Packages for Chakra, part of chakra-project.org
#
# contributor (x86_64): Giuseppe Calà <jiveaxe@gmail.com>
# include global config
source ../_buildscripts/${current_repo}-${_arch}-cfg.conf
pkgname=calibre
pkgver=0.7.43
pkgrel=1
pkgdesc="E-book library management application"
arch=('i686' 'x86_64')
url="http://calibre.kovidgoyal.net/"
license=('GPL3')
depends=('python2' 'python-imaging' 'libusb' 'pyqt' 'python-mechanize'
'imagemagick' 'dbus-python' 'python-lxml' 'beautiful-soup' 'python-dateutil'
'python-cssutils-beta' 'desktop-file-utils' 'shared-mime-info' 'python-dnspython'
'podofo>=0.8.1-6' 'xdg-utils' 'cherrypy' 'python-pypdf' 'unrar' 'chmlib' 'poppler' 'poppler-qt' 'liblqr' 'icu' 'sip' 'libffi')
makedepends=('python-distribute')
install=calibre.install
source=(http://calibre-ebook.googlecode.com/files/${pkgname}-${pkgver}.tar.gz)
md5sums=('28a9792a14b913e629eedd10e88b824d')
build() {
cd "${pkgname}"
rm -rf src/{cherrypy,pyPdf}
# Hador patches
sed -e "/render_img('mimetypes\/lrf.png', 'calibre-lrf.png')/,/self.icon_resources.append(('apps', 'calibre-viewer', '128'))/c \ \
dir = os.path.join(self.opts.staging_sharedir,'../pixmaps')\n \
os.mkdir(dir)\n \
render_img('mimetypes/lrf.png', os.path.join(dir,'calibre-lrf.png'))\n \
render_img('lt.png', os.path.join(dir, 'calibre-gui.png'))\n \
render_img('viewer.png', os.path.join(dir, 'calibre-viewer.png'))" \
-e "/f = open('calibre-lrfviewer.desktop', 'wb')/c \ \
dir = os.path.join(self.opts.staging_sharedir,'../applications')\n \
os.mkdir(dir)\n \
f = open(os.path.join(dir, 'calibre-lrfviewer.desktop'), 'wb')" \
-e "s/if mt and 'chemical' not in mt:/if mt and 'chemical' not in mt and 'text' not in mt and 'pdf' not in mt and 'xhtml' not in mt:/g" \
-e "s/f = open('calibre-ebook-viewer.desktop', 'wb')/f = open(os.path.join(dir, 'calibre-ebook-viewer.desktop'), 'wb')/g" \
-e "s/f = open('calibre-gui.desktop', 'wb')/f = open(os.path.join(dir, 'calibre-gui.desktop'), 'wb')/g" \
-e "/des = ('calibre-gui.desktop', 'calibre-lrfviewer.desktop',/,/f = open('calibre-mimetypes', 'wb')/c \ \
dir = os.path.join(self.opts.staging_sharedir,'../mime/packages/')\n \
os.makedirs(dir)\n \
f = open(os.path.join(dir, 'calibre.xml'), 'wb')" \
-e "/self.mime_resources.append('calibre-mimetypes')/,/check_call('xdg-mime install .\/calibre-mimetypes', shell=True)/d" \
-i src/calibre/linux.py
# Larryhaja patches
sed -e "/self.create_uninstaller()/,/os.rmdir(config_dir)/d" \
-e "s|self.opts.staging_sharedir, 'man/man1'|self.opts.staging_root, 'usr/share/man/man1'|" \
-e "s|manpath, prog+'.1'+__appname__+'.bz2'|manpath, prog+'.1'+'.bz2'|" \
-e "s:old_udev = '/etc:old_udev = '${pkgdir}/etc:" -i src/calibre/linux.py
sed -e "s/ldflags = shlex.split(ldflags)/ldflags = shlex.split(ldflags) + ['-fPIC']/" -i setup/extensions.py
# Disable unnecessary privilege dropping
sed -e "s:if os.geteuid() == 0:if False and os.geteuid() == 0:" -i setup/install.py
python2 setup.py build
}
package() {
cd ${pkgname}
mkdir -p ${pkgdir}/lib/python2.7/site-packages
python2 setup.py install --root=${pkgdir} --prefix=/usr \
--staging-bindir=${pkgdir}/usr/bin \
--staging-libdir=${pkgdir}/usr/lib \
--staging-sharedir=${pkgdir}/usr/share
find ${pkgdir} -type d -empty -delete
sed -i -e "s|#![ ]*/usr/bin/python$|#!/usr/bin/python2|" \
-e "s|#![ ]*/usr/bin/env *python$|#!/usr/bin/env python2|" \
$( find "${pkgdir}" -type f -regex ".+\.py\|.+\.recipe" )
# Decompress the man pages so makepkg will do it for us.
for decom in ${pkgdir}/usr/share/man/man1/*.bz2; do
bzip2 -d ${decom}
done
find "${pkgdir}/usr/bin" -type f -exec sed -i -e "s|#![ ]*/usr/bin/env *python$|#!/usr/bin/env python2|" {} +
}