Start work on porting wix

This commit is contained in:
Kovid Goyal 2023-10-10 10:19:09 +05:30
parent 2e859bab02
commit 85d899461d
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 7 additions and 28 deletions

View File

@ -1,4 +1,4 @@
<?xml version='1.0' encoding='utf-8'?> <?xml version='1.0' encoding='utf-8'?>
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util="http://schemas.microsoft.com/wix/UtilExtension" <Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"
> >
@ -60,12 +60,8 @@
</Property> </Property>
<Directory Id='TARGETDIR' Name='SourceDir'> <Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='{ProgramFilesFolder}' Name='PFiles'> <Directory Id='ProgramFiles64Folder' Name='PFiles'>
<!-- The name must be calibre on 32 bit to ensure <Directory Id='APPLICATIONFOLDER' Name="Calibre2" />
that the component guids dont change compared to previous msis.
However, on 64 bit it must be Calibre2 otherwise by default it
will install to C:\Program Files\calibre -->
<Directory Id='APPLICATIONFOLDER' Name="{appfolder}" />
</Directory> </Directory>
<Directory Id="ProgramMenuFolder"> <Directory Id="ProgramMenuFolder">
<Directory Id="ApplicationProgramsFolder" Name="{app}{x64} - E-book Management"/> <Directory Id="ApplicationProgramsFolder" Name="{app}{x64} - E-book Management"/>
@ -195,12 +191,12 @@
<InstallExecuteSequence> <InstallExecuteSequence>
<Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom> <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
{fix_wix} <Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
<RemoveExistingProducts After="InstallFinalize" /> <RemoveExistingProducts After="InstallFinalize" />
</InstallExecuteSequence> </InstallExecuteSequence>
<InstallUISequence> <InstallUISequence>
<Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom> <Custom Action="PreventDowngrading" After="FindRelatedProducts">NEWPRODUCTFOUND</Custom>
{fix_wix} <Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
</InstallUISequence> </InstallUISequence>
<UI> <UI>

View File

@ -10,15 +10,13 @@ from bypy.constants import is64bit
from bypy.utils import run from bypy.utils import run
# TODO: Migrate to Wix 4 see https://wixtoolset.org/docs/fourthree/ # TODO: Migrate to Wix 4 see https://wixtoolset.org/docs/fourthree/
WIXP = r'C:\Program Files (x86)\WiX Toolset v3.14' WIX = os.path.expanduser('~/.dotnet/tools/wix.exe')
if is64bit: if is64bit:
UPGRADE_CODE = '5DD881FF-756B-4097-9D82-8C0F11D521EA' UPGRADE_CODE = '5DD881FF-756B-4097-9D82-8C0F11D521EA'
else: else:
UPGRADE_CODE = 'BEB2A80D-E902-4DAD-ADF9-8BD2DA42CFE1' UPGRADE_CODE = 'BEB2A80D-E902-4DAD-ADF9-8BD2DA42CFE1'
calibre_constants = globals()['calibre_constants'] calibre_constants = globals()['calibre_constants']
CANDLE = WIXP + r'\bin\candle.exe'
LIGHT = WIXP + r'\bin\light.exe'
j, d, a, b = os.path.join, os.path.dirname, os.path.abspath, os.path.basename j, d, a, b = os.path.join, os.path.dirname, os.path.abspath, os.path.basename
@ -33,12 +31,9 @@ def create_installer(env):
components, smap = get_components_from_files(env) components, smap = get_components_from_files(env)
wxs = template.format( wxs = template.format(
app=calibre_constants['appname'], app=calibre_constants['appname'],
appfolder='Calibre2' if is64bit else 'Calibre',
version=calibre_constants['version'], version=calibre_constants['version'],
upgrade_code=UPGRADE_CODE, upgrade_code=UPGRADE_CODE,
ProgramFilesFolder='ProgramFiles64Folder' if is64bit else 'ProgramFilesFolder',
x64=' 64bit' if is64bit else '', x64=' 64bit' if is64bit else '',
fix_wix='<Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />' if is64bit else '',
compression='high', compression='high',
app_components=components, app_components=components,
exe_map=smap, exe_map=smap,
@ -57,28 +52,16 @@ def create_installer(env):
f.write(wxs.encode('utf-8')) f.write(wxs.encode('utf-8'))
with open(enusf, 'wb') as f: with open(enusf, 'wb') as f:
f.write(enus.encode('utf-8')) f.write(enus.encode('utf-8'))
wixobj = j(env.installer_dir, calibre_constants['appname'] + '.wixobj')
arch = 'x64' if is64bit else 'x86' arch = 'x64' if is64bit else 'x86'
cmd = [CANDLE, '-nologo', '-arch', arch, '-ext', 'WiXUtilExtension', '-o', wixobj, wxsf]
run(*cmd)
installer = j(env.dist, '%s%s-%s.msi' % ( installer = j(env.dist, '%s%s-%s.msi' % (
calibre_constants['appname'], ('-64bit' if is64bit else ''), calibre_constants['version'])) calibre_constants['appname'], ('-64bit' if is64bit else ''), calibre_constants['version']))
license = j(env.src_root, 'LICENSE.rtf') license = j(env.src_root, 'LICENSE.rtf')
banner = j(env.src_root, 'icons', 'wix-banner.bmp') banner = j(env.src_root, 'icons', 'wix-banner.bmp')
dialog = j(env.src_root, 'icons', 'wix-dialog.bmp') dialog = j(env.src_root, 'icons', 'wix-dialog.bmp')
cmd = [LIGHT, '-nologo', '-ext', 'WixUIExtension', cmd = [WIX, 'build', '-arch', arch, '-culture', 'en-us', '-loc', enusf, '-o', installer,
'-cultures:en-us', '-loc', enusf, wixobj,
'-ext', 'WixUtilExtension',
'-o', installer,
'-dWixUILicenseRtf=' + license, '-dWixUILicenseRtf=' + license,
'-dWixUIBannerBmp=' + banner, '-dWixUIBannerBmp=' + banner,
'-dWixUIDialogBmp=' + dialog] '-dWixUIDialogBmp=' + dialog]
cmd.extend([
'-sice:ICE60', # No language in dlls warning
'-sice:ICE61', # Allow upgrading with same version number
'-sice:ICE40', # Re-install mode overridden
'-sice:ICE69', # Shortcut components are part of a different feature than the files they point to
])
cmd.append('-sval') # Disable all checks since they fail when running under ssh cmd.append('-sval') # Disable all checks since they fail when running under ssh
run(*cmd) run(*cmd)