← Back to team overview

openlp-core team mailing list archive

[Merge] lp:~raoul-snyman/openlp/osx-packaging-updates into lp:openlp/packaging

 

Raoul Snyman has proposed merging lp:~raoul-snyman/openlp/osx-packaging-updates into lp:openlp/packaging.

Requested reviews:
  OpenLP Core (openlp-core)

For more details, see:
https://code.launchpad.net/~raoul-snyman/openlp/osx-packaging-updates/+merge/293837

Various updates to the OS X packaging scripts:

1. Further attempts to make the DMG layout and background stick (still not working)
2. Create a shiny new icon for the DMG with the OpenLP logo on it
3. Create new versions of the app and DMG icons with the new logo for when we move to that
4. Make the builder script work better
-- 
Your team OpenLP Core is requested to review the proposed merge of lp:~raoul-snyman/openlp/osx-packaging-updates into lp:openlp/packaging.
=== modified file 'osx/applescript-adjust-dmg-view.master'
--- osx/applescript-adjust-dmg-view.master	2012-12-01 13:23:08 +0000
+++ osx/applescript-adjust-dmg-view.master	2016-05-04 22:31:55 +0000
@@ -1,31 +1,32 @@
 on run
-	-- wait for virus scanner
-	delay 2
+    -- wait for virus scanner
+    delay 2
 
-	tell application "Finder"
-		tell disk "%s"
-			open
-			set current view of container window to icon view
-			set toolbar visible of container window to false
-			set statusbar visible of container window to false
-			set the bounds of container window to {400, 100, 1100, 500}
-			set theViewOptions to the icon view options of container window
-			set arrangement of theViewOptions to not arranged
-			set icon size of theViewOptions to 128
-			set background picture of theViewOptions to file ".background:installer-background.png"
-			set position of item "%s" of container window to {160, 200}
-			set position of item "Applications" of container window to {550, 200}
-			set position of item ".background" of container window to {100, 500}
-			set position of item ".DS_Store" of container window to {200, 500}
-			set position of item ".fseventsd" of container window to {300, 500}
-			set position of item ".Trashes" of container window to {400, 500}
+    tell application "Finder"
+        tell disk "%(dmg_name)s"
+            open
+            set current view of container window to icon view
+            set toolbar visible of container window to false
+            set statusbar visible of container window to false
+            set the bounds of container window to {400, 100, 1100, 500}
+            set theViewOptions to the icon view options of container window
+            set arrangement of theViewOptions to not arranged
+            set icon size of theViewOptions to 128
+            set background picture of theViewOptions to file ".background:installer-background.png"
+            set position of item "%(app_name)s" of container window to {160, 200}
+            set position of item "Applications" of container window to {550, 200}
+            set position of item ".background" of container window to {100, 500}
+            set position of item ".DS_Store" of container window to {200, 500}
+            set position of item ".fseventsd" of container window to {300, 500}
+            set position of item ".Trashes" of container window to {400, 500}
             set position of item ".VolumeIcon.icns" of container window to {500, 500}
-			open
-			close
-			update without registering applications
-			-- wait until the virus scan completes
-			delay 5
-			-- eject
-		end tell
-	end tell
+            delay 5
+            close
+            open
+            update without registering applications
+            -- wait until the virus scan completes
+            delay 2
+            -- eject
+        end tell
+    end tell
 end run

=== modified file 'osx/config.ini.default'
--- osx/config.ini.default	2015-08-28 20:36:44 +0000
+++ osx/config.ini.default	2016-05-04 22:31:55 +0000
@@ -1,17 +1,19 @@
 [executables]
 sphinx = sphinx-build-3.4
-pyinstaller = %(projects)s/pyinstaller/pyinstaller.py
-lrelease = lrelease
+pyinstaller = %(projects)s/../pyinstaller/pyinstaller.py
+lrelease = /opt/local/libexec/qt5/bin/lrelease
 diskutil = diskutil
 hdiutil = hdiutil
 osascript = osascript
 mudrawbin = mudraw
+mutoolbin = mutool
 
 [paths]
 branch = %(projects)s/trunk
 documentation = %(projects)s/documentation
-macicon = %(here)s/OpenLP.icns
-bundleinfo = %(here)s/Info.plist
+app_icon = %(here)s/OpenLP.icns
+dmg_icon = %(here)s/openlp-dmg.icns
+bundle_info = %(here)s/Info.plist
 hooks = %(here)s/../pyinstaller-hooks
 dmg_background = %(here)s/DmgImageInstallBackground.png
 
@@ -20,4 +22,4 @@
 password =
 
 [codesigning]
-certificate = OpenLP
+certificate = org.openlp.OpenLP

=== modified file 'osx/macosx-builder.py'
--- osx/macosx-builder.py	2015-12-23 17:14:43 +0000
+++ osx/macosx-builder.py	2016-05-04 22:31:55 +0000
@@ -113,7 +113,6 @@
     """
     for path in os.environ["PATH"].split(os.pathsep):
         if os.access(os.path.join(path, command), os.X_OK):
-            print("%s/%s" % (path, command))
             return "%s/%s" % (path, command)
 
 
@@ -237,11 +236,12 @@
         """
         self.sphinx = _which(self.config.get('executables', 'sphinx'))
         self.pyinstaller = os.path.abspath(self.config.get('executables', 'pyinstaller'))
-        self.lrelease = _which(self.config.get('executables', 'lrelease'))
+        self.lrelease = self.config.get('executables', 'lrelease')
         self.diskutil = _which(self.config.get('executables', 'diskutil'))
-        self.hdiutil = _which(self.config.get('executables', 'hdiutil'))
+        self.hdiutil = self.config.get('executables', 'hdiutil')
         self.osascript = _which(self.config.get('executables', 'osascript'))
         self.mudraw_bin = _which(self.config.get('executables', 'mudrawbin'))
+        self.mutool_bin = _which(self.config.get('executables', 'mutoolbin'))
 
     def setup_paths(self):
         """
@@ -263,20 +263,21 @@
             self.work_path = self.branch_path
         self.openlp_script = os.path.abspath(os.path.join(self.work_path, 'openlp.py'))
         self.hooks_path = os.path.abspath(os.path.join(self.work_path, self.config.get('paths', 'hooks')))
-        self.mac_icon = os.path.abspath(self.config.get('paths', 'macicon'))
-        self.bundle_info = os.path.abspath(self.config.get('paths', 'bundleinfo'))
+        self.app_icon = os.path.abspath(self.config.get('paths', 'app_icon'))
+        self.dmg_icon = os.path.abspath(self.config.get('paths', 'dmg_icon'))
+        self.bundle_info = os.path.abspath(self.config.get('paths', 'bundle_info'))
         self.dmg_background_img = os.path.abspath(self.config.get('paths', 'dmg_background'))
         self.i18n_utils = os.path.join(self.work_path, 'scripts', 'translation_utils.py')
         self.source_path = os.path.join(self.work_path, 'openlp')
         self.manual_path = os.path.join(self.docs_path, 'manual')
         self.manual_build_path = os.path.join(self.manual_path, 'build')
         self.i18n_path = os.path.join(self.work_path, 'resources', 'i18n')
-        self.build_path = os.path.join(self.branch_path, 'build')
-        self.dist_app_path = os.path.join(self.branch_path, 'dist', 'OpenLP.app')
-        self.dist_path = os.path.join(self.branch_path, 'dist', 'OpenLP.app', 'Contents', 'MacOS')
+        self.build_path = os.path.join(self.work_path, 'build')
+        self.dist_app_path = os.path.join(self.work_path, 'dist', 'OpenLP.app')
+        self.dist_path = os.path.join(self.work_path, 'dist', 'OpenLP.app', 'Contents', 'MacOS')
 
         # Path to Qt translation files.
-        from PyQt4.QtCore import QCoreApplication
+        from PyQt5.QtCore import QCoreApplication
 
         qt_plug_dir = str(list(QCoreApplication.libraryPaths())[0])
         self.qt_translat_path = os.path.join(os.path.dirname(qt_plug_dir), 'translations')
@@ -330,8 +331,7 @@
                '--noupx',
                '--additional-hooks-dir', self.hooks_path,
                '--runtime-hook', os.path.join(self.hooks_path, 'rthook_ssl.py'),
-               '-i', self.mac_icon,
-               '-p', self.work_path,
+               '-i', self.app_icon,
                '-n', 'OpenLP',
                self.openlp_script]
         if not self.args.verbose:
@@ -431,7 +431,7 @@
         """
         Copy Info.plist and OpenLP.icns to app bundle.
         """
-        copy(self.mac_icon, os.path.join(self.dist_app_path, 'Contents', 'Resources', os.path.basename(self.mac_icon)))
+        copy(self.app_icon, os.path.join(self.dist_app_path, 'Contents', 'Resources', os.path.basename(self.app_icon)))
         # Add OpenLP version to Info.plist and put it to app bundle.
         fr = open(self.bundle_info, 'r')
         fw = open(os.path.join(self.dist_app_path, 'Contents', os.path.basename(self.bundle_info)), 'w')
@@ -455,17 +455,32 @@
         if self.mudraw_bin and os.path.isfile(self.mudraw_bin):
             copy(os.path.join(self.mudraw_bin), os.path.join(self.dist_path, 'mudraw'))
             self.relink_mudraw()
+        elif self.mutool_bin and os.path.isfile(self.mutool_bin):
+            copy(os.path.join(self.mutool_bin), os.path.join(self.dist_path, 'mutool'))
+            self.relink_mutool()
         else:
-            self._print('... WARNING: mudraw not found')
+            self._print('... WARNING: mudraw and mutool not found')
 
     def relink_mudraw(self):
         """
         Relink mudraw to bundled libraries
         """
-        self._print('Linking mudraw with bundled libraries...')
-        libname = os.path.join(self.dist_path, 'mudraw')
+        self.relink_mupdf('mudraw')
+
+    def relink_mutool(self):
+        """
+        Relink mudraw to bundled libraries
+        """
+        self.relink_mupdf('mutool')
+
+    def relink_mupdf(self, bin_name):
+        """
+        Relink mupdf to bundled libraries
+        """
+        self._print('Linking {bin_name} with bundled libraries...'.format(bin_name=bin_name))
+        libname = os.path.join(self.dist_path, bin_name)
         distname = os.path.relpath(self.dist_path, libname)
-        self._print_verbose('... mudraw path %s', libname)
+        self._print_verbose('... {bin_name} path {path}'.format(bin_name=bin_name, path=libname))
 
         # Determine how many directories up is the directory with shared
         # dynamic libraries. '../'
@@ -613,7 +628,7 @@
         else:
             dmg_name = 'OpenLP-' + str(self.version_tag) + '.dmg'
 
-        dmg_file = os.path.join(self.branch_path, 'build', dmg_name)
+        dmg_file = os.path.join(self.work_path, 'build', dmg_name)
         # Remove dmg if it exists.
         if os.path.exists(dmg_file):
             os.remove(dmg_file)
@@ -644,7 +659,7 @@
         # 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], 'Could not copy the dmg icon file, dmg creation failed.')
+        self._run_command(['cp', self.dmg_icon, dmg_icon], '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.
@@ -684,7 +699,7 @@
 
         # Compress dmg file.
         self._print('... compressing the dmg file')
-        compressed_dmg = os.path.join(self.branch_path, 'dist', os.path.basename(dmg_file))  # Put dmg to 'dist' dir.
+        compressed_dmg = os.path.join(self.work_path, 'dist', os.path.basename(dmg_file))  # Put dmg to 'dist' dir.
         # Remove dmg if it exists.
         if os.path.exists(compressed_dmg):
             os.remove(compressed_dmg)
@@ -708,11 +723,12 @@
 
     def adjust_dmg_view(self, dmg_volume_name):
         try:
-            # TODO: Use only one applescript file. Remove one for osx 10.5.
-            f = open(os.path.join(self.script_path, 'applescript-adjust-dmg-view.master'))
-            p = Popen([self.osascript], stdin=PIPE)
-            p.communicate(bytes(f.read() % (dmg_volume_name, 'OpenLP'), 'utf-8'))
-            f.close()
+            master_script = os.path.join(self.script_path, 'applescript-adjust-dmg-view.master')
+            apple_script = os.path.join(self.script_path, 'adjust-dmg-view.applescript')
+            with open(master_script) as r, open(apple_script, 'w') as w:
+                apple_script = r.read() % {'dmg_name': dmg_volume_name, 'app_name': 'OpenLP.app'}
+                w.write(apple_script)
+            p = Popen([self.osascript, apple_script])
             result = p.returncode
             if (result != 0):
                 self._print('Adjusting dmg view failed (non-zero exit code).')
@@ -732,7 +748,12 @@
         self._print_verbose('"hooks" path: ............%s', self.hooks_path)
         self._print_verbose('PyInstaller: .............%s', self.pyinstaller)
         self._print_verbose('Documentation branch path:%s', self.docs_path)
-        self._print_verbose('Mudraw binary ............%s', self.mudraw_bin)
+        if self.mudraw_bin:
+            self._print_verbose('mudraw binary ............%s', self.mudraw_bin)
+        elif self.mutool_bin:
+            self._print_verbose('mutool binary ............%s', self.mutool_bin)
+        else:
+            self._print_verbose('mutool/mudraw ............Not found')
         self._print_verbose('')
         if not self.args.skip_update:
             self.update_code()

=== added file 'osx/openlp-dmg.icns'
Binary files osx/openlp-dmg.icns	1970-01-01 00:00:00 +0000 and osx/openlp-dmg.icns	2016-05-04 22:31:55 +0000 differ
=== added file 'osx/openlp-dmg.png'
Binary files osx/openlp-dmg.png	1970-01-01 00:00:00 +0000 and osx/openlp-dmg.png	2016-05-04 22:31:55 +0000 differ
=== added file 'osx/openlp-logo-new.png'
Binary files osx/openlp-logo-new.png	1970-01-01 00:00:00 +0000 and osx/openlp-logo-new.png	2016-05-04 22:31:55 +0000 differ
=== added file 'osx/openlp-logo-new.png.icns'
Binary files osx/openlp-logo-new.png.icns	1970-01-01 00:00:00 +0000 and osx/openlp-logo-new.png.icns	2016-05-04 22:31:55 +0000 differ
=== added file 'osx/openlp-new-dmg.png'
Binary files osx/openlp-new-dmg.png	1970-01-01 00:00:00 +0000 and osx/openlp-new-dmg.png	2016-05-04 22:31:55 +0000 differ
=== added file 'osx/openlp-new-dmg.png.icns'
Binary files osx/openlp-new-dmg.png.icns	1970-01-01 00:00:00 +0000 and osx/openlp-new-dmg.png.icns	2016-05-04 22:31:55 +0000 differ

Follow ups