1
0
mirror of https://gitlab.com/openlp/packaging.git synced 2024-12-22 21:12:50 +00:00

Merge branch 'bzr2git' into 'master'

First stab at converting to use git while packaging.

See merge request openlp/packaging!1
This commit is contained in:
Raoul Snyman 2019-09-13 19:32:30 +00:00
commit 81e4db7463
3 changed files with 25 additions and 23 deletions

View File

@ -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 ' \ 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' \ '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 ' \ '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 ' \ '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. 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.' 'option with a version number will produce a build of that exact version.'
@ -99,12 +99,12 @@ class Builder(object):
raise Exception(err_msg) raise Exception(err_msg)
return output, error 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. Update the code in the branch.
""" """
os.chdir(work_path) os.chdir(work_path)
output, _ = self._run_command(['bzr', command] + args, err_msg) output, _ = self._run_command(['git', command] + args, err_msg)
return output return output
def get_platform(self): def get_platform(self):
@ -160,8 +160,8 @@ class Builder(object):
parser.add_argument('--skip-translations', action='store_true', default=False, parser.add_argument('--skip-translations', action='store_true', default=False,
help='Do NOT update the language translation files') 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('--debug', action='store_true', default=False, help='Create a debug build')
parser.add_argument('--tag-override', metavar='<tag>-bzr<revision>', default=None, parser.add_argument('--tag-override', metavar='<tag>-git<revision-count>-<commit-hash>', default=None,
help='Override tag and revision, should be in format <tag>-bzr<revision>') help='Override tag and revision, should be in format <tag>-git<revision-count>-<commit-hash>')
self.add_extra_args(parser) self.add_extra_args(parser)
self.args = parser.parse_args() self.args = parser.parse_args()
@ -250,12 +250,12 @@ class Builder(object):
Update the code in the branch. Update the code in the branch.
""" """
self._print('Reverting any changes to the code...') 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._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') err_msg='Error cleaning up extra files')
self._print('Updating the code...') 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): def export_release(self):
""" """
@ -264,7 +264,8 @@ class Builder(object):
if os.path.exists(self.work_path): if os.path.exists(self.work_path):
rmtree(self.work_path) rmtree(self.work_path)
self._print('Exporting the release version...') self._print('Exporting the release version...')
self._bzr('export', self.branch_path, ['-r', 'tag:' + self.version, self.work_path], # Note that it is very important that the prefix ends with a slash to get the files into the folder
self._git('checkout-index', self.branch_path, ['-f', '-a', '--prefix={folder}/'.format(folder=self.work_path)],
'Error exporting the code') 'Error exporting the code')
def get_extra_parameters(self): def get_extra_parameters(self):
@ -316,16 +317,17 @@ class Builder(object):
self.version = self.args.tag_override self.version = self.args.tag_override
else: else:
# This is a development build, get the tag and revision # 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() lines = output.strip().splitlines()
if len(lines) == 0: if len(lines) == 0:
tag = '0.0.0' tag = '0.0.0'
revision = '0'
else: else:
tag, revision = lines[-1].split() tag = lines[-1]
output = self._bzr('log', self.branch_path, ['--line', '-r', '-1'], 'Error running bzr log') revision_count = self._git('rev-list', self.branch_path, ['--count', 'HEAD'], 'Error running git rev-list')
revision = output.split(':')[0] revision_count = revision_count.strip()
self.version = '{tag}.dev{revision}'.format(tag=tag, revision=revision) sha = self._git('rev-parse', self.branch_path, ['--short', 'HEAD'], 'Error running git rev-parse')
sha = sha.strip()
self.version = '{tag}.git-r{revision}-{sha}'.format(tag=tag, revision=revision_count, sha=sha)
# Write the version to the version file # Write the version to the version file
with open(os.path.join(self.dist_path, '.version'), 'w') as version_file: with open(os.path.join(self.dist_path, '.version'), 'w') as version_file:
version_file.write(str(self.version)) version_file.write(str(self.version))

View File

@ -47,8 +47,8 @@ PyInstaller
https://github.com/matysek/pyinstaller branch python3 or https://github.com/matysek/pyinstaller branch python3 or
https://github.com/pyinstaller/pyinstaller branch python3 https://github.com/pyinstaller/pyinstaller branch python3
Bazaar Git
You need the command line "bzr" client installed. You need the command line "git" client installed.
OpenLP OpenLP
A checkout of the latest code, in a branch directory, which is in a Bazaar A checkout of the latest code, in a branch directory, which is in a Bazaar

View File

@ -50,8 +50,8 @@ HTML Help Workshop
PyInstaller PyInstaller
PyInstaller can be installed from pypi. PyInstaller can be installed from pypi.
Bazaar Git
You need the command line "bzr" client installed. You need the command line "git" client installed.
OpenLP OpenLP
A checkout of the latest code, in a branch directory, which is in a Bazaar 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: with open(os.path.join(config_dir, 'OpenLP-base.wxs'), 'rt') as base_file:
xml = base_file.read() xml = base_file.read()
progfilefolder = 'ProgramFiles64Folder' if self.arch == 'x64' else 'ProgramFilesFolder' 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'), xml = xml % dict(dialog=os.path.join(config_dir, 'WizardMain.bmp'),
banner=os.path.join(config_dir, 'WizardBanner.bmp'), banner=os.path.join(config_dir, 'WizardBanner.bmp'),
platform=self.arch, platform=self.arch,
@ -253,8 +253,8 @@ class WindowsBuilder(Builder):
""" """
self._print_verbose('... Creating PortableApps appinfo file ...') self._print_verbose('... Creating PortableApps appinfo file ...')
config_dir = os.path.dirname(self.config_path) config_dir = os.path.dirname(self.config_path)
if '-bzr' in self.version: if '-git' in self.version:
version, revision = self.version.split('-bzr') version, revision = self.version.split('-git')
version = version + '.0' * (2 - version.count('.')) version = version + '.0' * (2 - version.count('.'))
self.portable_version = version + '.' + revision self.portable_version = version + '.' + revision
else: else: