mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-07 10:14:46 -04:00
install: fix calibre-uninstall relying on the source tree
Injecting the location of the mime_resources file from P() in non-frozen builds will depend on the mime resource from the source tree rather than the same location during install time... a source tree which may be deleted after successful installation. On a frozen build, or when using 'develop' instead of 'install', this path will be the same, and things just work. The solution is to add *both* paths, and try to uninstall whichever one exists.
This commit is contained in:
parent
2a63948440
commit
adcc2c5539
@ -127,11 +127,12 @@ if not frozen_path or not os.path.exists(os.path.join(frozen_path, 'resources',
|
|||||||
frozen_path = None
|
frozen_path = None
|
||||||
|
|
||||||
for f in {mime_resources!r}:
|
for f in {mime_resources!r}:
|
||||||
cmd = ['xdg-mime', 'uninstall', f]
|
if os.path.exists(f):
|
||||||
print ('Removing mime resource:', os.path.basename(f))
|
cmd = ['xdg-mime', 'uninstall', f]
|
||||||
ret = subprocess.call(cmd, shell=False)
|
print ('Removing mime resource:', os.path.basename(f))
|
||||||
if ret != 0:
|
ret = subprocess.call(cmd, shell=False)
|
||||||
print ('WARNING: Failed to remove mime resource', f)
|
if ret != 0:
|
||||||
|
print ('WARNING: Failed to remove mime resource', f)
|
||||||
|
|
||||||
for x in tuple({manifest!r}) + tuple({appdata_resources!r}) + (os.path.abspath(__file__), __file__, frozen_path):
|
for x in tuple({manifest!r}) + tuple({appdata_resources!r}) + (os.path.abspath(__file__), __file__, frozen_path):
|
||||||
if not x or not os.path.exists(x):
|
if not x or not os.path.exists(x):
|
||||||
@ -890,14 +891,16 @@ class PostInstall:
|
|||||||
ak = x.partition('.')[0]
|
ak = x.partition('.')[0]
|
||||||
if ak in APPDATA and os.access(appdata, os.W_OK):
|
if ak in APPDATA and os.access(appdata, os.W_OK):
|
||||||
self.appdata_resources.append(write_appdata(ak, APPDATA[ak], appdata, translators))
|
self.appdata_resources.append(write_appdata(ak, APPDATA[ak], appdata, translators))
|
||||||
MIME = P('calibre-mimetypes.xml')
|
MIME_BASE = 'calibre-mimetypes.xml'
|
||||||
|
MIME = P(MIME_BASE)
|
||||||
self.mime_resources.append(MIME)
|
self.mime_resources.append(MIME)
|
||||||
|
self.mime_resources.append(os.path.join(self.opts.staging_sharedir, MIME_BASE))
|
||||||
if not getattr(self.opts, 'staged_install', False):
|
if not getattr(self.opts, 'staged_install', False):
|
||||||
cc(['xdg-mime', 'install', MIME])
|
cc(['xdg-mime', 'install', MIME])
|
||||||
cc(['xdg-desktop-menu', 'forceupdate'])
|
cc(['xdg-desktop-menu', 'forceupdate'])
|
||||||
else:
|
else:
|
||||||
from shutil import copyfile
|
from shutil import copyfile
|
||||||
copyfile(MIME, os.path.join(env['XDG_DATA_DIRS'], 'mime', 'packages', os.path.basename(MIME)))
|
copyfile(MIME, os.path.join(env['XDG_DATA_DIRS'], 'mime', 'packages', MIME_BASE))
|
||||||
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