Skip to content

Commit c39a082

Browse files
authored
Remove patched site extension logic (#10103)
1 parent 6c23426 commit c39a082

File tree

2 files changed

+0
-133
lines changed

2 files changed

+0
-133
lines changed

azure-pipelines.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -259,22 +259,6 @@ jobs:
259259
Verbosity: 'Information'
260260
- publish: $(Build.ArtifactStagingDirectory)\SiteExtension
261261
artifact: SiteExtension
262-
- pwsh: |
263-
if ((test-path $(Build.ArtifactStagingDirectory)\ZippedPatchSiteExtension))
264-
{
265-
Write-Host "Patched site extension detected."
266-
Write-Host "##vso[task.setvariable variable=isPatchVersion]true"
267-
}
268-
displayName: 'Set isPatchVersion'
269-
- task: ManifestGeneratorTask@0
270-
displayName: 'SBOM Generation Task - ZippedPatchSiteExtension'
271-
inputs:
272-
BuildDropPath: '$(Build.ArtifactStagingDirectory)\ZippedPatchSiteExtension'
273-
Verbosity: 'Information'
274-
condition: and(succeeded(), eq(variables['isPatchVersion'], 'true'))
275-
- publish: $(Build.ArtifactStagingDirectory)\ZippedPatchSiteExtension
276-
artifact: PatchedSiteExtension
277-
condition: and(succeeded(), eq(variables['isPatchVersion'], 'true'))
278262
- task: ManifestGeneratorTask@0
279263
displayName: 'SBOM Generation Task - PrivateSiteExtension'
280264
inputs:

build/build-extensions.ps1

Lines changed: 0 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,6 @@ $publishDir = "$outDir\pub\WebJobs.Script.WebHost"
1313
$extensionVersion = Get-AzureFunctionsVersion $buildNumber $suffix $minorVersionPrefix
1414
Write-Host "Site extension version: $extensionVersion"
1515

16-
# Construct variables for strings like "4.1.0-15898" and "4.1.0"
17-
$versionParts = ($extensionVersion -Split "-")[0] -Split "\."
18-
$majorMinorVersion = $versionParts[0] + "." + $versionParts[1]
19-
$patchVersion = [int]$versionParts[2]
20-
$isPatch = $patchVersion -gt 0
21-
Write-Host "MajorMinorVersion is '$majorMinorVersion'. Patch version is '$patchVersion'. IsPatch: '$isPatch'"
22-
2316
function ZipContent([string] $sourceDirectory, [string] $target) {
2417
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
2518

@@ -117,101 +110,6 @@ function CleanOutput([string] $rootPath) {
117110
Write-Host " Current size: $(GetFolderSizeInMb $rootPath) Mb"
118111
}
119112

120-
function CreatePatchedSiteExtension([string] $siteExtensionPath) {
121-
try {
122-
Write-Host "SiteExtensionPath is $siteExtensionPath"
123-
$officialSiteExtensionPath = "$siteExtensionPath\$extensionVersion"
124-
$baseVersion = "$majorMinorVersion.0"
125-
$baseZipPath = "$publishDir\BaseZipDirectory"
126-
$baseExtractedPath = "$publishDir\BaseZipDirectory\Extracted"
127-
128-
# Try to download base version
129-
New-Item -Itemtype "directory" -path "$baseZipPath" -Force > $null
130-
New-Item -Itemtype "directory" -path "$baseExtractedPath" -Force > $null
131-
$baseZipUrl = "https://github.com/Azure/azure-functions-host/releases/download/v$majorMinorVersion.0/Functions.$majorMinorVersion.0.zip"
132-
133-
Write-Host "Downloading from $baseZipUrl"
134-
(New-Object System.Net.WebClient).DownloadFile($baseZipUrl, "$baseZipPath\Functions.$majorMinorVersion.0.zip")
135-
Write-Host "Download complete"
136-
137-
# Extract zip
138-
Expand-Archive -LiteralPath "$baseZipPath\Functions.$majorMinorVersion.0.zip" -DestinationPath "$baseExtractedPath"
139-
140-
# Create directory for patch
141-
$zipOutput = "$publishDir\ZippedPatchSiteExtension"
142-
New-Item -Itemtype directory -path $zipOutput -Force > $null
143-
144-
# Copy extensions.xml as is
145-
Copy-Item "$siteExtensionPath\extension.xml" -Destination "$patchedContentDirectory\extension.xml"
146-
147-
# Read hashes.txt for base
148-
$hashForBase = @{}
149-
foreach($line in Get-Content "$baseExtractedPath\$baseVersion\hashesForHardlinks.txt") {
150-
$lineContents = $line.Split(" ")
151-
$hashKey = $lineContents[1].Split(":")[1]
152-
$hashValue = $lineContents[0].Split(":")[1]
153-
154-
$hashForBase.Add($hashKey, $hashValue)
155-
}
156-
157-
# Read hashes.txt for patched
158-
$hashForPatched = @{}
159-
foreach($line in Get-Content "$officialSiteExtensionPath\hashesForHardlinks.txt") {
160-
$lineContents = $line.Split(" ")
161-
$hashKey = $lineContents[1].Split(":")[1]
162-
$hashValue = $lineContents[0].Split(":")[1]
163-
164-
$hashForPatched.Add($hashKey, $hashValue)
165-
}
166-
167-
# Iterate over patched to generate the appropriate set of files
168-
$informationJson = New-Object System.Collections.ArrayList
169-
foreach($key in $hashForPatched.Keys) {
170-
$infoKeyValuePairs = @{}
171-
172-
# If key doesn't exist in base, or if the keys exists but their hashes don't match, copy over.
173-
if((!$hashForBase.ContainsKey($key)) -or ($hashForPatched[$key] -ne $hashForBase[$key])) {
174-
$filePath = $key.Replace(".\","")
175-
$sourcePath = "$officialSiteExtensionPath\$filePath"
176-
$destinationPath = "$patchedContentDirectory\$extensionVersion\$filePath"
177-
Write-Host "Copying $sourcePath to $destinationPath"
178-
$ValidPath = Test-Path "$destinationPath"
179-
180-
If ($ValidPath -eq $False){
181-
New-Item -Path "$destinationPath" -Force > $null
182-
}
183-
184-
Copy-Item "$sourcePath" "$destinationPath" -Force > $null
185-
186-
# Get it into info
187-
$infoKeyValuePairs.Add("FileName", $key)
188-
$infoKeyValuePairs.Add("SourceVersion", $extensionVersion)
189-
$infoKeyValuePairs.Add("HashValue", $hashForPatched[$key])
190-
$informationJson.Add($infoKeyValuePairs)
191-
continue
192-
}
193-
194-
# Add info that would help get this file from base
195-
$infoKeyValuePairs.Add("FileName", $key)
196-
$infoKeyValuePairs.Add("SourceVersion", $baseVersion)
197-
$infoKeyValuePairs.Add("HashValue", $hashForBase[$key])
198-
$informationJson.Add($infoKeyValuePairs)
199-
}
200-
$informationJson | ConvertTo-Json -depth 100 | Out-File "$patchedContentDirectory\$extensionVersion\HardlinksMetadata.json"
201-
202-
# Zip it up
203-
ZipContent $patchedContentDirectory "$zipOutput\Functions.$extensionVersion.zip"
204-
205-
# Clean up
206-
Remove-Item $patchedContentDirectory -Recurse -Force > $null
207-
}
208-
catch {
209-
Write-Host $_.Exception
210-
$statusCode = $_.Exception.Response.StatusCode.Value__
211-
Write-Host "Invoking url $baseZipUrl returned status code of $statusCode which could mean that no base version exists. The full version needs to be deployed"
212-
}
213-
}
214-
215113
function CreateSiteExtensions() {
216114
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
217115
$siteExtensionPath = "$publishDir\temp_extension"
@@ -278,21 +176,6 @@ function CreateSiteExtensions() {
278176
ZipContent $siteExtensionPath "$zipOutput\FunctionsInProc.$extensionVersion.zip"
279177
}
280178

281-
# Create directory for content even if there is no patch build. This makes artifact uploading easier.
282-
$patchedContentDirectory = "$publishDir\PatchedSiteExtension"
283-
New-Item -Itemtype directory -path $patchedContentDirectory -Force > $null
284-
285-
# Construct patch
286-
if($isPatch)
287-
{
288-
Write-Host "======================================"
289-
Write-Host "Generating patch file"
290-
CreatePatchedSiteExtension $siteExtensionPath
291-
Write-Host "Done generating patch files"
292-
Write-Host "======================================"
293-
Write-Host
294-
}
295-
296179
Remove-Item $siteExtensionPath -Recurse -Force > $null
297180

298181
Write-Host "======================================"

0 commit comments

Comments
 (0)