mirror of
https://gitlab.com/openlp/packaging.git
synced 2024-12-21 12:32:51 +00:00
Add arch to dmg name, bundle applescript, parse pep440 version number
This commit is contained in:
parent
cdd1851f2d
commit
931faa3775
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,4 @@
|
||||
__pycache__
|
||||
*.pyc
|
||||
config.ini
|
||||
*.spec
|
||||
|
@ -23,6 +23,7 @@
|
||||
Base class for the Windows and macOS builders.
|
||||
"""
|
||||
import os
|
||||
import re
|
||||
import runpy
|
||||
import sys
|
||||
from argparse import ArgumentParser
|
||||
@ -39,6 +40,7 @@ BUILDER_DESCRIPTION = 'Build OpenLP for {platform}. Options are provided on both
|
||||
'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.'
|
||||
PEP440 = re.compile(r'(?P<major>\d)\.(?P<minor>\d)(\.(?P<fix>\d))?((?P<pre>a|b|rc)(?P<rel>\d))?')
|
||||
|
||||
|
||||
def _which(program):
|
||||
@ -157,6 +159,16 @@ class Builder(object):
|
||||
output, _ = self._run_command(['git', command] + args, err_msg)
|
||||
return output
|
||||
|
||||
def parse_pep440_version(self, version: str) -> dict:
|
||||
"""Parse a PEP440-compatible version number into a dictionary"""
|
||||
if m := PEP440.match(version):
|
||||
groups = m.groupdict()
|
||||
if not groups.get('fix'):
|
||||
groups['fix'] = '0'
|
||||
return groups
|
||||
else:
|
||||
return None
|
||||
|
||||
def get_platform(self):
|
||||
"""
|
||||
Return the platform we're building for
|
||||
|
@ -92,6 +92,7 @@ like this:
|
||||
|
||||
import glob
|
||||
import os
|
||||
import platform
|
||||
from pathlib import Path
|
||||
from shutil import copy, copytree, move, rmtree
|
||||
|
||||
@ -106,6 +107,13 @@ class MacOSXBuilder(Builder):
|
||||
The :class:`MacosxBuilder` class encapsulates everything that is needed
|
||||
to build a Mac OS X .dmg file.
|
||||
"""
|
||||
def _pep440_to_mac_version(self, version: str) -> str:
|
||||
"""Convert a PEP440-compatible version to a Mac compatible version"""
|
||||
if pep440 := self.parse_pep440_version(version):
|
||||
return f'{pep440["major"]}.{pep440["minor"]}.{pep440["fix"]}'
|
||||
else:
|
||||
return '0.0.0'
|
||||
|
||||
def _get_directory_size(self, directory):
|
||||
"""
|
||||
Return directory size - size of everything in the dir.
|
||||
@ -310,7 +318,7 @@ class MacOSXBuilder(Builder):
|
||||
with open(os.path.join(self.dist_app_path, 'Contents', os.path.basename(self.bundle_info_path)), 'w') as fw, \
|
||||
open(self.bundle_info_path, 'r') as fr:
|
||||
text = fr.read()
|
||||
text = text % {'openlp_version': self.version}
|
||||
text = text % {'openlp_version': self._pep440_to_mac_version(self.version)}
|
||||
fw.write(text)
|
||||
|
||||
def _copy_macosx_files(self):
|
||||
@ -337,8 +345,9 @@ class MacOSXBuilder(Builder):
|
||||
Create .dmg file.
|
||||
"""
|
||||
self._print('Creating dmg file...')
|
||||
dmg_name = 'OpenLP-{version}.dmg'.format(version=self.version)
|
||||
dmg_title = 'OpenLP {version}'.format(version=self.version)
|
||||
arch = platform.machine()
|
||||
dmg_name = f'OpenLP-{self.version}-{arch}.dmg'
|
||||
dmg_title = f'OpenLP {self.version}'
|
||||
|
||||
self.dmg_file = os.path.join(self.work_path, 'dist', dmg_name)
|
||||
# Remove dmg if it exists.
|
||||
@ -392,7 +401,7 @@ class MacOSXBuilder(Builder):
|
||||
"""
|
||||
self._print('Copying extra files for macOS...')
|
||||
# Exclude VLC for now, at least
|
||||
self._copy_vlc_files()
|
||||
# self._copy_vlc_files()
|
||||
self._copy_bundle_files()
|
||||
self._copy_macosx_files()
|
||||
self._install_pyro5()
|
||||
|
@ -97,7 +97,6 @@ Portable App Builds
|
||||
|
||||
import os
|
||||
import glob
|
||||
import re
|
||||
import sys
|
||||
from distutils import dir_util
|
||||
from hashlib import md5
|
||||
@ -110,9 +109,6 @@ from lxml.objectify import fromstring
|
||||
from builder import Builder
|
||||
|
||||
|
||||
PEP440 = re.compile(r'(?P<major>\d)\.(?P<minor>\d)(\.(?P<fix>\d))?((?P<pre>a|b|rc)(?P<rel>\d))?')
|
||||
|
||||
|
||||
class WindowsBuilder(Builder):
|
||||
"""
|
||||
The :class:`WindowsBuilder` class encapsulates everything that is needed
|
||||
@ -134,25 +130,22 @@ class WindowsBuilder(Builder):
|
||||
|
||||
def _pep440_to_windows_version(self, version: str) -> str:
|
||||
"""Convert a PEP440-compatible version string to a Windows version string"""
|
||||
if m := PEP440.match(version):
|
||||
groups = m.groupdict()
|
||||
if not groups.get('fix'):
|
||||
groups['fix'] = '0'
|
||||
if pep440 := self.parse_pep440_version(version):
|
||||
build_number = 5000
|
||||
if groups.get('pre'):
|
||||
if groups['pre'] == 'a':
|
||||
if pep440.get('pre'):
|
||||
if pep440['pre'] == 'a':
|
||||
build_number = 1000
|
||||
elif groups['pre'] == 'b':
|
||||
elif pep440['pre'] == 'b':
|
||||
build_number = 2000
|
||||
elif groups['pre'] == 'rc':
|
||||
elif pep440['pre'] == 'rc':
|
||||
build_number = 3000
|
||||
if groups.get('rel'):
|
||||
if pep440.get('rel'):
|
||||
try:
|
||||
rel = int(groups['rel'])
|
||||
rel = int(pep440['rel'])
|
||||
build_number += rel
|
||||
except ValueError:
|
||||
pass
|
||||
return f'{groups["major"]}.{groups["minor"]}.{groups["fix"]}.{build_number}'
|
||||
return f'{pep440["major"]}.{pep440["minor"]}.{pep440["fix"]}.{build_number}'
|
||||
else:
|
||||
return '0.0.0.0'
|
||||
|
||||
|
@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
||||
|
||||
###############################################################################
|
||||
# OpenLP - Open Source Lyrics Projection #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# Copyright (c) 2008-2019 OpenLP Developers #
|
||||
# --------------------------------------------------------------------------- #
|
||||
# This program is free software; you can redistribute it and/or modify it #
|
||||
# under the terms of the GNU General Public License as published by the Free #
|
||||
# Software Foundation; version 2 of the License. #
|
||||
# #
|
||||
# This program is distributed in the hope that it will be useful, but WITHOUT #
|
||||
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
|
||||
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
|
||||
# more details. #
|
||||
# #
|
||||
# You should have received a copy of the GNU General Public License along #
|
||||
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
hiddenimports = ['applescript']
|
@ -20,4 +20,4 @@
|
||||
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
|
||||
###############################################################################
|
||||
|
||||
hiddenimports = ['Pyro4']
|
||||
hiddenimports = ['Pyro5']
|
||||
|
Loading…
Reference in New Issue
Block a user