diff tests/test-install.t @ 43623:94eac340d212

packaging: stage files and dynamically generate WiX installer Like we did for Inno, we want to make the WiX installer "dumb" and simply consume source files from a directory tree rather than have to define every single file in installer files. This will greatly decrease the amount of effort required to maintain the WiX installer since we don't have to think that much about keeping files in sync. This commit changes the WiX packager to populate a staging directory as part of packaging. After it does so, it scans that directory and dynamically generates WiX XML defining the content within. The IDs and GUIDs being generated are deterministic. So, upgrades should work as expected in Windows Installer land. (WiX has a "heat" tool that can generate XML by walking the filesystem but it doesn't have this deterministic property, sadly.) As part of this change, GUIDs are now effectively reset. So the next upgrade should be a complete wipe and replace. This could potentially cause issues. But in my local testing, I was able to upgrade an existing 5.1.2 install without issue. Compared to the previous commit, the installed files differ in the following: * A ReleaseNotes.txt file is now included * A hgrc.d/editor.rc file is now generated (mercurial.rc has been updated to reflect this logical change to the content source) * All files are marked as read-only. Previously, only a subset of files were. This should help prevent unwanted tampering. Although we may want to consider use cases like modifying template files... This change also means that Inno and WiX are now using very similar code for managing the install layout. This means that on disk both packages are nearly identical. The differences in install layout are as follows: * Inno has a Copying.txt vs a COPYING.rtf for WiX. (The WiX installer wants to use RTF.) * Inno has a Mercurial.url file that is an internet shortcut to www.mercurial-scm.org. (This could potentially be removed.) * Inno includes msvc[mpr]90.dll files and WiX does not. (WiX installs the MSVC runtime via merge modules.) * Inno includes unins000.{dat,exe} files. (WiX's state is managed by Windows Installer, which places things elsewhere.) Because file lists are dynamically generated now, the test ensuring things remain in sync has been deleted. Good riddance. While this is a huge step towards unifying the Windows installers, there's still some improvements that can be made. But I think it is worth celebrating the milestone of getting both Inno and WiX to essentially share core packaging code and workflows. That should make it much easier to change the installers going forward. This will aid support of Python 3. Differential Revision: https://phab.mercurial-scm.org/D7173
author Gregory Szorc <gregory.szorc@gmail.com>
date Mon, 11 Nov 2019 18:55:42 -0800
parents 45c15ed06f33
children 0b475b0b0344
line wrap: on
line diff
--- a/tests/test-install.t	Mon Nov 11 19:04:49 2019 -0800
+++ b/tests/test-install.t	Mon Nov 11 18:55:42 2019 -0800
@@ -162,75 +162,6 @@
     "fsmonitor-watchman": "false",
     "fsmonitor-watchman-error": "warning: Watchman unavailable: watchman exited with code 1",
 
-
-#if test-repo
-  $ . "$TESTDIR/helpers-testrepo.sh"
-
-  $ cat >> wixxml.py << EOF
-  > import os
-  > import subprocess
-  > import sys
-  > import xml.etree.ElementTree as ET
-  > from mercurial import pycompat
-  > 
-  > # MSYS mangles the path if it expands $TESTDIR
-  > testdir = os.environ['TESTDIR']
-  > ns = {'wix' : 'http://schemas.microsoft.com/wix/2006/wi'}
-  > 
-  > def directory(node, relpath):
-  >     '''generator of files in the xml node, rooted at relpath'''
-  >     dirs = node.findall('./{%(wix)s}Directory' % ns)
-  > 
-  >     for d in dirs:
-  >         for subfile in directory(d, relpath + d.attrib['Name'] + '/'):
-  >             yield subfile
-  > 
-  >     files = node.findall('./{%(wix)s}Component/{%(wix)s}File' % ns)
-  > 
-  >     for f in files:
-  >         yield pycompat.sysbytes(relpath + f.attrib['Name'])
-  > 
-  > def hgdirectory(relpath):
-  >     '''generator of tracked files, rooted at relpath'''
-  >     hgdir = "%s/../mercurial" % (testdir)
-  >     args = ['hg', '--cwd', hgdir, 'files', relpath]
-  >     proc = subprocess.Popen(args, stdout=subprocess.PIPE,
-  >                             stderr=subprocess.PIPE)
-  >     output = proc.communicate()[0]
-  > 
-  >     for line in output.splitlines():
-  >         if os.name == 'nt':
-  >             yield line.replace(pycompat.sysbytes(os.sep), b'/')
-  >         else:
-  >             yield line
-  > 
-  > tracked = [f for f in hgdirectory(sys.argv[1])]
-  > 
-  > xml = ET.parse("%s/../contrib/packaging/wix/%s.wxs" % (testdir, sys.argv[1]))
-  > root = xml.getroot()
-  > dir = root.find('.//{%(wix)s}DirectoryRef' % ns)
-  > 
-  > installed = [f for f in directory(dir, '')]
-  > 
-  > print('Not installed:')
-  > for f in sorted(set(tracked) - set(installed)):
-  >     print('  %s' % pycompat.sysstr(f))
-  > 
-  > print('Not tracked:')
-  > for f in sorted(set(installed) - set(tracked)):
-  >     print('  %s' % pycompat.sysstr(f))
-  > EOF
-
-  $ ( testrepohgenv; "$PYTHON" wixxml.py help )
-  Not installed:
-  Not tracked:
-
-  $ ( testrepohgenv; "$PYTHON" wixxml.py templates )
-  Not installed:
-  Not tracked:
-
-#endif
-
 Verify that Mercurial is installable with pip. Note that this MUST be
 the last test in this file, because we do some nasty things to the
 shell environment in order to make the virtualenv work reliably.