mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
9f6b59fa2e
I had previously left the platform field (in line 7 of the installer database's SummaryInformation table) set at "x86" instead of any value you might expect such as "Arm" or "Arm64", because I found that an MSI file with either of the latter values was rejected by WoA's msiexec as invalid. It turns out this is because I _also_ needed to upgrade the installer database schema version to a higher value than I even knew existed: apparently the problem is that those platform fields aren't present in the older schema. A test confirms that this works. Unfortunately, WiX 3 doesn't actually know _how_ to write MSIs with those platform values. But that's OK, because diffing the x86 and x64 MSIs against each other suggested that there were basically no other changes in the database tables - so I can just generate the installer as if for x64, and then rewrite that one field after installer construction using GNOME msitools to take apart the binary file structure and put it back together. (Those are the same tools I'm using as part of my system for running WiX on Linux in the first place.) This commit introduces a script to do that post-hoc bodging, and calls it from Buildscr. I've also changed over the choice of Program Files folder for the Arm installers so that it's ProgramFiles64Folder instead of ProgramFilesFolder - so now the Windows on Arm installer doesn't incongruously default to installing in C:\Program Files (x86)!
64 lines
1.9 KiB
Python
Executable File
64 lines
1.9 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
import argparse
|
|
import os
|
|
import tempfile
|
|
import shutil
|
|
import subprocess
|
|
import pipes
|
|
|
|
def run(command, verbose):
|
|
if verbose:
|
|
sys.stdout.write("$ {}\n".format(" ".join(
|
|
pipes.quote(word) for word in command)))
|
|
out = subprocess.check_output(command)
|
|
if verbose:
|
|
sys.stdout.write("".join(
|
|
"> {}\n".format(line) for line in out.splitlines()))
|
|
|
|
def set_platform(msi, platform, verbose):
|
|
run(["msidump", "-t", msi], verbose)
|
|
|
|
summary_stream = "_SummaryInformation.idt"
|
|
|
|
with open(summary_stream) as fh:
|
|
lines = [line.rstrip("\r\n").split("\t")
|
|
for line in iter(fh.readline, "")]
|
|
|
|
for line in lines[3:]:
|
|
if line[0] == "7":
|
|
line[1] = ";".join([platform] + line[1].split(";", 1)[1:])
|
|
|
|
with open(summary_stream, "w") as fh:
|
|
for line in lines:
|
|
fh.write("\t".join(line) + "\r\n")
|
|
|
|
run(["msibuild", msi, "-i", summary_stream], 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("-v", "--verbose", action="store_true",
|
|
help="Log what this script is doing.")
|
|
parser.add_argument("-k", "--keep", action="store_true",
|
|
help="Don't delete the temporary working directory.")
|
|
args = parser.parse_args()
|
|
|
|
msi = os.path.abspath(args.msi)
|
|
msidir = os.path.dirname(msi)
|
|
try:
|
|
tempdir = tempfile.mkdtemp(dir=msidir)
|
|
os.chdir(tempdir)
|
|
set_platform(msi, args.platform, args.verbose)
|
|
finally:
|
|
if args.keep:
|
|
sys.stdout.write(
|
|
"Retained temporary directory {}\n".format(tempdir))
|
|
else:
|
|
shutil.rmtree(tempdir)
|
|
|
|
if __name__ == '__main__':
|
|
main()
|