mirror of
https://gitlab.com/openlp/packaging.git
synced 2024-12-22 04:52:50 +00:00
Use WiX instead of InnoSetup
This commit is contained in:
parent
dacbab0e4e
commit
a0ebb0a926
@ -1,5 +1,5 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
|
# vim: autoindent shiftwidth=4 expandtab textwidth=120 tabstop=4 softtabstop=4
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# OpenLP - Open Source Lyrics Projection #
|
# OpenLP - Open Source Lyrics Projection #
|
||||||
@ -216,7 +216,7 @@ class Builder(object):
|
|||||||
else:
|
else:
|
||||||
self.version = None
|
self.version = None
|
||||||
self.work_path = self.branch_path
|
self.work_path = self.branch_path
|
||||||
self.openlp_script = os.path.abspath(os.path.join(self.work_path, 'openlp-run.py'))
|
self.openlp_script = os.path.abspath(os.path.join(self.work_path, 'run_openlp.py'))
|
||||||
self.source_path = os.path.join(self.work_path, 'openlp')
|
self.source_path = os.path.join(self.work_path, 'openlp')
|
||||||
self.manual_path = os.path.join(self.documentation_path, 'manual')
|
self.manual_path = os.path.join(self.documentation_path, 'manual')
|
||||||
self.manual_build_path = os.path.join(self.manual_path, 'build')
|
self.manual_build_path = os.path.join(self.manual_path, 'build')
|
||||||
@ -267,10 +267,12 @@ class Builder(object):
|
|||||||
Run PyInstaller on the branch to build an executable.
|
Run PyInstaller on the branch to build an executable.
|
||||||
"""
|
"""
|
||||||
self._print('Running PyInstaller...')
|
self._print('Running PyInstaller...')
|
||||||
copy(os.path.join(self.work_path, 'openlp.py'), self.openlp_script)
|
|
||||||
os.chdir(self.work_path)
|
os.chdir(self.work_path)
|
||||||
cmd = [self.python,
|
if self.pyinstaller_exe.endswith('.py'):
|
||||||
self.pyinstaller_exe,
|
cmd = [self.python, self.pyinstaller_exe]
|
||||||
|
else:
|
||||||
|
cmd = [self.pyinstaller_exe]
|
||||||
|
cmd.extend([
|
||||||
'--clean',
|
'--clean',
|
||||||
'--noconfirm',
|
'--noconfirm',
|
||||||
'--windowed',
|
'--windowed',
|
||||||
@ -279,7 +281,8 @@ class Builder(object):
|
|||||||
'--runtime-hook', os.path.join(self.hooks_path, 'rthook_ssl.py'),
|
'--runtime-hook', os.path.join(self.hooks_path, 'rthook_ssl.py'),
|
||||||
'-i', self.icon_path,
|
'-i', self.icon_path,
|
||||||
'-n', 'OpenLP',
|
'-n', 'OpenLP',
|
||||||
self.openlp_script]
|
self.openlp_script
|
||||||
|
])
|
||||||
if self.args.verbose:
|
if self.args.verbose:
|
||||||
cmd.append('--log-level=DEBUG')
|
cmd.append('--log-level=DEBUG')
|
||||||
else:
|
else:
|
||||||
@ -423,7 +426,8 @@ class Builder(object):
|
|||||||
rmtree(self.manual_build_path)
|
rmtree(self.manual_build_path)
|
||||||
os.chdir(self.manual_path)
|
os.chdir(self.manual_path)
|
||||||
sphinx_build = self.get_sphinx_build()
|
sphinx_build = self.get_sphinx_build()
|
||||||
command = [self.sphinx_exe, '-b', sphinx_build, '-d', 'build/doctrees', 'source', 'build/{}'.format(sphinx_build)]
|
command = [self.sphinx_exe, '-b', sphinx_build, '-d', 'build/doctrees', 'source',
|
||||||
|
'build/{}'.format(sphinx_build)]
|
||||||
self._run_command(command, 'Error running Sphinx')
|
self._run_command(command, 'Error running Sphinx')
|
||||||
self.after_run_sphinx()
|
self.after_run_sphinx()
|
||||||
|
|
||||||
@ -472,5 +476,3 @@ class Builder(object):
|
|||||||
|
|
||||||
self._print('Done.')
|
self._print('Done.')
|
||||||
raise SystemExit()
|
raise SystemExit()
|
||||||
|
|
||||||
|
|
||||||
|
@ -118,8 +118,15 @@ import os
|
|||||||
from distutils import dir_util
|
from distutils import dir_util
|
||||||
from shutil import copy, move, rmtree
|
from shutil import copy, move, rmtree
|
||||||
|
|
||||||
|
from lxml.etree import fromstring, tostring
|
||||||
|
from lxml.builder import E
|
||||||
|
|
||||||
from builder import Builder
|
from builder import Builder
|
||||||
|
|
||||||
|
BLACKLIST = [
|
||||||
|
'pptviewlib.dll.intermediate.manifest'
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
class WindowsBuilder(Builder):
|
class WindowsBuilder(Builder):
|
||||||
"""
|
"""
|
||||||
@ -138,28 +145,95 @@ class WindowsBuilder(Builder):
|
|||||||
'Release|Win32'], 'Error building pptviewlib.dll')
|
'Release|Win32'], 'Error building pptviewlib.dll')
|
||||||
copy(os.path.join(self.pptviewlib_path, 'Release', 'pptviewlib.dll'), self.pptviewlib_path)
|
copy(os.path.join(self.pptviewlib_path, 'Release', 'pptviewlib.dll'), self.pptviewlib_path)
|
||||||
|
|
||||||
def _create_innosetup_file(self):
|
def _walk_dirs(self, dir_dict, path):
|
||||||
"""
|
"""
|
||||||
Create an InnoSetup file pointing to the branch being built.
|
Walk a dictionary according to path
|
||||||
"""
|
"""
|
||||||
self._print('Creating Inno Setup file...')
|
parts = path.split(os.sep)
|
||||||
config_dir = os.path.dirname(self.config_path)
|
search_key = parts.pop(0)
|
||||||
with open(os.path.join(config_dir, 'OpenLP.iss.default'), 'r') as input_file, \
|
if search_key in dir_dict.keys():
|
||||||
open(os.path.join(config_dir, 'OpenLP.iss'), 'w') as output_file:
|
if not parts:
|
||||||
content = input_file.read()
|
return dir_dict[search_key]
|
||||||
content = content.replace('%(branch)s', self.branch_path)
|
else:
|
||||||
content = content.replace('%(display_version)s', self.version.replace('-bzr', '.'))
|
return walk_dirs(dir_dict[search_key], os.sep.join(parts))
|
||||||
output_file.write(content)
|
else:
|
||||||
|
return None
|
||||||
|
|
||||||
def _run_innosetup(self):
|
def _get_fragments_from_files(self, start_dir):
|
||||||
"""
|
"""
|
||||||
Run InnoSetup to create an installer.
|
Walk down a directory recursively and build up the XML for WiX
|
||||||
"""
|
"""
|
||||||
self._print('Running Inno Setup...')
|
start_base, start_path = os.path.split(start_dir)
|
||||||
|
element = E.DirectoryRef(Id='INSTALLDIR')
|
||||||
|
directories = {start_path: {'__dir__': element}}
|
||||||
|
components = []
|
||||||
|
|
||||||
|
for root, _, files in os.walk(start_dir):
|
||||||
|
parent = os.sep.join(root.replace(os.path.join(start_base, ''), '').split(os.sep)[:-1])
|
||||||
|
if root == start_dir:
|
||||||
|
path = ''
|
||||||
|
else:
|
||||||
|
path = root.replace(os.path.join(start_dir, ''), '')
|
||||||
|
base = os.path.basename(root)
|
||||||
|
if root != start_dir:
|
||||||
|
dir_id = 'dir_{parent}_{base}'.format(parent=parent.replace(os.sep, '_'), base=base)
|
||||||
|
element = E.Directory(Id=dir_id, Name=base)
|
||||||
|
new_dir = {'__dir__': element}
|
||||||
|
parent_dir = walk_dirs(directories, parent)
|
||||||
|
parent_dir[base] = new_dir
|
||||||
|
parent_dir['__dir__'].append(element)
|
||||||
|
for fname in files:
|
||||||
|
if fname in BLACKLIST:
|
||||||
|
continue
|
||||||
|
source = os.path.join(path, fname) if path else fname
|
||||||
|
file_id = 'file_{source}'.format(source=source.replace('-', '_').replace(os.sep, '_'))
|
||||||
|
file_ = E.File(Id=file_id, KeyPath="yes", Source=source)
|
||||||
|
component = E.Component(file_, Id='cmp_' + fixed_id, Guid='*')
|
||||||
|
element.append(component)
|
||||||
|
components.append(component)
|
||||||
|
|
||||||
|
files_fragment = E.Fragment(directories[start_path]['__dir__'])
|
||||||
|
comps_fragment = E.Fragment(E.ComponentGroup(*[E.ComponentRef(Id=c.attrib['Id']) for c in components], Id='Files'))
|
||||||
|
return files_fragment, comps_fragment
|
||||||
|
|
||||||
|
def _create_wix_file(self):
|
||||||
|
"""
|
||||||
|
Create a WiX project file
|
||||||
|
"""
|
||||||
|
self._print('Creating WiX file...')
|
||||||
config_dir = os.path.dirname(self.config_path)
|
config_dir = os.path.dirname(self.config_path)
|
||||||
os.chdir(config_dir)
|
self._print_verbose('Reading base WiX file')
|
||||||
self._run_command([self.innosetup_exe, os.path.join(config_dir, 'OpenLP.iss'), '/q'],
|
with open(os.path.join(config_dir, 'OpenLP-base.wxs'), 'rb') as base_file:
|
||||||
'Error running InnoSetup')
|
xml = base_file.read()
|
||||||
|
xml = xml.format(dialog=os.path.join(config_dir, 'WizardMain.bmp'),
|
||||||
|
banner=os.path.join(config_dir, 'WizardBanner.bmp'))
|
||||||
|
tree = fromstring(xml)
|
||||||
|
self._print_verbose('Creating XML fragments from files and directories')
|
||||||
|
fragments = self._get_fragments_from_files(self.dist_path)
|
||||||
|
self._print_verbose('Inserting XML fragments into base WiX file')
|
||||||
|
wix = base_tree.getroot()
|
||||||
|
for fragment in fragments:
|
||||||
|
wix.append(fragment)
|
||||||
|
self._print_verbose('Writing new WiX file')
|
||||||
|
with open(os.path.join(self.config_path, 'OpenLP.wxs'), 'wb') as f:
|
||||||
|
f.write(tostring(tree, encoding='utf-8', xml_declaration=True, pretty_print=True))
|
||||||
|
|
||||||
|
def _run_wix_tools(self):
|
||||||
|
"""
|
||||||
|
Run the WiX toolset to create an installer
|
||||||
|
"""
|
||||||
|
self._print('Running WiX tools...')
|
||||||
|
msi_file = os.path.join(self.dist_path, 'OpenLP-{}.msi'.format(self.version))
|
||||||
|
if msi_file:
|
||||||
|
self._print_verbose('Removing old MSI file')
|
||||||
|
os.unlink(msi_file)
|
||||||
|
config_dir = os.path.dirname(self.config_path)
|
||||||
|
os.chdir(self.dist_path)
|
||||||
|
self._run_command([self.candle_exe, '-ext', 'WiXUtilExtension', os.path.join(config_dir, 'OpenLP.wxs')],
|
||||||
|
'Error running WiX tool: candle')
|
||||||
|
self._run_command([self.light_exe, '-ext', 'WiXUtilExtension', '-ext', 'WixUIExtension', 'OpenLP.wixobj',
|
||||||
|
'-o', msi_file],
|
||||||
|
'Error running WiX tool: light')
|
||||||
|
|
||||||
def _create_portableapp_structure(self):
|
def _create_portableapp_structure(self):
|
||||||
"""
|
"""
|
||||||
@ -335,8 +409,8 @@ class WindowsBuilder(Builder):
|
|||||||
Build the installer
|
Build the installer
|
||||||
"""
|
"""
|
||||||
self._build_pptviewlib()
|
self._build_pptviewlib()
|
||||||
self._create_innosetup_file()
|
self._create_wix_file()
|
||||||
self._run_innosetup()
|
self._run_wix_tools()
|
||||||
if self.args.portable:
|
if self.args.portable:
|
||||||
self._run_portableapp_builder()
|
self._run_portableapp_builder()
|
||||||
|
|
||||||
|
79
windows/OpenLP-base.wxs
Normal file
79
windows/OpenLP-base.wxs
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"
|
||||||
|
xmlns:util="http://schemas.microsoft.com/wix/UtilExtension">
|
||||||
|
<Product Name="OpenLP" Manufacturer="OpenLP" Id="{98092172-3875-47d3-8DBE-3EB0D5A57CE7}"
|
||||||
|
UpgradeCode="{8C5881AC-8F1E-4937-BB99-B823FABF18F0}" Language="1033" Codepage="1252" Version="2.5.0">
|
||||||
|
<Package Id="*" Keywords="Installer" Description="Free open source church worship presentation software"
|
||||||
|
Comments="OpenLP is open source under the GNU General Public License" Manufacturer="OpenLP Developers"
|
||||||
|
InstallerVersion="251" Languages="1033" Compressed="yes" SummaryCodepage="1252"/>
|
||||||
|
<Condition Message="You need to be an administrator to install this product.">Privileged</Condition>
|
||||||
|
<Media Id="1" Cabinet="openlp.cab" EmbedCab="yes"/>
|
||||||
|
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />
|
||||||
|
<Property Id="ARPPRODUCTICON" Value="OpenLP.ico" />
|
||||||
|
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch OpenLP" />
|
||||||
|
<Property Id="WixShellExecTarget" Value="[#file_OpenLP.exe]" />
|
||||||
|
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />
|
||||||
|
<UI>
|
||||||
|
<UIRef Id="WixUI_InstallDir" />
|
||||||
|
<Publish Dialog="ExitDialog"
|
||||||
|
Control="Finish"
|
||||||
|
Event="DoAction"
|
||||||
|
Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
|
||||||
|
</UI>
|
||||||
|
<WixVariable Id="WixUILicenseRtf" Value="gpl-2.0.rtf" />
|
||||||
|
<WixVariable Id="WixUIDialogBmp" Value="{dialog}" />
|
||||||
|
<WixVariable Id="WixUIBannerBmp" Value="{banner}" />
|
||||||
|
<Directory Id="TARGETDIR" Name="SourceDir">
|
||||||
|
<Directory Id="ProgramFilesFolder">
|
||||||
|
<Directory Id="INSTALLDIR" Name="OpenLP"/>
|
||||||
|
</Directory>
|
||||||
|
<Directory Id="ProgramMenuFolder" Name="Programs">
|
||||||
|
<Directory Id="ProgramMenuDir" Name="OpenLP">
|
||||||
|
<Component Id="ProgramMenuDir" Guid="{7AABE54C-5B03-4049-AA85-E18B787A19C7}">
|
||||||
|
<RemoveFolder Id="ProgramMenuDir" On="uninstall" />
|
||||||
|
<RegistryValue Root="HKCU" Key="Software\OpenLP\OpenLP" Type="string" Value="" KeyPath="yes" />
|
||||||
|
<Shortcut Id="ApplicationStartMenuShortcut"
|
||||||
|
Name="OpenLP"
|
||||||
|
Description="Open Source Worship Presentation Software"
|
||||||
|
Target="[#file_OpenLP.exe]"
|
||||||
|
Icon="OpenLP.ico"
|
||||||
|
WorkingDirectory="RootDirectory"/>
|
||||||
|
<Shortcut Id="DebugStartMenuShortcut"
|
||||||
|
Name="OpenLP (Debug)"
|
||||||
|
Description="Run OpenLP with debug logging enabled"
|
||||||
|
Target="[#file_OpenLP.exe]"
|
||||||
|
Arguments="--log-level debug"
|
||||||
|
Icon="OpenLP.ico"
|
||||||
|
WorkingDirectory="RootDirectory"/>
|
||||||
|
<Shortcut Id="HelpStartMenuShortcut"
|
||||||
|
Name="OpenLP Help"
|
||||||
|
Description="Help file for OpenLP"
|
||||||
|
Target="[#file_OpenLP.chm]"
|
||||||
|
WorkingDirectory="RootDirectory"/>
|
||||||
|
<util:InternetShortcut Id="OpenLPWebSite"
|
||||||
|
Name="OpenLP on the Web"
|
||||||
|
Target="http://openlp.org/"/>
|
||||||
|
<util:InternetShortcut Id="OpenLPForums"
|
||||||
|
Name="Get support for OpenLP"
|
||||||
|
Target="http://forums.openlp.org/"/>
|
||||||
|
<Shortcut Id="UninstallProduct"
|
||||||
|
Name="Uninstall OpenLP"
|
||||||
|
Target="[SystemFolder]msiexec.exe"
|
||||||
|
Arguments="/x [ProductCode]"
|
||||||
|
Description="Removes OpenLP from your computer" />
|
||||||
|
</Component>
|
||||||
|
</Directory>
|
||||||
|
</Directory>
|
||||||
|
<Directory Id="DesktopFolder" Name="Desktop" />
|
||||||
|
</Directory>
|
||||||
|
<DirectoryRef Id="INSTALLDIR">
|
||||||
|
<Directory Id="RootDirectory" Name="OpenLP" />
|
||||||
|
</DirectoryRef>
|
||||||
|
<Feature Id="Complete" Title="Complete" Description="The OpenLP program files" Level="1"
|
||||||
|
ConfigurableDirectory="INSTALLDIR" AllowAdvertise="no" InstallDefault="local" Absent="disallow">
|
||||||
|
<ComponentGroupRef Id="Files"/>
|
||||||
|
<ComponentRef Id="ProgramMenuDir"/>
|
||||||
|
</Feature>
|
||||||
|
<Icon Id="OpenLP.ico" SourceFile="OpenLP.ico"/>
|
||||||
|
</Product>
|
||||||
|
</Wix>
|
BIN
windows/WizardBanner.bmp
Normal file
BIN
windows/WizardBanner.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 84 KiB |
BIN
windows/WizardMain.bmp
Normal file
BIN
windows/WizardMain.bmp
Normal file
Binary file not shown.
After Width: | Height: | Size: 601 KiB |
Loading…
Reference in New Issue
Block a user