diff --git a/builders/builder.py b/builders/builder.py index 76139c6..3fddda6 100644 --- a/builders/builder.py +++ b/builders/builder.py @@ -32,7 +32,7 @@ from subprocess import Popen, PIPE BUILDER_DESCRIPTION = 'Build OpenLP for {platform}. Options are provided on both the command line and a ' \ 'configuration file. Options in the configuration file are overridden by the command line options.\n\n' \ 'This build system can produce either development or release builds. A development release uses the ' \ - 'code as-is in the specified branch directory. The release build exports a tag from bzr and uses the ' \ + 'code as-is in the specified branch directory. The release build exports a tag from git and uses the ' \ 'exported code for building. The two modes are invoked by the presence or absence of the --release ' \ 'option. If this option is omitted, a development build is built, while including the --release ' \ 'option with a version number will produce a build of that exact version.' @@ -99,12 +99,12 @@ class Builder(object): raise Exception(err_msg) return output, error - def _bzr(self, command, work_path, args=[], err_msg='There was an error running bzr'): + def _git(self, command, work_path, args=[], err_msg='There was an error running git'): """ Update the code in the branch. """ os.chdir(work_path) - output, _ = self._run_command(['bzr', command] + args, err_msg) + output, _ = self._run_command(['git', command] + args, err_msg) return output def get_platform(self): @@ -160,8 +160,8 @@ class Builder(object): parser.add_argument('--skip-translations', action='store_true', default=False, help='Do NOT update the language translation files') parser.add_argument('--debug', action='store_true', default=False, help='Create a debug build') - parser.add_argument('--tag-override', metavar='-bzr', default=None, - help='Override tag and revision, should be in format -bzr') + parser.add_argument('--tag-override', metavar='-git-', default=None, + help='Override tag and revision, should be in format -git-') self.add_extra_args(parser) self.args = parser.parse_args() @@ -250,12 +250,12 @@ class Builder(object): Update the code in the branch. """ self._print('Reverting any changes to the code...') - self._bzr('revert', self.branch_path, err_msg='Error reverting the code') + self._git('reset', self.branch_path, ['--hard'], err_msg='Error reverting the code') self._print('Cleaning any extra files...') - self._bzr('clean-tree', self.branch_path, ['--quiet', '--force', '--ignored', '--unknown'], + self._git('clean', self.branch_path, ['--quiet', '--force', '-d'], err_msg='Error cleaning up extra files') self._print('Updating the code...') - self._bzr('update', self.branch_path, err_msg='Error updating the code') + self._git('pull', self.branch_path, ['--rebase'], err_msg='Error updating the code') def export_release(self): """ @@ -264,7 +264,7 @@ class Builder(object): if os.path.exists(self.work_path): rmtree(self.work_path) self._print('Exporting the release version...') - self._bzr('export', self.branch_path, ['-r', 'tag:' + self.version, self.work_path], + self._git('checkout-index', self.branch_path, ['-f', '-a', '--prefix={folder}'.format(folder=self.work_path)], 'Error exporting the code') def get_extra_parameters(self): @@ -316,16 +316,16 @@ class Builder(object): self.version = self.args.tag_override else: # This is a development build, get the tag and revision - output = self._bzr('tags', self.branch_path, err_msg='Error running bzr tags') + output = self._git('tag', self.branch_path, ['--list'], err_msg='Error running git tag') lines = output.splitlines() if len(lines) == 0: tag = '0.0.0' - revision = '0' else: - tag, revision = lines[-1].split() - output = self._bzr('log', self.branch_path, ['--line', '-r', '-1'], 'Error running bzr log') - revision = output.split(':')[0] - self.version = '{tag}.dev{revision}'.format(tag=tag, revision=revision) + tmp, ref_tag = lines[-1].split() + tag = ref_tag.split('/')[2] + revision = self._git('rev-list', self.branch_path, ['--count', 'HEAD'], 'Error running git rev-list') + sha = self._git('rev-parse', self.branch_path, ['--short', 'HEAD'], 'Error running git rev-parse') + self.version = '{tag}.git-{revision}-{sha}'.format(tag=tag, revision=revision, sha=sha) # Write the version to the version file with open(os.path.join(self.dist_path, '.version'), 'w') as version_file: version_file.write(str(self.version)) diff --git a/builders/macosx-builder.py b/builders/macosx-builder.py index ed2dfe4..e48ef69 100644 --- a/builders/macosx-builder.py +++ b/builders/macosx-builder.py @@ -47,8 +47,8 @@ PyInstaller https://github.com/matysek/pyinstaller branch python3 or https://github.com/pyinstaller/pyinstaller branch python3 -Bazaar - You need the command line "bzr" client installed. +Git + You need the command line "git" client installed. OpenLP A checkout of the latest code, in a branch directory, which is in a Bazaar diff --git a/builders/windows-builder.py b/builders/windows-builder.py index 5d2b482..bce060a 100644 --- a/builders/windows-builder.py +++ b/builders/windows-builder.py @@ -50,8 +50,8 @@ HTML Help Workshop PyInstaller PyInstaller can be installed from pypi. -Bazaar - You need the command line "bzr" client installed. +Git + You need the command line "git" client installed. OpenLP A checkout of the latest code, in a branch directory, which is in a Bazaar @@ -196,7 +196,7 @@ class WindowsBuilder(Builder): with open(os.path.join(config_dir, 'OpenLP-base.wxs'), 'rt') as base_file: xml = base_file.read() progfilefolder = 'ProgramFiles64Folder' if self.arch == 'x64' else 'ProgramFilesFolder' - windows_version = self.version.replace('-bzr', '.') + windows_version = self.version.replace('-git', '.') xml = xml % dict(dialog=os.path.join(config_dir, 'WizardMain.bmp'), banner=os.path.join(config_dir, 'WizardBanner.bmp'), platform=self.arch, @@ -253,8 +253,8 @@ class WindowsBuilder(Builder): """ self._print_verbose('... Creating PortableApps appinfo file ...') config_dir = os.path.dirname(self.config_path) - if '-bzr' in self.version: - version, revision = self.version.split('-bzr') + if '-git' in self.version: + version, revision = self.version.split('-git') version = version + '.0' * (2 - version.count('.')) self.portable_version = version + '.' + revision else: