Skip to content

Commit 093b1d4

Browse files
committed
Use more recent version for libyaml
1 parent 5896420 commit 093b1d4

File tree

4 files changed

+77
-257
lines changed

4 files changed

+77
-257
lines changed

src/VcpkgPortOverlay/CreatePortOverlay.ps1

Lines changed: 67 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,21 @@ function Select-DirectoryInPatch
9999
return $result
100100
}
101101

102+
<#
103+
When updating a portfile, we look for a section that looks like this:
104+
105+
vcpkg_from_github(
106+
OUT_SOURCE_PATH SOURCE_PATH
107+
REPO <user/repo>
108+
REF <commith hash>
109+
SHA512 <code .tar.gz hash>
110+
HEAD_REF master
111+
PATCHES
112+
patch-1.patch
113+
patch-2.patch
114+
)
115+
#>
116+
102117
# Adds a patch to a portfile.cmake
103118
function Add-PatchToPortFile
104119
{
@@ -109,22 +124,7 @@ function Add-PatchToPortFile
109124
[string]$PatchName
110125
)
111126

112-
<#
113-
We're looking for a section that looks like this:
114-
115-
vcpkg_from_github(
116-
OUT_SOURCE_PATH SOURCE_PATH
117-
REPO <user/repo>
118-
REF <commith hash>
119-
SHA512 <hash>
120-
HEAD_REF master
121-
PATCHES
122-
patch-1.patch
123-
patch-2.patch
124-
)
125-
126-
We look for the line that says "PATCHES" and add the new patch before the closing parenthesis
127-
#>
127+
# Look for the line that says "PATCHES" and add the new patch before the closing parenthesis
128128

129129
$portFilePath = Join-Path $OverlayRoot $Port "portfile.cmake"
130130
$originalPortFile = Get-Content $portFilePath
@@ -179,8 +179,57 @@ function Add-PatchToPort
179179
Add-PatchToPortFile -Port $Port -PatchName $PatchName
180180
}
181181

182+
# Sets the value of an existing function parameter.
183+
# For example, REF in vcpkg_from_github
184+
function Set-ParameterInPortFile
185+
{
186+
param(
187+
[Parameter(Mandatory)]
188+
[string]$Port,
189+
[Parameter(Mandatory)]
190+
[string]$ParameterName,
191+
[Parameter(Mandatory)]
192+
[string]$CurrentValuePattern,
193+
[Parameter(Mandatory)]
194+
[string]$NewValue
195+
)
196+
197+
$portFilePath = Join-Path $OverlayRoot $Port 'portfile.cmake'
198+
$originalPortFile = Get-Content $portFilePath
199+
200+
# Explanation for the regex:
201+
# '(?<=)' - lookbehind without matching
202+
# '^ +' - the parameter is only preceeded by spaces (and followed by a single space)
203+
# '(?=)' - lookahead without matching
204+
# ' |$' - the parameter may be the end of the line, or be followed by something else after a space (e.g. a comment)
205+
$regex = "(?<=^ +$ParameterName )$CurrentValuePattern(?= |$)"
206+
207+
$modifiedPortFile = $originalPortFile -replace $regex, $NewValue
208+
$modifiedPortFile | Out-File $portFilePath
209+
}
210+
211+
# Updates the source commit used for a port.
212+
# Takes the commit hash, and the hash of the archive with the code that vcpkg will download.
213+
function Update-PortSource
214+
{
215+
param(
216+
[Parameter(Mandatory)]
217+
[string]$Port,
218+
[Parameter(Mandatory)]
219+
[string]$Commit,
220+
[Parameter(Mandatory)]
221+
[string]$SourceHash
222+
)
223+
224+
$portDir = Join-Path $OverlayRoot $Port
225+
226+
Set-ParameterInPortFile $Port -ParameterName 'REF' -CurrentValuePattern '[0-9a-f]{40}' -NewValue $Commit
227+
Set-ParameterInPortFile $Port -ParameterName 'SHA512' -CurrentValuePattern '[0-9a-f]{128}' -NewValue $SourceHash
228+
}
229+
230+
182231
New-PortOverlay cpprestsdk
183-
Add-PatchToPort cpprestsdk -PatchRepo "microsoft/winget-cli" -PatchCommit "888b4ed8f4f7d25cb05a47210e083fe29348163b" -PatchName "add-server-certificate-validation.patch" -PatchRoot "src/cpprestsdk/cpprestsdk"
232+
Add-PatchToPort cpprestsdk -PatchRepo 'microsoft/winget-cli' -PatchCommit '888b4ed8f4f7d25cb05a47210e083fe29348163b' -PatchName 'add-server-certificate-validation.patch' -PatchRoot 'src/cpprestsdk/cpprestsdk'
184233

185234
New-PortOverlay libyaml
186-
Add-PatchToPort libyaml -PatchRepo "yaml/libyaml" -PatchCommit "51843fe48257c6b7b6e70cdec1db634f64a40818" -PatchName "fix-parser-nesting.patch"
235+
Update-PortSource libyaml -Commit '840b65c40675e2d06bf40405ad3f12dec7f35923' -SourceHash 'de85560312d53a007a2ddf1fe403676bbd34620480b1ba446b8c16bb366524ba7a6ed08f6316dd783bf980d9e26603a9efc82f134eb0235917b3be1d3eb4b302'

src/VcpkgPortOverlay/README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
# Overlay ports
22

3-
This directory contains an overlay for vcpkg ports, for cases where we need to apply local patches.
4-
In all cases, most of the recipe is taken from the [official vcpkg registry](https://github.com/Microsoft/vcpkg), and we only add a patch.
3+
This directory contains an overlay for vcpkg ports, for cases where we need local modifications to a port.
4+
In all cases, most of the recipe is taken from the [official vcpkg registry](https://github.com/Microsoft/vcpkg), and we only make small changes.
55

66
The whole directory can be re-created with `.\CreatePortOverlay.ps1`
77

88
## cpprestsdk
99

1010
We add support for certificate pinning.
1111

12-
Patch file: `add-server-certificate-validation.patch`
13-
Source for the change: https://github.com/microsoft/winget-cli/commit/888b4ed8f4f7d25cb05a47210e083fe29348163b
12+
Changes:
13+
* Add patch file: `add-server-certificate-validation.patch`
14+
Patch source: https://github.com/microsoft/winget-cli/commit/888b4ed8f4f7d25cb05a47210e083fe29348163b
1415

1516
## libyaml
1617

17-
We apply a patch for a vulnerability.
18+
We use an unreleased version that fixes a vulnerability.
1819

19-
Patch file: `fix-parser-nesting.patch`
20-
Source for the change: https://github.com/yaml/libyaml/commit/51843fe48257c6b7b6e70cdec1db634f64a40818
20+
Changes:
21+
* New source commit: https://github.com/yaml/libyaml/commit/840b65c40675e2d06bf40405ad3f12dec7f35923

src/VcpkgPortOverlay/libyaml/fix-parser-nesting.patch

Lines changed: 0 additions & 229 deletions
This file was deleted.

src/VcpkgPortOverlay/libyaml/portfile.cmake

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,12 @@ endif()
55
vcpkg_from_github(
66
OUT_SOURCE_PATH SOURCE_PATH
77
REPO yaml/libyaml
8-
REF 2c891fc7a770e8ba2fec34fc6b545c672beb37e6 # 0.2.5
9-
SHA512 7cdde7b48c937777b851747f7e0b9a74cb7da30173e09305dad931ef83c3fcee3e125e721166690fe6a0987ba897564500530e5518e4b66b1c9b1db8900bf320
8+
REF 840b65c40675e2d06bf40405ad3f12dec7f35923 # 0.2.5
9+
SHA512 de85560312d53a007a2ddf1fe403676bbd34620480b1ba446b8c16bb366524ba7a6ed08f6316dd783bf980d9e26603a9efc82f134eb0235917b3be1d3eb4b302
1010
HEAD_REF master
1111
PATCHES
1212
${PATCHES}
1313
export-pkgconfig.patch
14-
fix-parser-nesting.patch
1514
)
1615

1716
vcpkg_cmake_configure(

0 commit comments

Comments
 (0)