diff --git a/contrib/packaging/hgpackaging/inno.py b/contrib/packaging/hgpackaging/inno.py --- a/contrib/packaging/hgpackaging/inno.py +++ b/contrib/packaging/hgpackaging/inno.py @@ -12,6 +12,8 @@ import pathlib import shutil import subprocess +import jinja2 + from .py2exe import build_py2exe from .util import find_vc_runtime_files @@ -75,9 +77,26 @@ def build( print('creating installer') - # Copy Inno files into place. - for p in ('mercurial.iss', 'modpath.iss'): - shutil.copyfile(inno_source_dir / p, inno_build_dir / p) + # Install Inno files by rendering a template. + jinja_env = jinja2.Environment( + loader=jinja2.FileSystemLoader(str(inno_source_dir)), + # Need to change these to prevent conflict with Inno Setup. + comment_start_string='{##', + comment_end_string='##}', + ) + + try: + template = jinja_env.get_template('mercurial.iss') + except jinja2.TemplateSyntaxError as e: + raise Exception( + 'template syntax error at %s:%d: %s' + % (e.name, e.lineno, e.message,) + ) + + content = template.render() + + with (inno_build_dir / 'mercurial.iss').open('w', encoding='utf-8') as fh: + fh.write(content) args = [str(iscc_exe)] diff --git a/contrib/packaging/inno/mercurial.iss b/contrib/packaging/inno/mercurial.iss --- a/contrib/packaging/inno/mercurial.iss +++ b/contrib/packaging/inno/mercurial.iss @@ -40,7 +40,7 @@ AppPublisher=Matt Mackall and others AppPublisherURL=https://mercurial-scm.org/ AppSupportURL=https://mercurial-scm.org/ AppUpdatesURL=https://mercurial-scm.org/ -AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3} +{{ 'AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3}' }} AppContact=mercurial@mercurial-scm.org DefaultDirName={pf}\Mercurial SourceDir=..\.. @@ -121,4 +121,5 @@ begin setArrayLength(Result, 1) Result[0] := ExpandConstant('{app}'); end; -#include "modpath.iss" + +{% include 'modpath.iss' %}