80 'bin_x86': bin_version / 'x86', |
80 'bin_x86': bin_version / 'x86', |
81 'bin_x64': bin_version / 'x64', |
81 'bin_x64': bin_version / 'x64', |
82 } |
82 } |
83 |
83 |
84 |
84 |
|
85 def normalize_windows_version(version): |
|
86 """Normalize Mercurial version string so WiX/Inno accepts it. |
|
87 |
|
88 Version strings have to be numeric ``A.B.C[.D]`` to conform with MSI's |
|
89 requirements. |
|
90 |
|
91 We normalize RC version or the commit count to a 4th version component. |
|
92 We store this in the 4th component because ``A.B.C`` releases do occur |
|
93 and we want an e.g. ``5.3rc0`` version to be semantically less than a |
|
94 ``5.3.1rc2`` version. This requires always reserving the 3rd version |
|
95 component for the point release and the ``X.YrcN`` release is always |
|
96 point release 0. |
|
97 |
|
98 In the case of an RC and presence of ``+`` suffix data, we can't use both |
|
99 because the version format is limited to 4 components. We choose to use |
|
100 RC and throw away the commit count in the suffix. This means we could |
|
101 produce multiple installers with the same normalized version string. |
|
102 |
|
103 >>> normalize_windows_version("5.3") |
|
104 '5.3.0' |
|
105 |
|
106 >>> normalize_windows_version("5.3rc0") |
|
107 '5.3.0.0' |
|
108 |
|
109 >>> normalize_windows_version("5.3rc1") |
|
110 '5.3.0.1' |
|
111 |
|
112 >>> normalize_windows_version("5.3rc1+2-abcdef") |
|
113 '5.3.0.1' |
|
114 |
|
115 >>> normalize_windows_version("5.3+2-abcdef") |
|
116 '5.3.0.2' |
|
117 """ |
|
118 if '+' in version: |
|
119 version, extra = version.split('+', 1) |
|
120 else: |
|
121 extra = None |
|
122 |
|
123 # 4.9rc0 |
|
124 if version[:-1].endswith('rc'): |
|
125 rc = int(version[-1:]) |
|
126 version = version[:-3] |
|
127 else: |
|
128 rc = None |
|
129 |
|
130 # Ensure we have at least X.Y version components. |
|
131 versions = [int(v) for v in version.split('.')] |
|
132 while len(versions) < 3: |
|
133 versions.append(0) |
|
134 |
|
135 if len(versions) < 4: |
|
136 if rc is not None: |
|
137 versions.append(rc) |
|
138 elif extra: |
|
139 # <commit count>-<hash>+<date> |
|
140 versions.append(int(extra.split('-')[0])) |
|
141 |
|
142 return '.'.join('%d' % x for x in versions[0:4]) |
|
143 |
|
144 |
85 def find_signtool(): |
145 def find_signtool(): |
86 """Find signtool.exe from the Windows SDK.""" |
146 """Find signtool.exe from the Windows SDK.""" |
87 sdk = windows_10_sdk_info() |
147 sdk = windows_10_sdk_info() |
88 |
148 |
89 for key in ('bin_x64', 'bin_x86'): |
149 for key in ('bin_x64', 'bin_x86'): |