mirror of
https://gitlab.com/openlp/packaging.git
synced 2024-12-22 21:12:50 +00:00
Refactoring: Simplify code adjusting dmg view in osx build.
This commit is contained in:
parent
57441ec741
commit
d5e908f6ee
@ -1,34 +1,6 @@
|
|||||||
on saveImageWithItselfAsIcon(icon_image_file)
|
|
||||||
-- save icon_image_file with itself as icon
|
|
||||||
set icon_image_file_string to icon_image_file as string
|
|
||||||
tell application "Image Events"
|
|
||||||
launch
|
|
||||||
set icon_image to open file icon_image_file_string
|
|
||||||
save icon_image with icon
|
|
||||||
close icon_image
|
|
||||||
end tell
|
|
||||||
end saveImageWithItselfAsIcon
|
|
||||||
|
|
||||||
on CopyOrPaste(i, cv)
|
|
||||||
tell application "Finder"
|
|
||||||
activate
|
|
||||||
set infoWindow to open information window of i
|
|
||||||
set infoWindowName to name of infoWindow
|
|
||||||
end tell
|
|
||||||
tell application "System Events" to tell process "Finder" to tell window infoWindowName
|
|
||||||
keystroke tab -- select icon button
|
|
||||||
keystroke (cv & "w") using command down (* (copy or paste) + close window *)
|
|
||||||
end tell -- window 1 then process Finder then System Events
|
|
||||||
end CopyOrPaste
|
|
||||||
|
|
||||||
on run
|
on run
|
||||||
set icon_image_file to POSIX file "%s" as alias
|
|
||||||
set dmg_file to POSIX file "/Volumes/%s" as alias
|
|
||||||
|
|
||||||
my saveImageWithItselfAsIcon(icon_image_file)
|
|
||||||
-- wait for virus scanner
|
-- wait for virus scanner
|
||||||
delay 2
|
delay 2
|
||||||
-- my copyIconOfTo(icon_image_file, dmg_file)
|
|
||||||
|
|
||||||
tell application "Finder"
|
tell application "Finder"
|
||||||
tell disk "%s"
|
tell disk "%s"
|
||||||
|
@ -555,24 +555,6 @@ class MacosxBuilder(object):
|
|||||||
u'Could not copy app bundle, dmg creation failed.'
|
u'Could not copy app bundle, dmg creation failed.'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
# Set dmg background. Requires running Mac OS X gui.
|
|
||||||
# TODO: better formatting and code refactoring
|
|
||||||
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.dmg_background_img,'openlp_appname': 'OpenLP' },
|
|
||||||
os.path.join(self.script_path,
|
|
||||||
'applescript-adjustview-10-6.master'))
|
|
||||||
|
|
||||||
# Set icon for dmg file.
|
# Set icon for dmg file.
|
||||||
# http://endrift.com/blog/2010/06/14/dmg-files-volume-icons-cli/
|
# http://endrift.com/blog/2010/06/14/dmg-files-volume-icons-cli/
|
||||||
self._print('... Setting the dmg icon.')
|
self._print('... Setting the dmg icon.')
|
||||||
@ -587,6 +569,20 @@ class MacosxBuilder(object):
|
|||||||
self._run_command(['SetFile', '-a', 'C', dmg_volume_path],
|
self._run_command(['SetFile', '-a', 'C', dmg_volume_path],
|
||||||
'Could not set dmg icon attributes.')
|
'Could not set dmg icon attributes.')
|
||||||
|
|
||||||
|
# Set dmg background. Requires running Mac OS X gui.
|
||||||
|
# TODO: better formatting and code refactoring
|
||||||
|
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_dmg_view(os.path.basename(dmg_volume_path))
|
||||||
|
|
||||||
# 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],
|
||||||
@ -623,29 +619,20 @@ class MacosxBuilder(object):
|
|||||||
|
|
||||||
self.dmg_file = compressed_dmg
|
self.dmg_file = compressed_dmg
|
||||||
|
|
||||||
def adjust_package_view(self, settings, adjustview_scriptname):
|
def adjust_dmg_view(self, dmg_volume_name):
|
||||||
#logging.info('[%s] making adjustments to the view...', script_name)
|
|
||||||
try:
|
try:
|
||||||
f = open(adjustview_scriptname)
|
# TODO: Use only one applescript file. Remove one for osx 10.5.
|
||||||
|
f = open(os.path.join(self.script_path,
|
||||||
|
'applescript-adjustview-10-6.master'))
|
||||||
p = Popen(["osascript"], stdin=PIPE)
|
p = Popen(["osascript"], stdin=PIPE)
|
||||||
p.communicate(f.read() % (
|
p.communicate(f.read() % (dmg_volume_name, 'OpenLP'))
|
||||||
settings['openlp_dmg_icon_file'],
|
|
||||||
settings['openlp_appname'],
|
|
||||||
settings['openlp_appname'],
|
|
||||||
settings['openlp_appname']))
|
|
||||||
f.close()
|
f.close()
|
||||||
result = p.returncode
|
result = p.returncode
|
||||||
if (result != 0):
|
if (result != 0):
|
||||||
#logging.error('[%s] could not adjust the view, dmg creation \
|
self._print('Adjusting dmg view failed.')
|
||||||
# failed!', script_name)
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except IOError, e:
|
except (IOError, OSError):
|
||||||
#logging.error('[%s] could not adjust the view (%s), dmg creation \
|
self._print('Adjusting dmg view failed.')
|
||||||
# failed!', script_name, e)
|
|
||||||
sys.exit(1)
|
|
||||||
except OSError, e:
|
|
||||||
#logging.error('[%s] could not adjust the view (%s), dmg creation \
|
|
||||||
# failed!', script_name, e)
|
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
def main(self):
|
def main(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user