diff --git a/Buildscr b/Buildscr index 2b789d4c..a98f5f3f 100644 --- a/Buildscr +++ b/Buildscr @@ -152,8 +152,7 @@ in putty do perl -i~ -pe 'y/\015//d;s/$$/\015/' LICENCE # Some gratuitous theming for the MSI installer UI. in putty/icons do make -j$(nproc) -in putty do convert -size 164x312 'gradient:blue-white' -distort SRT -90 -swirl 180 \( -size 329x312 canvas:white \) +append \( icons/putty-48.png -geometry +28+24 \) -composite \( icons/pscp-48.png -geometry +88+96 \) -composite \( icons/puttygen-48.png -geometry +28+168 \) -composite \( icons/pageant-48.png -geometry +88+240 \) -composite windows/msidialog.bmp -in putty do convert -size 493x58 canvas:white \( icons/putty-48.png -geometry +440+5 \) -composite windows/msibanner.bmp +in putty do ./windows/make_install_images.sh mkdir putty/windows/build32 mkdir putty/windows/build64 @@ -200,10 +199,20 @@ in putty/windows with wixonlinux do candle -arch x64 -dRealPlatform=x64 -dDllOk= in putty/windows with wixonlinux do candle -arch x64 -dRealPlatform=Arm -dDllOk=no -dBuilddir=abuild32/ -dWinver="$(Winver)" -dPuttytextver="$(Puttytextver)" installer.wxs && light -ext WixUIExtension -ext WixUtilExtension -sval installer.wixobj -o installera32.msi -spdb in putty/windows with wixonlinux do candle -arch x64 -dRealPlatform=Arm64 -dDllOk=no -dBuilddir=abuild64/ -dWinver="$(Winver)" -dPuttytextver="$(Puttytextver)" installer.wxs && light -ext WixUIExtension -ext WixUtilExtension -sval installer.wixobj -o installera64.msi -spdb -# Bodge the platform fields for the Windows on Arm installers, since -# WiX 3 doesn't understand Arm platform names itself. -in putty/windows do ./msiplatform.py installera32.msi Arm -in putty/windows do ./msiplatform.py installera64.msi Arm64 +# Change the width field for our dialog background image so that it +# doesn't stretch across the whole dialog. (WiX's default one does; we +# replace it with a narrow one so that the text to the right of it +# shows up on system default background colour, meaning that +# high-contrast mode doesn't make the text white on white. But that +# means we also have to modify the width field, and there's nothing in +# WiX's source syntax to make that happen.) +# +# Also bodge the platform fields for the Windows on Arm installers, +# since WiX 3 doesn't understand Arm platform names itself. +in putty/windows do ./msifixup.py installer32.msi --dialog-bmp-width=123 +in putty/windows do ./msifixup.py installer64.msi --dialog-bmp-width=123 +in putty/windows do ./msifixup.py installera32.msi --dialog-bmp-width=123 --platform=Arm +in putty/windows do ./msifixup.py installera64.msi --dialog-bmp-width=123 --platform=Arm64 # Sign the Windows installers. ifneq "$(cross_winsigncode)" "" in putty/windows do $(cross_winsigncode) -i https://www.chiark.greenend.org.uk/~sgtatham/putty/ -n "PuTTY Installer" installer32.msi installer64.msi installera32.msi installera64.msi diff --git a/windows/make_install_images.sh b/windows/make_install_images.sh new file mode 100755 index 00000000..49041e24 --- /dev/null +++ b/windows/make_install_images.sh @@ -0,0 +1,22 @@ +#!/bin/sh + +# Script to make the bitmap files that go into the PuTTY MSI installer. + +set -e + +# For convenience, allow this script to be run from the Windows +# subdirectory as well as the top level of the source tree. +if test -f installer.wxs -a ! -f putty.h -a -f ../putty.h; then + cd .. +fi + +convert -size 164x312 'gradient:blue-white' -distort SRT -90 -swirl 180 \ + \( icons/putty-48.png -geometry +28+24 \) -composite \ + \( icons/pscp-48.png -geometry +88+96 \) -composite \ + \( icons/puttygen-48.png -geometry +28+168 \) -composite \ + \( icons/pageant-48.png -geometry +88+240 \) -composite \ + windows/msidialog.bmp + +convert -size 493x58 canvas:white \ + \( icons/putty-48.png -geometry +440+5 \) -composite \ + windows/msibanner.bmp diff --git a/windows/msiplatform.py b/windows/msifixup.py similarity index 52% rename from windows/msiplatform.py rename to windows/msifixup.py index eea4272f..4d4bb3e4 100755 --- a/windows/msiplatform.py +++ b/windows/msifixup.py @@ -16,30 +16,43 @@ def run(command, verbose): sys.stdout.write("".join( "> {}\n".format(line) for line in out.splitlines())) -def set_platform(msi, platform, verbose): - run(["msidump", "-t", msi], verbose) +def make_changes(msi, args): + run(["msidump", "-t", msi], args.verbose) + build_cmd = ["msibuild", msi] - summary_stream = "_SummaryInformation.idt" + def change_table(filename): + with open(filename) as fh: + lines = [line.rstrip("\r\n").split("\t") + for line in iter(fh.readline, "")] - with open(summary_stream) as fh: - lines = [line.rstrip("\r\n").split("\t") - for line in iter(fh.readline, "")] + for line in lines[3:]: + yield line - for line in lines[3:]: - if line[0] == "7": - line[1] = ";".join([platform] + line[1].split(";", 1)[1:]) + with open(filename, "w") as fh: + for line in lines: + fh.write("\t".join(line) + "\r\n") - with open(summary_stream, "w") as fh: - for line in lines: - fh.write("\t".join(line) + "\r\n") + build_cmd.extend(["-i", filename]) - run(["msibuild", msi, "-i", summary_stream], verbose) + if args.platform is not None: + for line in change_table("_SummaryInformation.idt"): + if line[0] == "7": + line[1] = ";".join([args.platform] + line[1].split(";", 1)[1:]) + + if args.dialog_bmp_width is not None: + for line in change_table("Control.idt"): + if line[9] == "WixUI_Bmp_Dialog": + line[5] = args.dialog_bmp_width + + run(build_cmd, args.verbose) def main(): parser = argparse.ArgumentParser( description='Change the platform field of an MSI installer package.') parser.add_argument("msi", help="MSI installer file.") - parser.add_argument("platform", help="New value for the platform field.") + parser.add_argument("--platform", help="Change the platform field.") + parser.add_argument("--dialog-bmp-width", help="Change the width field" + " in all uses of WixUI_Bmp_Dialog.") parser.add_argument("-v", "--verbose", action="store_true", help="Log what this script is doing.") parser.add_argument("-k", "--keep", action="store_true", @@ -51,7 +64,7 @@ def main(): try: tempdir = tempfile.mkdtemp(dir=msidir) os.chdir(tempdir) - set_platform(msi, args.platform, args.verbose) + make_changes(msi, args) finally: if args.keep: sys.stdout.write(