diff --git a/osx/macosx-builder.py b/osx/macosx-builder.py index 54ac745..b9652f5 100644 --- a/osx/macosx-builder.py +++ b/osx/macosx-builder.py @@ -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): """