1
0
mirror of https://gitlab.com/openlp/packaging.git synced 2024-12-22 21:12:50 +00:00

Fix issue when mounted dmg is still in use by OSX Finder.

This commit is contained in:
Martin Zibricky 2012-12-01 13:41:58 +01:00
parent 07cceba2c6
commit 8c25375e04

View File

@ -113,6 +113,8 @@ build process you can specify different make targets
import os
import plistlib
import signal
import subprocess
import sys
from shutil import copy, rmtree
from subprocess import Popen, PIPE
@ -591,10 +593,22 @@ class MacosxBuilder(object):
u'Could not copy the background image, dmg creation failed.'
)
print 10 * 'A'
self.adjust_dmg_view(os.path.basename(dmg_volume_path))
# Unmount dmg file.
## Unmount dmg file.
self._print('... unmounting the dmg.')
# Sometimes it could happen that OSX Finder is blocking umount.
# We need to find this process and kill it.
try:
output = subprocess.check_output(['fuser', dmg_volume_path])
blocking_proc_pid = int(output.strip().split()[0])
if blocking_proc_pid:
os.kill(int(blocking_proc_pid), signal.SIGKILL)
except:
self._print('... failed to kill process using %s' % dmg_volume_path)
# Unmount dmg file.
self._run_command([self.hdiutil, 'detach', dmg_volume_path],
'Could not unmount the dmg file, dmg creation failed.'
)
@ -639,11 +653,9 @@ class MacosxBuilder(object):
f.close()
result = p.returncode
if (result != 0):
self._print('Adjusting dmg view failed.')
sys.exit(1)
self._print('Adjusting dmg view failed (non-zero exit code).')
except (IOError, OSError):
self._print('Adjusting dmg view failed.')
sys.exit(1)
def main(self):
"""