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,6 +127,7 @@ if not frozen_path or not os.path.exists(os.path.join(frozen_path, 'resources',
|
||||
frozen_path = None
|
||||
|
||||
for f in {mime_resources!r}:
|
||||
if os.path.exists(f):
|
||||
cmd = ['xdg-mime', 'uninstall', f]
|
||||
print ('Removing mime resource:', os.path.basename(f))
|
||||
ret = subprocess.call(cmd, shell=False)
|
||||
@ -890,14 +891,16 @@ class PostInstall:
|
||||
ak = x.partition('.')[0]
|
||||
if ak in APPDATA and os.access(appdata, os.W_OK):
|
||||
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(os.path.join(self.opts.staging_sharedir, MIME_BASE))
|
||||
if not getattr(self.opts, 'staged_install', False):
|
||||
cc(['xdg-mime', 'install', MIME])
|
||||
cc(['xdg-desktop-menu', 'forceupdate'])
|
||||
else:
|
||||
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:
|
||||
if self.opts.fatal_errors:
|
||||
raise
|
||||
|
Loading…
x
Reference in New Issue
Block a user