Patchwork D7157: packaging: install and run Inno files in a build directory

login
register
mail settings
Submitter phabricator
Date Oct. 24, 2019, 1:55 a.m.
Message ID <differential-rev-PHID-DREV-gle4cwtc7mjghti4pzcg-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/42545/
State Superseded
Headers show

Comments

phabricator - Oct. 24, 2019, 1:55 a.m.
indygreg created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Upcoming commits will refactor the Windows installers so their
  content is dynamically derived. In preparation for this, we
  copy the Inno files into a new build directory and run them
  from there. This required changing some relative paths to
  work from a new directory level but is otherwise a pretty
  straightforward change.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D7157

AFFECTED FILES
  contrib/packaging/hgpackaging/inno.py
  contrib/packaging/inno/mercurial.iss

CHANGE DETAILS




To: indygreg, #hg-reviewers
Cc: mercurial-devel

Patch

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
@@ -5,7 +5,7 @@ 
 #define FileHandle
 #define FileLine
 #define VERSION = "unknown"
-#if FileHandle = FileOpen(SourcePath + "\..\..\..\mercurial\__version__.py")
+#if FileHandle = FileOpen(SourcePath + "\..\..\mercurial\__version__.py")
   #expr FileLine = FileRead(FileHandle)
   #expr FileLine = FileRead(FileHandle)
   #define VERSION = Copy(FileLine, Pos('"', FileLine)+1, Len(FileLine)-Pos('"', FileLine)-1)
@@ -43,7 +43,7 @@ 
 AppID={{4B95A5F1-EF59-4B08-BED8-C891C46121B3}
 AppContact=mercurial@mercurial-scm.org
 DefaultDirName={pf}\Mercurial
-SourceDir=..\..\..
+SourceDir=..\..
 VersionInfoDescription=Mercurial distributed SCM (version {#VERSION})
 VersionInfoCopyright=Copyright 2005-2019 Matt Mackall and others
 VersionInfoCompany=Matt Mackall and others
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
@@ -15,7 +15,6 @@ 
 from .py2exe import build_py2exe
 from .util import find_vc_runtime_files
 
-
 EXTRA_PACKAGES = {
     'dulwich',
     'keyring',
@@ -43,11 +42,16 @@ 
         raise Exception('%s does not exist' % iscc_exe)
 
     vc_x64 = r'\x64' in os.environ.get('LIB', '')
+    arch = 'x64' if vc_x64 else 'x86'
+    inno_source_dir = source_dir / 'contrib' / 'packaging' / 'inno'
+    inno_build_dir = build_dir / ('inno-%s' % arch)
 
     requirements_txt = (
         source_dir / 'contrib' / 'packaging' / 'inno' / 'requirements.txt'
     )
 
+    inno_build_dir.mkdir(parents=True, exist_ok=True)
+
     build_py2exe(
         source_dir,
         build_dir,
@@ -71,6 +75,10 @@ 
 
     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)
+
     args = [str(iscc_exe)]
 
     if vc_x64:
@@ -80,6 +88,6 @@ 
         args.append('/dVERSION=%s' % version)
 
     args.append('/Odist')
-    args.append('contrib/packaging/inno/mercurial.iss')
+    args.append(str(inno_build_dir / 'mercurial.iss'))
 
     subprocess.run(args, cwd=str(source_dir), check=True)