mirror of
https://gitlab.com/openlp/packaging.git
synced 2024-12-22 04:52: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:
commit
81e4db7463
@ -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='<tag>-bzr<revision>', default=None,
|
||||
help='Override tag and revision, should be in format <tag>-bzr<revision>')
|
||||
parser.add_argument('--tag-override', metavar='<tag>-git<revision-count>-<commit-hash>', default=None,
|
||||
help='Override tag and revision, should be in format <tag>-git<revision-count>-<commit-hash>')
|
||||
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,8 @@ 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],
|
||||
# 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')
|
||||
|
||||
def get_extra_parameters(self):
|
||||
@ -316,16 +317,17 @@ 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')
|
||||
lines = output.splitlines()
|
||||
output = self._git('tag', self.branch_path, ['--list'], err_msg='Error running git tag')
|
||||
lines = output.strip().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)
|
||||
tag = lines[-1]
|
||||
revision_count = self._git('rev-list', self.branch_path, ['--count', 'HEAD'], 'Error running git rev-list')
|
||||
revision_count = revision_count.strip()
|
||||
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
|
||||
with open(os.path.join(self.dist_path, '.version'), 'w') as version_file:
|
||||
version_file.write(str(self.version))
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user