mirror of
https://gitlab.com/openlp/packaging.git
synced 2024-12-22 13:02:50 +00:00
Fix setting dmg icon for osx build. Icon is now set without Mac gui (Finder).
This commit is contained in:
parent
12fd1af4fb
commit
04c73e4c45
0
osx/DmgImageInstallBackground.png
Executable file → Normal file
0
osx/DmgImageInstallBackground.png
Executable file → Normal file
Before Width: | Height: | Size: 48 KiB After Width: | Height: | Size: 48 KiB |
@ -555,23 +555,38 @@ class MacosxBuilder(object):
|
|||||||
u'Could not copy app bundle, dmg creation failed.'
|
u'Could not copy app bundle, dmg creation failed.'
|
||||||
)
|
)
|
||||||
|
|
||||||
self._print('... Copying the background image.')
|
|
||||||
os.mkdir(os.path.join(dmg_volume_path, '.background'))
|
|
||||||
self._run_command(['cp', self.dmg_background_img,
|
|
||||||
os.path.join(dmg_volume_path,
|
|
||||||
'.background/installer-background.png')],
|
|
||||||
u'Could not copy the background image, dmg creation failed.'
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
# Set dmg background. Requires running Mac OS X gui.
|
# Set dmg background. Requires running Mac OS X gui.
|
||||||
# TODO: better formatting and code refactoring
|
# TODO: better formatting and code refactoring
|
||||||
if not self.args.devel:
|
if not self.args.devel:
|
||||||
|
self._print('... Setting the background image.')
|
||||||
|
|
||||||
|
os.mkdir(os.path.join(dmg_volume_path, '.background'))
|
||||||
|
self._run_command(['cp', self.dmg_background_img,
|
||||||
|
os.path.join(dmg_volume_path,
|
||||||
|
'.background/installer-background.png')],
|
||||||
|
u'Could not copy the background image, dmg creation failed.'
|
||||||
|
)
|
||||||
|
|
||||||
self.adjust_package_view({'openlp_dmg_icon_file':
|
self.adjust_package_view({'openlp_dmg_icon_file':
|
||||||
self.dmg_background_img,'openlp_appname': 'OpenLP' },
|
self.dmg_background_img,'openlp_appname': 'OpenLP' },
|
||||||
os.path.join(self.script_path,
|
os.path.join(self.script_path,
|
||||||
'applescript-adjustview-10-6.master'))
|
'applescript-adjustview-10-6.master'))
|
||||||
|
|
||||||
|
# Set icon for dmg file.
|
||||||
|
# http://endrift.com/blog/2010/06/14/dmg-files-volume-icons-cli/
|
||||||
|
self._print('... Setting the dmg icon.')
|
||||||
|
dmg_icon = os.path.join(dmg_volume_path, '.VolumeIcon.icns')
|
||||||
|
self._run_command(['cp', self.mac_icon, dmg_icon],
|
||||||
|
u'Could not copy the dmg icon file, dmg creation failed.'
|
||||||
|
)
|
||||||
|
# Set proper dmg icon attributes.
|
||||||
|
self._run_command(['SetFile', '-c', 'icnC', dmg_icon],
|
||||||
|
'Could not set dmg icon attributes.')
|
||||||
|
# Ensures dmg icon will be used while mounted.
|
||||||
|
self._run_command(['SetFile', '-a', 'C', dmg_volume_path],
|
||||||
|
'Could not set dmg icon attributes.')
|
||||||
|
|
||||||
# Unmount dmg file.
|
# Unmount dmg file.
|
||||||
self._print('... unmounting the dmg.')
|
self._print('... unmounting the dmg.')
|
||||||
self._run_command([self.hdiutil, 'detach', dmg_volume_path],
|
self._run_command([self.hdiutil, 'detach', dmg_volume_path],
|
||||||
@ -606,9 +621,7 @@ class MacosxBuilder(object):
|
|||||||
self._print('Finished creating dmg file, resulting file: %s' %
|
self._print('Finished creating dmg file, resulting file: %s' %
|
||||||
compressed_dmg)
|
compressed_dmg)
|
||||||
|
|
||||||
# TODO Reimplement following actions.
|
self.dmg_file = compressed_dmg
|
||||||
#seticon_scriptname = "applescript-seticon-10-6.master"
|
|
||||||
#compress_view(settings, seticon_scriptname, dmg_file)
|
|
||||||
|
|
||||||
def adjust_package_view(self, settings, adjustview_scriptname):
|
def adjust_package_view(self, settings, adjustview_scriptname):
|
||||||
#logging.info('[%s] making adjustments to the view...', script_name)
|
#logging.info('[%s] making adjustments to the view...', script_name)
|
||||||
@ -635,7 +648,6 @@ class MacosxBuilder(object):
|
|||||||
# failed!', script_name, e)
|
# failed!', script_name, e)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
"""
|
"""
|
||||||
The main function to run the Mac OS X builder.
|
The main function to run the Mac OS X builder.
|
||||||
@ -648,7 +660,7 @@ class MacosxBuilder(object):
|
|||||||
self._print_verbose(u'Source path: .............%s', self.source_path)
|
self._print_verbose(u'Source path: .............%s', self.source_path)
|
||||||
self._print_verbose(u'"dist.app" path: .........%s', self.dist_app_path)
|
self._print_verbose(u'"dist.app" path: .........%s', self.dist_app_path)
|
||||||
self._print_verbose(u'"dist" path: .............%s', self.dist_path)
|
self._print_verbose(u'"dist" path: .............%s', self.dist_path)
|
||||||
self._print_verbose(u'"hooks" path: .............%s', self.hooks_path)
|
self._print_verbose(u'"hooks" path: ............%s', self.hooks_path)
|
||||||
self._print_verbose(u'PyInstaller: .............%s', self.pyinstaller)
|
self._print_verbose(u'PyInstaller: .............%s', self.pyinstaller)
|
||||||
self._print_verbose(u'Documentation branch path:%s', self.docs_path)
|
self._print_verbose(u'Documentation branch path:%s', self.docs_path)
|
||||||
self._print_verbose(u'')
|
self._print_verbose(u'')
|
||||||
@ -680,49 +692,3 @@ class MacosxBuilder(object):
|
|||||||
|
|
||||||
if __name__ == u'__main__':
|
if __name__ == u'__main__':
|
||||||
MacosxBuilder().main()
|
MacosxBuilder().main()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# TODO reimplement following options. They arenecessary for release builds.
|
|
||||||
def compress_view(settings, seticon_scriptname, dmg_file):
|
|
||||||
logging.info('[%s] setting icon of the dmg file...', script_name)
|
|
||||||
try:
|
|
||||||
f = open(seticon_scriptname)
|
|
||||||
p = subp.Popen(["osascript"], stdin=subp.PIPE)
|
|
||||||
p.communicate(f.read() % ((os.getcwd() + '/' +
|
|
||||||
settings['openlp_dmg_icon_file']), dmg_file))
|
|
||||||
f.close()
|
|
||||||
result = p.returncode
|
|
||||||
if (result != 0):
|
|
||||||
logging.error('[%s] could not set the icon to the dmg file, \
|
|
||||||
dmg creation failed!', script_name)
|
|
||||||
sys.exit(1)
|
|
||||||
except IOError, e:
|
|
||||||
logging.error('[%s] could not adjust the view (%s), dmg creation \
|
|
||||||
failed!', script_name, e)
|
|
||||||
sys.exit(1)
|
|
||||||
except OSError, e:
|
|
||||||
logging.error('[%s] could not set the icon to the dmg file(%s), \
|
|
||||||
dmg creation failed!', script_name, e)
|
|
||||||
sys.exit(1)
|
|
||||||
|
|
||||||
def old_main():
|
|
||||||
|
|
||||||
version = platform.mac_ver()[0]
|
|
||||||
# we only need the differenciation between leopard and snow leopard
|
|
||||||
if version.startswith("10.6") or version.startswith("10.7"):
|
|
||||||
SNOWLEOPARD = True
|
|
||||||
logging.info('[%s] using snow leopard scripts (version = %s)',
|
|
||||||
script_name, version)
|
|
||||||
else:
|
|
||||||
SNOWLEOPARD = False
|
|
||||||
logging.info('[%s] using leopard scripts (version = %s)', script_name,
|
|
||||||
version)
|
|
||||||
adjustview_scriptname = "applescript-adjustview-10-5.master"
|
|
||||||
seticon_scriptname = "applescript-seticon-10-5.master"
|
|
||||||
|
|
||||||
if not os.path.isfile(adjustview_scriptname) \
|
|
||||||
or not os.path.isfile(seticon_scriptname):
|
|
||||||
logging.error('[%s] could not find apple scripts for given OS X '
|
|
||||||
+ 'version %s', script_name, version)
|
|
||||||
sys.exit(1)
|
|
||||||
|
Loading…
Reference in New Issue
Block a user