Linux installer: When calling the xdg utilities use system libraries rather than the libraries bundled with calibre

This commit is contained in:
Kovid Goyal 2012-07-07 10:11:18 +05:30
parent e7e0aea695
commit 93545002ce

View File

@ -5,6 +5,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
import sys, os, cPickle, textwrap, stat
from subprocess import check_call
from functools import partial
from calibre import __appname__, prints, guess_type
from calibre.constants import islinux, isnetbsd, isbsd
@ -346,19 +347,28 @@ class PostInstall:
try:
self.info('Setting up desktop integration...')
env = os.environ.copy()
cc = check_call
if getattr(sys, 'frozen_path', False) and 'LD_LIBRARY_PATH' in env:
paths = env.get('LD_LIBRARY_PATH', '').split(os.pathsep)
paths = [x for x in paths if x]
npaths = [x for x in paths if x != sys.frozen_path+'/lib']
env['LD_LIBRARY_PATH'] = os.pathsep.join(npaths)
cc = partial(check_call, env=env)
with TemporaryDirectory() as tdir, CurrentDir(tdir), \
PreserveMIMEDefaults():
render_img('mimetypes/lrf.png', 'calibre-lrf.png')
check_call('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png application-lrf', shell=True)
cc('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png application-lrf', shell=True)
self.icon_resources.append(('mimetypes', 'application-lrf', '128'))
check_call('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png text-lrs', shell=True)
cc('xdg-icon-resource install --noupdate --context mimetypes --size 128 calibre-lrf.png text-lrs', shell=True)
self.icon_resources.append(('mimetypes', 'application-lrs',
'128'))
render_img('lt.png', 'calibre-gui.png', width=256, height=256)
check_call('xdg-icon-resource install --noupdate --size 256 calibre-gui.png calibre-gui', shell=True)
cc('xdg-icon-resource install --noupdate --size 256 calibre-gui.png calibre-gui', shell=True)
self.icon_resources.append(('apps', 'calibre-gui', '128'))
render_img('viewer.png', 'calibre-viewer.png')
check_call('xdg-icon-resource install --size 128 calibre-viewer.png calibre-viewer', shell=True)
cc('xdg-icon-resource install --size 128 calibre-viewer.png calibre-viewer', shell=True)
self.icon_resources.append(('apps', 'calibre-viewer', '128'))
mimetypes = set([])
@ -385,14 +395,14 @@ class PostInstall:
'calibre-ebook-viewer.desktop')
for x in des:
cmd = ['xdg-desktop-menu', 'install', '--noupdate', './'+x]
check_call(' '.join(cmd), shell=True)
cc(' '.join(cmd), shell=True)
self.menu_resources.append(x)
check_call(['xdg-desktop-menu', 'forceupdate'])
cc(['xdg-desktop-menu', 'forceupdate'])
f = open('calibre-mimetypes', 'wb')
f.write(MIME)
f.close()
self.mime_resources.append('calibre-mimetypes')
check_call('xdg-mime install ./calibre-mimetypes', shell=True)
cc('xdg-mime install ./calibre-mimetypes', shell=True)
except Exception:
if self.opts.fatal_errors:
raise