Skip to content

Commit 425ec15

Browse files
committed
Issue python#28402: Adds signed catalog files for stdlib on Windows.
1 parent b1321fb commit 425ec15

File tree

11 files changed

+64
-7
lines changed

11 files changed

+64
-7
lines changed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,8 @@ Library
226226
Windows
227227
-------
228228

229+
- Issue #28402: Adds signed catalog files for stdlib on Windows.
230+
229231
- Issue #28333: Enables Unicode for ps1/ps2 and input() prompts. (Patch by
230232
Eryk Sun)
231233

PCbuild/pyproject.props

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,13 @@ foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses
147147
Targets="CleanAll" />
148148
</Target>
149149

150-
<PropertyGroup Condition="'$(SigningCertificate)' != '' and $(SupportSigning)">
151-
<SignToolPath Condition="'$(SignToolPath)' == '' or !Exists($(SignToolPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86\signtool.exe</SignToolPath>
152-
<SignToolPath Condition="!Exists($(SignToolPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86\signtool.exe</SignToolPath>
153-
<SignToolPath Condition="!Exists($(SignToolPath))">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\signtool.exe</SignToolPath>
154-
<_SignCommand Condition="Exists($(SignToolPath))">"$(SignToolPath)" sign /q /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)"</_SignCommand>
150+
<PropertyGroup>
151+
<SdkBinPath Condition="'$(SdkBinPath)' == '' or !Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot10)\bin\x86</SdkBinPath>
152+
<SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot81)\bin\x86</SdkBinPath>
153+
<SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\Software\Microsoft\Windows Kits\Installed Roots@KitsRoot)\bin\x86</SdkBinPath>
154+
<SdkBinPath Condition="!Exists($(SdkBinPath))">$(registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)\Bin\</SdkBinPath>
155+
<_SignCommand Condition="Exists($(SdkBinPath)) and '$(SigningCertificate)' != '' and $(SupportSigning)">"$(SdkBinPath)\signtool.exe" sign /q /n "$(SigningCertificate)" /fd sha256 /t http://timestamp.verisign.com/scripts/timestamp.dll /d "Python $(PythonVersion)"</_SignCommand>
156+
<_MakeCatCommand Condition="Exists($(SdkBinPath))">"$(SdkBinPath)\makecat.exe"</_MakeCatCommand>
155157
</PropertyGroup>
156158

157159
<Target Name="_SignBuild" AfterTargets="AfterBuild" Condition="'$(SigningCertificate)' != '' and $(SupportSigning)">

Tools/msi/common.wxs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@
6363
<!-- Top-level directories -->
6464
<Fragment>
6565
<DirectoryRef Id="InstallDirectory">
66-
<Directory Id="DLLs" Name="DLLs" />
66+
<Directory Id="DLLs" Name="DLLs">
67+
<Directory Id="Catalogs" />
68+
</Directory>
6769
</DirectoryRef>
6870
</Fragment>
6971

Tools/msi/lib/lib.wixproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<TargetBase>$(PySourcePath)Lib</TargetBase>
2828
<Target_>Lib\</Target_>
2929
<Group>lib_py</Group>
30+
<IncludeInCat>true</IncludeInCat>
3031
</InstallFiles>
3132
</ItemGroup>
3233

Tools/msi/lib/lib.wxs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<ComponentGroupRef Id="lib_py" />
1212
<ComponentGroupRef Id="lib_files" />
1313
<ComponentGroupRef Id="lib_extensions" />
14+
<ComponentGroupRef Id="lib_cat" />
1415
<ComponentRef Id="OptionalFeature" />
1516
</Feature>
1617
</Product>

Tools/msi/lib/lib_files.wxs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,11 @@
7070
</Component>
7171
</ComponentGroup>
7272
</Fragment>
73+
<Fragment>
74+
<ComponentGroup Id="lib_cat">
75+
<Component Id="lib_cat" Directory="Catalogs" Guid="*">
76+
<File Name="python_lib.cat" KeyPath="yes" />
77+
</Component>
78+
</ComponentGroup>
79+
</Fragment>
7380
</Wix>

Tools/msi/msi.props

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<Configuration Condition="'$(Configuration)' == ''">Release</Configuration>
1212
<Platform Condition="'$(Platform)' == ''">x86</Platform>
1313
<InstallScope Condition="'$(InstallScope)' != 'perMachine'">perUser</InstallScope>
14+
<_MakeCatCommand Condition="'$(_MakeCatCommand)' == ''">makecat</_MakeCatCommand>
1415
</PropertyGroup>
1516

1617
<Import Project="wix.props" />
@@ -103,6 +104,7 @@
103104
<Group>generated_filelist</Group>
104105
<Condition></Condition>
105106
<DiskId></DiskId>
107+
<IncludeInCat>false</IncludeInCat>
106108
</InstallFiles>
107109
<LinkerBindInputPaths>
108110
<Visible>false</Visible>

Tools/msi/msi.targets

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@
1212
<_Source>%(Source)$([msbuild]::MakeRelative(%(SourceBase), %(FullPath)))</_Source>
1313
<_Target>%(Target_)$([msbuild]::MakeRelative(%(TargetBase), %(FullPath)))</_Target>
1414
</InstallFiles>
15+
16+
<_CatalogFiles Include="@(InstallFiles)" Condition="%(InstallFiles.IncludeInCat) and ''!=$([System.IO.File]::ReadAllText(%(InstallFiles.FullPath)))" />
1517
</ItemGroup>
16-
18+
1719
<WriteLinesToFile File="$(_FileListTarget)" Lines="@(InstallFiles->'&quot;%(_Source)&quot;,&quot;%(_Target)&quot;,&quot;%(Group)&quot;,&quot;%(DiskId)&quot;,&quot;%(Condition)&quot;')" Overwrite="true" />
1820
<Exec Command='"$(PythonExe)" csv_to_wxs.py "$(_FileListTarget)" "$(_InstallFilesTarget)"'
1921
WorkingDirectory="$(MSBuildThisFileDirectory)" />
@@ -24,6 +26,35 @@
2426
</ItemGroup>
2527
</Target>
2628

29+
<Target Name="GenerateCatalog" AfterTargets="ProcessInstallFiles" Condition="'@(_CatalogFiles)' != ''">
30+
<PropertyGroup>
31+
<_CatFileSourceTarget>$(IntermediateOutputPath)$(MSBuildProjectName).cdf</_CatFileSourceTarget>
32+
<_CatFileTarget>$(IntermediateOutputPath)python_$(MSBuildProjectName).cat</_CatFileTarget>
33+
<_CatFile>[CatalogHeader]
34+
Name=$([System.IO.Path]::GetFileName($(_CatFileTarget)))
35+
ResultDir=$([System.IO.Path]::GetDirectoryName($(_CatFileTarget)))
36+
PublicVersion=1
37+
CatalogVersion=2
38+
HashAlgorithms=SHA256
39+
PageHashes=false
40+
EncodingType=
41+
42+
[CatalogFiles]
43+
@(_CatalogFiles->'&lt;HASH&gt;%(Filename)%(Extension)=%(FullPath)','
44+
')
45+
</_CatFile>
46+
</PropertyGroup>
47+
48+
<WriteLinesToFile File="$(_CatFileSourceTarget)" Lines="$(_CatFile)" Overwrite="true" />
49+
<Exec Command='$(_MakeCatCommand) "$(_CatFileSourceTarget)"' WorkingDirectory="$(MSBuildThisFileDirectory)" />
50+
<Exec Command='$(_SignCommand) "$(_CatFileTarget)"' WorkingDirectory="$(MSBuildThisFileDirectory)"
51+
Condition="Exists($(_CatFileTarget)) and '$(_SignCommand)' != ''" />
52+
53+
<ItemGroup>
54+
<FileWrites Include="$(_CatFileSourceTarget);$(_CatFileTarget)" />
55+
</ItemGroup>
56+
</Target>
57+
2758
<Target Name="_TransformWxlTemplates" AfterTargets="PrepareForBuild" Inputs="@(WxlTemplate);$(PySourcePath)include\patchlevel.h" Outputs="$(IntermediateOutputPath)%(Filename).wxl">
2859
<PropertyGroup Condition="'@(WxlTemplate)' != ''">
2960
<_Content>$([System.IO.File]::ReadAllText(%(WxlTemplate.FullPath)).Replace(`{{ShortVersion}}`, `$(MajorVersionNumber).$(MinorVersionNumber)$(PyTestExt)`).Replace(`{{LongVersion}}`, `$(PythonVersion)$(PyTestExt)`).Replace(`{{Bitness}}`, `$(Bitness)`))</_Content>

Tools/msi/tools/tools.wixproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<TargetBase>$(PySourcePath)</TargetBase>
3737
<Target_></Target_>
3838
<Group>tools_py</Group>
39+
<IncludeInCat>true</IncludeInCat>
3940
</InstallFiles>
4041
</ItemGroup>
4142

Tools/msi/tools/tools.wxs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
<Feature Id="DefaultFeature" AllowAdvertise="no" Title="!(loc.Title)" Description="!(loc.Description)">
1010
<ComponentGroupRef Id="tools_py" />
1111
<ComponentGroupRef Id="tools_scripts" />
12+
<ComponentGroupRef Id="tools_cat" />
1213
<ComponentRef Id="OptionalFeature" />
1314
</Feature>
1415
</Product>

0 commit comments

Comments
 (0)