contrib/packaging/hgpackaging/wix.py
author Gregory Szorc <gregory.szorc@gmail.com>
Fri, 24 Jan 2020 20:27:59 -0800
branchstable
changeset 44145 62111bc5ff87
parent 44144 2251b6cde170
child 44149 a70108a3d7cc
permissions -rw-r--r--
wix: use original version string for MSI filename Version string normalization is mostly to placate MSI requirements. I think it makes sense to use the original version string in filenames. Since we can have distinct versions normalizing to the same MSI version string, this will allow us to distinguish between different actual version strings based on the filename. Differential Revision: https://phab.mercurial-scm.org/D8005
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
     1
# wix.py - WiX installer functionality
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
     2
#
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
     3
# Copyright 2019 Gregory Szorc <gregory.szorc@gmail.com>
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
     4
#
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
     5
# This software may be used and distributed according to the terms of the
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
     6
# GNU General Public License version 2 or any later version.
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
     7
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
     8
# no-check-code because Python 3 native.
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
     9
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    10
import collections
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    11
import os
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    12
import pathlib
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    13
import re
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    14
import shutil
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    15
import subprocess
42048
978b03d5f66e wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents: 42047
diff changeset
    16
import typing
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    17
import uuid
41962
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
    18
import xml.dom.minidom
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    19
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
    20
from .downloads import download_entry
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    21
from .py2exe import (
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    22
    build_py2exe,
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    23
    stage_install,
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    24
)
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    25
from .util import (
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    26
    extract_zip_to_directory,
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    27
    process_install_rules,
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    28
    sign_with_signtool,
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    29
)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    30
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    31
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    32
EXTRA_PACKAGES = {
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    33
    'distutils',
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    34
    'pygments',
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    35
}
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    36
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    37
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    38
EXTRA_INSTALL_RULES = [
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    39
    ('contrib/packaging/wix/COPYING.rtf', 'COPYING.rtf'),
44137
e4344e463c0c packaging: rename hgrc.d to defaultrc for Windows config files next to the exe
Matt Harbison <matt_harbison@yahoo.com>
parents: 43667
diff changeset
    40
    ('contrib/win32/mercurial.ini', 'defaultrc/mercurial.rc'),
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    41
]
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    42
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    43
STAGING_REMOVE_FILES = [
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    44
    # We use the RTF variant.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    45
    'copying.txt',
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    46
]
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    47
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    48
SHORTCUTS = {
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    49
    # hg.1.html'
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    50
    'hg.file.5d3e441c_28d9_5542_afd0_cdd4234f12d5': {
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    51
        'Name': 'Mercurial Command Reference',
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    52
    },
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    53
    # hgignore.5.html
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    54
    'hg.file.5757d8e0_f207_5e10_a2ec_3ba0a062f431': {
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    55
        'Name': 'Mercurial Ignore Files',
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    56
    },
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    57
    # hgrc.5.html
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    58
    'hg.file.92e605fd_1d1a_5dc6_9fc0_5d2998eb8f5e': {
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    59
        'Name': 'Mercurial Configuration Files',
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    60
    },
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    61
}
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    62
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
    63
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    64
def find_version(source_dir: pathlib.Path):
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    65
    version_py = source_dir / 'mercurial' / '__version__.py'
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    66
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    67
    with version_py.open('r', encoding='utf-8') as fh:
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    68
        source = fh.read().strip()
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    69
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    70
    m = re.search('version = b"(.*)"', source)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    71
    return m.group(1)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    72
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    73
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    74
def normalize_version(version):
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    75
    """Normalize Mercurial version string so WiX accepts it.
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
    76
44143
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    77
    Version strings have to be numeric ``A.B.C[.D]`` to conform with MSI's
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    78
    requirements.
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    79
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    80
    We normalize RC version or the commit count to a 4th version component.
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    81
    We store this in the 4th component because ``A.B.C`` releases do occur
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    82
    and we want an e.g. ``5.3rc0`` version to be semantically less than a
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    83
    ``5.3.1rc2`` version. This requires always reserving the 3rd version
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    84
    component for the point release and the ``X.YrcN`` release is always
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    85
    point release 0.
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    86
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    87
    In the case of an RC and presence of ``+`` suffix data, we can't use both
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    88
    because the version format is limited to 4 components. We choose to use
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    89
    RC and throw away the commit count in the suffix. This means we could
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    90
    produce multiple installers with the same normalized version string.
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    91
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    92
    >>> normalize_version("5.3")
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    93
    '5.3.0'
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    94
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    95
    >>> normalize_version("5.3rc0")
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    96
    '5.3.0.0'
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    97
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    98
    >>> normalize_version("5.3rc1")
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
    99
    '5.3.0.1'
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   100
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   101
    >>> normalize_version("5.3rc1+2-abcdef")
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   102
    '5.3.0.1'
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   103
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   104
    >>> normalize_version("5.3+2-abcdef")
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   105
    '5.3.0.2'
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   106
    """
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   107
    if '+' in version:
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   108
        version, extra = version.split('+', 1)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   109
    else:
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   110
        extra = None
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   111
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   112
    # 4.9rc0
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   113
    if version[:-1].endswith('rc'):
44143
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   114
        rc = int(version[-1:])
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   115
        version = version[:-3]
44143
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   116
    else:
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   117
        rc = None
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   118
44143
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   119
    # Ensure we have at least X.Y version components.
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   120
    versions = [int(v) for v in version.split('.')]
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   121
    while len(versions) < 3:
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   122
        versions.append(0)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   123
44143
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   124
    if len(versions) < 4:
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   125
        if rc is not None:
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   126
            versions.append(rc)
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   127
        elif extra:
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   128
            # <commit count>-<hash>+<date>
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   129
            versions.append(int(extra.split('-')[0]))
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   130
44143
8d653abed861 wix: more robust normalization of RC version components
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44137
diff changeset
   131
    return '.'.join('%d' % x for x in versions[0:4])
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   132
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   133
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   134
def ensure_vc90_merge_modules(build_dir):
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   135
    x86 = (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   136
        download_entry(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   137
            'vc9-crt-x86-msm',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   138
            build_dir,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   139
            local_name='microsoft.vcxx.crt.x86_msm.msm',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   140
        )[0],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   141
        download_entry(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   142
            'vc9-crt-x86-msm-policy',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   143
            build_dir,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   144
            local_name='policy.x.xx.microsoft.vcxx.crt.x86_msm.msm',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   145
        )[0],
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   146
    )
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   147
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   148
    x64 = (
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   149
        download_entry(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   150
            'vc9-crt-x64-msm',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   151
            build_dir,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   152
            local_name='microsoft.vcxx.crt.x64_msm.msm',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   153
        )[0],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   154
        download_entry(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   155
            'vc9-crt-x64-msm-policy',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   156
            build_dir,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   157
            local_name='policy.x.xx.microsoft.vcxx.crt.x64_msm.msm',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   158
        )[0],
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   159
    )
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   160
    return {
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   161
        'x86': x86,
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   162
        'x64': x64,
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   163
    }
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   164
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   165
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   166
def run_candle(wix, cwd, wxs, source_dir, defines=None):
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   167
    args = [
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   168
        str(wix / 'candle.exe'),
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   169
        '-nologo',
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   170
        str(wxs),
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   171
        '-dSourceDir=%s' % source_dir,
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   172
    ]
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   173
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   174
    if defines:
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   175
        args.extend('-d%s=%s' % define for define in sorted(defines.items()))
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   176
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   177
    subprocess.run(args, cwd=str(cwd), check=True)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   178
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   179
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   180
def make_post_build_signing_fn(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   181
    name,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   182
    subject_name=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   183
    cert_path=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   184
    cert_password=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   185
    timestamp_url=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   186
):
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   187
    """Create a callable that will use signtool to sign hg.exe."""
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   188
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   189
    def post_build_sign(source_dir, build_dir, dist_dir, version):
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   190
        description = '%s %s' % (name, version)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   191
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   192
        sign_with_signtool(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   193
            dist_dir / 'hg.exe',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   194
            description,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   195
            subject_name=subject_name,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   196
            cert_path=cert_path,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   197
            cert_password=cert_password,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   198
            timestamp_url=timestamp_url,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   199
        )
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   200
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   201
    return post_build_sign
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   202
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   203
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   204
def make_files_xml(staging_dir: pathlib.Path, is_x64) -> str:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   205
    """Create XML string listing every file to be installed."""
41962
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   206
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   207
    # We derive GUIDs from a deterministic file path identifier.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   208
    # We shoehorn the name into something that looks like a URL because
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   209
    # the UUID namespaces are supposed to work that way (even though
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   210
    # the input data probably is never validated).
41962
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   211
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   212
    doc = xml.dom.minidom.parseString(
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   213
        '<?xml version="1.0" encoding="utf-8"?>'
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   214
        '<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">'
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   215
        '</Wix>'
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   216
    )
41962
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   217
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   218
    # Assemble the install layout by directory. This makes it easier to
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   219
    # emit XML, since each directory has separate entities.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   220
    manifest = collections.defaultdict(dict)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   221
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   222
    for root, dirs, files in os.walk(staging_dir):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   223
        dirs.sort()
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   224
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   225
        root = pathlib.Path(root)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   226
        rel_dir = root.relative_to(staging_dir)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   227
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   228
        for i in range(len(rel_dir.parts)):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   229
            parent = '/'.join(rel_dir.parts[0 : i + 1])
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   230
            manifest.setdefault(parent, {})
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   231
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   232
        for f in sorted(files):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   233
            full = root / f
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   234
            manifest[str(rel_dir).replace('\\', '/')][full.name] = full
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   235
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   236
    component_groups = collections.defaultdict(list)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   237
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   238
    # Now emit a <Fragment> for each directory.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   239
    # Each directory is composed of a <DirectoryRef> pointing to its parent
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   240
    # and defines child <Directory>'s and a <Component> with all the files.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   241
    for dir_name, entries in sorted(manifest.items()):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   242
        # The directory id is derived from the path. But the root directory
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   243
        # is special.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   244
        if dir_name == '.':
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   245
            parent_directory_id = 'INSTALLDIR'
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   246
        else:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   247
            parent_directory_id = 'hg.dir.%s' % dir_name.replace('/', '.')
41962
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   248
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   249
        fragment = doc.createElement('Fragment')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   250
        directory_ref = doc.createElement('DirectoryRef')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   251
        directory_ref.setAttribute('Id', parent_directory_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   252
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   253
        # Add <Directory> entries for immediate children directories.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   254
        for possible_child in sorted(manifest.keys()):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   255
            if (
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   256
                dir_name == '.'
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   257
                and '/' not in possible_child
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   258
                and possible_child != '.'
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   259
            ):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   260
                child_directory_id = 'hg.dir.%s' % possible_child
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   261
                name = possible_child
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   262
            else:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   263
                if not possible_child.startswith('%s/' % dir_name):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   264
                    continue
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   265
                name = possible_child[len(dir_name) + 1 :]
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   266
                if '/' in name:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   267
                    continue
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   268
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   269
                child_directory_id = 'hg.dir.%s' % possible_child.replace(
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   270
                    '/', '.'
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   271
                )
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   272
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   273
            directory = doc.createElement('Directory')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   274
            directory.setAttribute('Id', child_directory_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   275
            directory.setAttribute('Name', name)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   276
            directory_ref.appendChild(directory)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   277
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   278
        # Add <Component>s for files in this directory.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   279
        for rel, source_path in sorted(entries.items()):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   280
            if dir_name == '.':
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   281
                full_rel = rel
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   282
            else:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   283
                full_rel = '%s/%s' % (dir_name, rel)
41962
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   284
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   285
            component_unique_id = (
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   286
                'https://www.mercurial-scm.org/wix-installer/0/component/%s'
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   287
                % full_rel
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   288
            )
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   289
            component_guid = uuid.uuid5(uuid.NAMESPACE_URL, component_unique_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   290
            component_id = 'hg.component.%s' % str(component_guid).replace(
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   291
                '-', '_'
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   292
            )
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   293
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   294
            component = doc.createElement('Component')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   295
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   296
            component.setAttribute('Id', component_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   297
            component.setAttribute('Guid', str(component_guid).upper())
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   298
            component.setAttribute('Win64', 'yes' if is_x64 else 'no')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   299
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   300
            # Assign this component to a top-level group.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   301
            if dir_name == '.':
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   302
                component_groups['ROOT'].append(component_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   303
            elif '/' in dir_name:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   304
                component_groups[dir_name[0 : dir_name.index('/')]].append(
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   305
                    component_id
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   306
                )
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   307
            else:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   308
                component_groups[dir_name].append(component_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   309
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   310
            unique_id = (
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   311
                'https://www.mercurial-scm.org/wix-installer/0/%s' % full_rel
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   312
            )
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   313
            file_guid = uuid.uuid5(uuid.NAMESPACE_URL, unique_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   314
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   315
            # IDs have length limits. So use GUID to derive them.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   316
            file_guid_normalized = str(file_guid).replace('-', '_')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   317
            file_id = 'hg.file.%s' % file_guid_normalized
41962
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   318
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   319
            file_element = doc.createElement('File')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   320
            file_element.setAttribute('Id', file_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   321
            file_element.setAttribute('Source', str(source_path))
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   322
            file_element.setAttribute('KeyPath', 'yes')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   323
            file_element.setAttribute('ReadOnly', 'yes')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   324
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   325
            component.appendChild(file_element)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   326
            directory_ref.appendChild(component)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   327
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   328
        fragment.appendChild(directory_ref)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   329
        doc.documentElement.appendChild(fragment)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   330
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   331
    for group, component_ids in sorted(component_groups.items()):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   332
        fragment = doc.createElement('Fragment')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   333
        component_group = doc.createElement('ComponentGroup')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   334
        component_group.setAttribute('Id', 'hg.group.%s' % group)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   335
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   336
        for component_id in component_ids:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   337
            component_ref = doc.createElement('ComponentRef')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   338
            component_ref.setAttribute('Id', component_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   339
            component_group.appendChild(component_ref)
41962
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   340
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   341
        fragment.appendChild(component_group)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   342
        doc.documentElement.appendChild(fragment)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   343
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   344
    # Add <Shortcut> to files that have it defined.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   345
    for file_id, metadata in sorted(SHORTCUTS.items()):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   346
        els = doc.getElementsByTagName('File')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   347
        els = [el for el in els if el.getAttribute('Id') == file_id]
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   348
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   349
        if not els:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   350
            raise Exception('could not find File[Id=%s]' % file_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   351
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   352
        for el in els:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   353
            shortcut = doc.createElement('Shortcut')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   354
            shortcut.setAttribute('Id', 'hg.shortcut.%s' % file_id)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   355
            shortcut.setAttribute('Directory', 'ProgramMenuDir')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   356
            shortcut.setAttribute('Icon', 'hgIcon.ico')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   357
            shortcut.setAttribute('IconIndex', '0')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   358
            shortcut.setAttribute('Advertise', 'yes')
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   359
            for k, v in sorted(metadata.items()):
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   360
                shortcut.setAttribute(k, v)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   361
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   362
            el.appendChild(shortcut)
41962
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   363
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   364
    return doc.toprettyxml()
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   365
131d0b7c3940 wix: autogenerate wxs file for library files
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41961
diff changeset
   366
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   367
def build_installer(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   368
    source_dir: pathlib.Path,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   369
    python_exe: pathlib.Path,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   370
    msi_name='mercurial',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   371
    version=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   372
    post_build_fn=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   373
    extra_packages_script=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   374
    extra_wxs: typing.Optional[typing.Dict[str, str]] = None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   375
    extra_features: typing.Optional[typing.List[str]] = None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   376
):
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   377
    """Build a WiX MSI installer.
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   378
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   379
    ``source_dir`` is the path to the Mercurial source tree to use.
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   380
    ``arch`` is the target architecture. either ``x86`` or ``x64``.
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   381
    ``python_exe`` is the path to the Python executable to use/bundle.
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   382
    ``version`` is the Mercurial version string. If not defined,
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   383
    ``mercurial/__version__.py`` will be consulted.
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   384
    ``post_build_fn`` is a callable that will be called after building
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   385
    Mercurial but before invoking WiX. It can be used to e.g. facilitate
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   386
    signing. It is passed the paths to the Mercurial source, build, and
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   387
    dist directories and the resolved Mercurial version.
42047
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41962
diff changeset
   388
    ``extra_packages_script`` is a command to be run to inject extra packages
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41962
diff changeset
   389
    into the py2exe binary. It should stage packages into the virtualenv and
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41962
diff changeset
   390
    print a null byte followed by a newline-separated list of packages that
715d3220ac4f wix: add a hook for a prebuild script to inject extra libraries
Augie Fackler <augie@google.com>
parents: 41962
diff changeset
   391
    should be included in the exe.
42048
978b03d5f66e wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents: 42047
diff changeset
   392
    ``extra_wxs`` is a dict of {wxs_name: working_dir_for_wxs_build}.
42049
1711f5813a63 wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents: 42048
diff changeset
   393
    ``extra_features`` is a list of additional named Features to include in
1711f5813a63 wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents: 42048
diff changeset
   394
    the build. These must match Feature names in one of the wxs scripts.
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   395
    """
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   396
    arch = 'x64' if r'\x64' in os.environ.get('LIB', '') else 'x86'
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   397
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   398
    hg_build_dir = source_dir / 'build'
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   399
    dist_dir = source_dir / 'dist'
41961
39f65c506899 wix: introduce variable to hold path to wix packaging directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41957
diff changeset
   400
    wix_dir = source_dir / 'contrib' / 'packaging' / 'wix'
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   401
41961
39f65c506899 wix: introduce variable to hold path to wix packaging directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41957
diff changeset
   402
    requirements_txt = wix_dir / 'requirements.txt'
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   403
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   404
    build_py2exe(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   405
        source_dir,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   406
        hg_build_dir,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   407
        python_exe,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   408
        'wix',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   409
        requirements_txt,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   410
        extra_packages=EXTRA_PACKAGES,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   411
        extra_packages_script=extra_packages_script,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   412
    )
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   413
44144
2251b6cde170 wix: always normalize version string
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44143
diff changeset
   414
    orig_version = version or find_version(source_dir)
2251b6cde170 wix: always normalize version string
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44143
diff changeset
   415
    version = normalize_version(orig_version)
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   416
    print('using version string: %s' % version)
44144
2251b6cde170 wix: always normalize version string
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44143
diff changeset
   417
    if version != orig_version:
2251b6cde170 wix: always normalize version string
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44143
diff changeset
   418
        print('(normalized from: %s)' % orig_version)
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   419
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   420
    if post_build_fn:
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   421
        post_build_fn(source_dir, hg_build_dir, dist_dir, version)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   422
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   423
    build_dir = hg_build_dir / ('wix-%s' % arch)
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   424
    staging_dir = build_dir / 'stage'
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   425
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   426
    build_dir.mkdir(exist_ok=True)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   427
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   428
    # Purge the staging directory for every build so packaging is pristine.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   429
    if staging_dir.exists():
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   430
        print('purging %s' % staging_dir)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   431
        shutil.rmtree(staging_dir)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   432
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   433
    stage_install(source_dir, staging_dir, lower_case=True)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   434
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   435
    # We also install some extra files.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   436
    process_install_rules(EXTRA_INSTALL_RULES, source_dir, staging_dir)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   437
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   438
    # And remove some files we don't want.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   439
    for f in STAGING_REMOVE_FILES:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   440
        p = staging_dir / f
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   441
        if p.exists():
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   442
            print('removing %s' % p)
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   443
            p.unlink()
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   444
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   445
    wix_pkg, wix_entry = download_entry('wix', hg_build_dir)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   446
    wix_path = hg_build_dir / ('wix-%s' % wix_entry['version'])
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   447
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   448
    if not wix_path.exists():
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   449
        extract_zip_to_directory(wix_pkg, wix_path)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   450
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   451
    ensure_vc90_merge_modules(hg_build_dir)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   452
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   453
    source_build_rel = pathlib.Path(os.path.relpath(source_dir, build_dir))
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   454
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   455
    defines = {'Platform': arch}
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   456
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   457
    # Derive a .wxs file with the staged files.
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   458
    manifest_wxs = build_dir / 'stage.wxs'
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   459
    with manifest_wxs.open('w', encoding='utf-8') as fh:
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   460
        fh.write(make_files_xml(staging_dir, is_x64=arch == 'x64'))
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   461
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   462
    run_candle(wix_path, build_dir, manifest_wxs, staging_dir, defines=defines)
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   463
42048
978b03d5f66e wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents: 42047
diff changeset
   464
    for source, rel_path in sorted((extra_wxs or {}).items()):
978b03d5f66e wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents: 42047
diff changeset
   465
        run_candle(wix_path, build_dir, source, rel_path, defines=defines)
978b03d5f66e wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents: 42047
diff changeset
   466
41961
39f65c506899 wix: introduce variable to hold path to wix packaging directory
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41957
diff changeset
   467
    source = wix_dir / 'mercurial.wxs'
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   468
    defines['Version'] = version
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   469
    defines['Comments'] = 'Installs Mercurial version %s' % version
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   470
    defines['VCRedistSrcDir'] = str(hg_build_dir)
42049
1711f5813a63 wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents: 42048
diff changeset
   471
    if extra_features:
1711f5813a63 wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents: 42048
diff changeset
   472
        assert all(';' not in f for f in extra_features)
1711f5813a63 wix: add functionality to inject additional Features into installer
Augie Fackler <raf@durin42.com>
parents: 42048
diff changeset
   473
        defines['MercurialExtraFeatures'] = ';'.join(extra_features)
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   474
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   475
    run_candle(wix_path, build_dir, source, source_build_rel, defines=defines)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   476
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   477
    msi_path = (
44145
62111bc5ff87 wix: use original version string for MSI filename
Gregory Szorc <gregory.szorc@gmail.com>
parents: 44144
diff changeset
   478
        source_dir / 'dist' / ('%s-%s-%s.msi' % (msi_name, orig_version, arch))
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   479
    )
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   480
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   481
    args = [
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   482
        str(wix_path / 'light.exe'),
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   483
        '-nologo',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   484
        '-ext',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   485
        'WixUIExtension',
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   486
        '-sw1076',
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   487
        '-spdb',
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   488
        '-o',
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   489
        str(msi_path),
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   490
    ]
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   491
42048
978b03d5f66e wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents: 42047
diff changeset
   492
    for source, rel_path in sorted((extra_wxs or {}).items()):
978b03d5f66e wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents: 42047
diff changeset
   493
        assert source.endswith('.wxs')
978b03d5f66e wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents: 42047
diff changeset
   494
        source = os.path.basename(source)
978b03d5f66e wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents: 42047
diff changeset
   495
        args.append(str(build_dir / ('%s.wixobj' % source[:-4])))
978b03d5f66e wix: add support for additional wxs files
Augie Fackler <raf@durin42.com>
parents: 42047
diff changeset
   496
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   497
    args.extend(
43667
94eac340d212 packaging: stage files and dynamically generate WiX installer
Gregory Szorc <gregory.szorc@gmail.com>
parents: 43570
diff changeset
   498
        [str(build_dir / 'stage.wixobj'), str(build_dir / 'mercurial.wixobj'),]
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   499
    )
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   500
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   501
    subprocess.run(args, cwd=str(source_dir), check=True)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   502
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   503
    print('%s created' % msi_path)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   504
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   505
    return {
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   506
        'msi_path': msi_path,
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   507
    }
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   508
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   509
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   510
def build_signed_installer(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   511
    source_dir: pathlib.Path,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   512
    python_exe: pathlib.Path,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   513
    name: str,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   514
    version=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   515
    subject_name=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   516
    cert_path=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   517
    cert_password=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   518
    timestamp_url=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   519
    extra_packages_script=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   520
    extra_wxs=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   521
    extra_features=None,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   522
):
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   523
    """Build an installer with signed executables."""
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   524
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   525
    post_build_fn = make_post_build_signing_fn(
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   526
        name,
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   527
        subject_name=subject_name,
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   528
        cert_path=cert_path,
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   529
        cert_password=cert_password,
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   530
        timestamp_url=timestamp_url,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   531
    )
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   532
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   533
    info = build_installer(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   534
        source_dir,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   535
        python_exe=python_exe,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   536
        msi_name=name.lower(),
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   537
        version=version,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   538
        post_build_fn=post_build_fn,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   539
        extra_packages_script=extra_packages_script,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   540
        extra_wxs=extra_wxs,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   541
        extra_features=extra_features,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   542
    )
41957
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   543
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   544
    description = '%s %s' % (name, version)
b83de9150c1c packaging: convert files to LF
Gregory Szorc <gregory.szorc@gmail.com>
parents: 41929
diff changeset
   545
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   546
    sign_with_signtool(
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   547
        info['msi_path'],
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   548
        description,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   549
        subject_name=subject_name,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   550
        cert_path=cert_path,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   551
        cert_password=cert_password,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   552
        timestamp_url=timestamp_url,
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 42049
diff changeset
   553
    )