Skip to content

Commit

Permalink
Fix rebase issues
Browse files Browse the repository at this point in the history
  • Loading branch information
jviau committed May 1, 2024
1 parent 5873a18 commit 0b23095
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 5 deletions.
1 change: 0 additions & 1 deletion .sccignore

This file was deleted.

1 change: 0 additions & 1 deletion NuGet.config
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
<configuration>
<packageSources>
<clear />
<!-- <add key="upstream" value="https://pkgs.dev.azure.com/azfunc/internal/_packaging/upstream/nuget/v3/index.json" /> -->
<add key="nuget.org" value="https://api.nuget.org/v3/index.json" />
<add key="Microsoft.Azure.Functions.PowerShellWorker" value="https://azfunc.pkgs.visualstudio.com/e6a70c92-4128-439f-8012-382fe78d6396/_packaging/Microsoft.Azure.Functions.PowerShellWorker/nuget/v3/index.json" />
<add key="AzureFunctions@internalrelease" value="https://azfunc.pkgs.visualstudio.com/e6a70c92-4128-439f-8012-382fe78d6396/_packaging/AzureFunctions%40internalrelease/nuget/v3/index.json" />
Expand Down
6 changes: 3 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ jobs:
displayName: 'ESRP CodeSigning: Strong Name and Authenticode'
inputs:
ConnectedServiceName: 'ESRP Service'
FolderPath: 'out/bin/WebJobs.Script.Abstractions'
FolderPath: 'out/bin/WebJobs.Script.Abstractions/release'
Pattern: Microsoft.Azure.WebJobs.Script.Abstractions*.dll
signConfigType: inlineSignParams
inlineOperation: |
Expand Down Expand Up @@ -169,8 +169,8 @@ jobs:
displayName: 'ESRP CodeSigning: Strong Name and Authenticode'
inputs:
ConnectedServiceName: 'ESRP Service'
FolderPath: 'out/bin/ExtensionsMetadataGenerator/release'
Pattern: Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator*.dll
FolderPath: 'out/bin/ExtensionsMetadataGenerator'
Pattern: 'Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator*.dll'
signConfigType: inlineSignParams
inlineOperation: |
[
Expand Down
116 changes: 116 additions & 0 deletions build/build-extensions.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@ $publishDir = "$outDir\pub\WebJobs.Script.WebHost"
$extensionVersion = Get-AzureFunctionsVersion $buildNumber $suffix $minorVersionPrefix
Write-Host "Site extension version: $extensionVersion"

# Construct variables for strings like "4.1.0-15898" and "4.1.0"
$versionParts = ($extensionVersion -Split "-")[0] -Split "\."
$majorMinorVersion = $versionParts[0] + "." + $versionParts[1]
$patchVersion = [int]$versionParts[2]
$isPatch = $patchVersion -gt 0
Write-Host "MajorMinorVersion is '$majorMinorVersion'. Patch version is '$patchVersion'. IsPatch: '$isPatch'"

function ZipContent([string] $sourceDirectory, [string] $target) {
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()

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

function CreatePatchedSiteExtension([string] $siteExtensionPath) {
try {
Write-Host "SiteExtensionPath is $siteExtensionPath"
$officialSiteExtensionPath = "$siteExtensionPath\$extensionVersion"
$baseVersion = "$majorMinorVersion.0"
$baseZipPath = "$publishDir\BaseZipDirectory"
$baseExtractedPath = "$publishDir\BaseZipDirectory\Extracted"

# Try to download base version
New-Item -Itemtype "directory" -path "$baseZipPath" -Force > $null
New-Item -Itemtype "directory" -path "$baseExtractedPath" -Force > $null
$baseZipUrl = "https://github.com/Azure/azure-functions-host/releases/download/v$majorMinorVersion.0/Functions.$majorMinorVersion.0.zip"

Write-Host "Downloading from $baseZipUrl"
(New-Object System.Net.WebClient).DownloadFile($baseZipUrl, "$baseZipPath\Functions.$majorMinorVersion.0.zip")
Write-Host "Download complete"

# Extract zip
Expand-Archive -LiteralPath "$baseZipPath\Functions.$majorMinorVersion.0.zip" -DestinationPath "$baseExtractedPath"

# Create directory for patch
$zipOutput = "$publishDir\ZippedPatchSiteExtension"
New-Item -Itemtype directory -path $zipOutput -Force > $null

# Copy extensions.xml as is
Copy-Item "$siteExtensionPath\extension.xml" -Destination "$patchedContentDirectory\extension.xml"

# Read hashes.txt for base
$hashForBase = @{}
foreach($line in Get-Content "$baseExtractedPath\$baseVersion\hashesForHardlinks.txt") {
$lineContents = $line.Split(" ")
$hashKey = $lineContents[1].Split(":")[1]
$hashValue = $lineContents[0].Split(":")[1]

$hashForBase.Add($hashKey, $hashValue)
}

# Read hashes.txt for patched
$hashForPatched = @{}
foreach($line in Get-Content "$officialSiteExtensionPath\hashesForHardlinks.txt") {
$lineContents = $line.Split(" ")
$hashKey = $lineContents[1].Split(":")[1]
$hashValue = $lineContents[0].Split(":")[1]

$hashForPatched.Add($hashKey, $hashValue)
}

# Iterate over patched to generate the appropriate set of files
$informationJson = New-Object System.Collections.ArrayList
foreach($key in $hashForPatched.Keys) {
$infoKeyValuePairs = @{}

# If key doesn't exist in base, or if the keys exists but their hashes don't match, copy over.
if((!$hashForBase.ContainsKey($key)) -or ($hashForPatched[$key] -ne $hashForBase[$key])) {
$filePath = $key.Replace(".\","")
$sourcePath = "$officialSiteExtensionPath\$filePath"
$destinationPath = "$patchedContentDirectory\$extensionVersion\$filePath"
Write-Host "Copying $sourcePath to $destinationPath"
$ValidPath = Test-Path "$destinationPath"

If ($ValidPath -eq $False){
New-Item -Path "$destinationPath" -Force > $null
}

Copy-Item "$sourcePath" "$destinationPath" -Force > $null

# Get it into info
$infoKeyValuePairs.Add("FileName", $key)
$infoKeyValuePairs.Add("SourceVersion", $extensionVersion)
$infoKeyValuePairs.Add("HashValue", $hashForPatched[$key])
$informationJson.Add($infoKeyValuePairs)
continue
}

# Add info that would help get this file from base
$infoKeyValuePairs.Add("FileName", $key)
$infoKeyValuePairs.Add("SourceVersion", $baseVersion)
$infoKeyValuePairs.Add("HashValue", $hashForBase[$key])
$informationJson.Add($infoKeyValuePairs)
}
$informationJson | ConvertTo-Json -depth 100 | Out-File "$patchedContentDirectory\$extensionVersion\HardlinksMetadata.json"

# Zip it up
ZipContent $patchedContentDirectory "$zipOutput\Functions.$extensionVersion.zip"

# Clean up
Remove-Item $patchedContentDirectory -Recurse -Force > $null
}
catch {
Write-Host $_.Exception
$statusCode = $_.Exception.Response.StatusCode.Value__
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"
}
}

function CreateSiteExtensions() {
$stopwatch = [System.Diagnostics.Stopwatch]::StartNew()
$siteExtensionPath = "$publishDir\temp_extension"
Expand Down Expand Up @@ -180,6 +282,17 @@ function CreateSiteExtensions() {
$patchedContentDirectory = "$publishDir\PatchedSiteExtension"
New-Item -Itemtype directory -path $patchedContentDirectory -Force > $null

# Construct patch
if($isPatch)
{
Write-Host "======================================"
Write-Host "Generating patch file"
CreatePatchedSiteExtension $siteExtensionPath
Write-Host "Done generating patch files"
Write-Host "======================================"
Write-Host
}

Remove-Item $siteExtensionPath -Recurse -Force > $null

Write-Host "======================================"
Expand Down Expand Up @@ -214,6 +327,9 @@ if (Test-Path $publishDir) {
Remove-Item $publishDir -Recurse -Force -ErrorAction Stop
}

Write-Host "Extensions version: $extensionVersion"
Write-Host ""

BuildRuntime "win-x86"
BuildRuntime "win-x64"

Expand Down
1 change: 1 addition & 0 deletions build/initialize-pipeline.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ param (

$buildReason = $env:BUILD_REASON
$sourceBranch = $env:BUILD_SOURCEBRANCH
$provider = $env:BUILD_REPOSITORY_PROVIDER

Write-Host "BUILD_REASON: '$buildReason'"
Write-Host "BUILD_SOURCEBRANCH: '$sourceBranch'"
Expand Down

0 comments on commit 0b23095

Please sign in to comment.