From 99c942d277c2e759cc77c0fb7ca5a596fea2ab26 Mon Sep 17 00:00:00 2001 From: Raoul Snyman Date: Sun, 9 Nov 2014 01:47:37 +0200 Subject: [PATCH] Modify OS X builder to build specific release versions --- osx/macosx-builder.py | 77 +++++++++++++++++++++++-------------------- 1 file changed, 42 insertions(+), 35 deletions(-) diff --git a/osx/macosx-builder.py b/osx/macosx-builder.py index afd41e9..fb8cc53 100644 --- a/osx/macosx-builder.py +++ b/osx/macosx-builder.py @@ -68,17 +68,10 @@ macosx-builder.py Mako Mako Templates for Python. This package is required for building the - remote plugin. It can be installed by going to your - python_directory\scripts\.. and running "easy_install Mako". If you do not - have easy_install, the Mako package can be obtained here: + remote plugin. - http://www.makotemplates.org/download.html - -SQLAlchemy Migrate - Required for the databases used in OpenLP. The package can be - obtained here: - - http://code.google.com/p/sqlalchemy-migrate/ +Alembic + Required for upgrading the databases used in OpenLP. MuPDF Required for PDF support in OpenLP. Install using macports, or use the @@ -89,32 +82,22 @@ MachOLib used by Mac OS X. Used to relink the mudraw binary from MuPDF to the bundled libraries. Install using macports or pip. -MachOLib - Python library to analyze and edit Mach-O headers, the executable format - used by Mac OS X. Used to relink the mudraw binary from MuPDF to the bundled - libraries. Install using macports or pip. - config.ini.default The configuration file contains settings of the version string to include in the bundle as well as directory and file settings for different purposes (e.g. PyInstaller location or installer background image) -To start the build process do a +To install everything you need to install MacPorts. Once MacPorts is installed +and up-to-date, run the following command:: - make + $ sudo port install python34 py34-pyqt4 py34-sphinx py34-sqlalchemy \ + py34-macholib py34-mako py34-alembic py34-enchant \ + py34-beautifulsoup4 py34-lxml py34-nose -The result should be a {openlp_dmgname}.dmg -file in the same directory. If something went wrong - this sometimes happen -with the graphical commands in the Apple script - do a +You may need to install chardet via pip:: - make clean + $ sudo pip install chardet -and start the build process again. If you want to execute only parts of the -build process you can specify different make targets - - make view -- runs the Apple scripts to set the icons - make package -- creates the dmg file and copies the application files - make bundle -- compresses the dmg file and sets the dmg file icon """ import os @@ -220,6 +203,8 @@ class MacosxBuilder(object): parser.add_argument('--devel', dest='devel', action='store_true', default=False, help='Development build does not have set icons for .dmg file ' 'and .dmg filename contains bzr revision number.') + parser.add_argument('--release', dest='release', metavar='VERSION', + help='Build a release version of OpenLP with the version specified') parser.add_argument('-d', '--documentation', metavar='DOCS', dest='docs', help='Specify the path to the documentation branch.') parser.add_argument('-c', '--config', metavar='CONFIG', dest='config', @@ -277,16 +262,22 @@ class MacosxBuilder(object): self.docs_path = os.path.abspath(self.args.docs) else: self.docs_path = self.config.get('paths', 'documentation') - self.openlp_script = os.path.abspath(os.path.join(self.branch_path, 'openlp.py')) - self.hooks_path = os.path.abspath(os.path.join(self.branch_path, self.config.get('paths', 'hooks'))) + if self.args.release: + self.version_number = self.args.release + self.work_path = os.path.abspath(os.path.join(self.branch_path, '..', 'OpenLP-' + self.version_number)) + else: + self.version_number = None + 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.dmg_background_img = os.path.abspath(self.config.get('paths', 'dmg_background')) - self.i18n_utils = os.path.join(self.branch_path, 'scripts', 'translation_utils.py') - self.source_path = os.path.join(self.branch_path, 'openlp') + 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.branch_path, 'resources', 'i18n') + 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') @@ -317,12 +308,27 @@ class MacosxBuilder(object): self._print(output) raise Exception('Error updating the code') + def export_release(self): + """ + Export a particular release + """ + if os.path.exists(self.work_path): + rmtree(self.work_path) + os.chdir(self.branch_path) + self._print('Exporting the release version...') + bzr = Popen(('bzr', 'export', '-r', 'tag:' + self.version_number, self.work_path), stdout=PIPE) + output = bzr.communicate()[0] + code = bzr.wait() + if code != 0: + self._print(output) + raise Exception('Error exporting the code') + def run_pyinstaller(self): """ Run PyInstaller on the branch to build an executable. """ self._print('Running PyInstaller...') - os.chdir(self.branch_path) + os.chdir(self.work_path) pyinstaller = Popen((self.python, self.pyinstaller, '--noconfirm', @@ -333,7 +339,7 @@ class MacosxBuilder(object): '--log-level=ERROR', # '--distpath', self.branch_path, # '-i', self.mac_icon, - '-p', self.branch_path, + '-p', self.work_path, '-n', 'OpenLP', self.openlp_script), stdout=PIPE) @@ -436,7 +442,6 @@ class MacosxBuilder(object): text = fr.read() text = text % {'openlp_version': self.version_string} fw.write(text) - fr.close() fw.close() @@ -703,6 +708,8 @@ class MacosxBuilder(object): self._print_verbose('') if not self.args.skip_update: self.update_code() + if self.args.release: + self.export_release() self.run_pyinstaller() self.write_version_file() self.copy_mac_bundle_files()