mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Linux installer: When calling the xdg utilities use system libraries rather than the libraries bundled with calibre
This commit is contained in:
parent
e7e0aea695
commit
93545002ce
@ -5,6 +5,7 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
|||||||
|
|
||||||
import sys, os, cPickle, textwrap, stat
|
import sys, os, cPickle, textwrap, stat
|
||||||
from subprocess import check_call
|
from subprocess import check_call
|
||||||
|
from functools import partial
|
||||||
|
|
||||||
from calibre import __appname__, prints, guess_type
|
from calibre import __appname__, prints, guess_type
|
||||||
from calibre.constants import islinux, isnetbsd, isbsd
|
from calibre.constants import islinux, isnetbsd, isbsd
|
||||||
@ -346,19 +347,28 @@ class PostInstall:
|
|||||||
try:
|
try:
|
||||||
self.info('Setting up desktop integration...')
|
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), \
|
with TemporaryDirectory() as tdir, CurrentDir(tdir), \
|
||||||
PreserveMIMEDefaults():
|
PreserveMIMEDefaults():
|
||||||
render_img('mimetypes/lrf.png', 'calibre-lrf.png')
|
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'))
|
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',
|
self.icon_resources.append(('mimetypes', 'application-lrs',
|
||||||
'128'))
|
'128'))
|
||||||
render_img('lt.png', 'calibre-gui.png', width=256, height=256)
|
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'))
|
self.icon_resources.append(('apps', 'calibre-gui', '128'))
|
||||||
render_img('viewer.png', 'calibre-viewer.png')
|
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'))
|
self.icon_resources.append(('apps', 'calibre-viewer', '128'))
|
||||||
|
|
||||||
mimetypes = set([])
|
mimetypes = set([])
|
||||||
@ -385,14 +395,14 @@ class PostInstall:
|
|||||||
'calibre-ebook-viewer.desktop')
|
'calibre-ebook-viewer.desktop')
|
||||||
for x in des:
|
for x in des:
|
||||||
cmd = ['xdg-desktop-menu', 'install', '--noupdate', './'+x]
|
cmd = ['xdg-desktop-menu', 'install', '--noupdate', './'+x]
|
||||||
check_call(' '.join(cmd), shell=True)
|
cc(' '.join(cmd), shell=True)
|
||||||
self.menu_resources.append(x)
|
self.menu_resources.append(x)
|
||||||
check_call(['xdg-desktop-menu', 'forceupdate'])
|
cc(['xdg-desktop-menu', 'forceupdate'])
|
||||||
f = open('calibre-mimetypes', 'wb')
|
f = open('calibre-mimetypes', 'wb')
|
||||||
f.write(MIME)
|
f.write(MIME)
|
||||||
f.close()
|
f.close()
|
||||||
self.mime_resources.append('calibre-mimetypes')
|
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:
|
except Exception:
|
||||||
if self.opts.fatal_errors:
|
if self.opts.fatal_errors:
|
||||||
raise
|
raise
|
||||||
|
Loading…
x
Reference in New Issue
Block a user