2016-11-15 20:01:34 +00:00
|
|
|
|
<#
|
|
|
|
|
.NOTES
|
|
|
|
|
Author: @jhowardmsft
|
|
|
|
|
|
|
|
|
|
Summary: Windows native version of .go-autogen which generates the
|
|
|
|
|
.go source code for building, and performs resource compilation.
|
|
|
|
|
|
|
|
|
|
.PARAMETER CommitString
|
|
|
|
|
The commit string. This is calculated externally to this script.
|
|
|
|
|
|
|
|
|
|
.PARAMETER DockerVersion
|
2017-02-16 07:22:50 +00:00
|
|
|
|
The version such as 17.04.0-dev. This is calculated externally to this script.
|
2022-04-12 11:15:54 +00:00
|
|
|
|
|
|
|
|
|
.PARAMETER Platform
|
|
|
|
|
The platform name, such as "Docker Engine - Community".
|
|
|
|
|
|
|
|
|
|
.PARAMETER Product
|
|
|
|
|
The product name, used to set version.ProductName, which is used to set BuildKit's
|
|
|
|
|
ExportedProduct variable in order to show useful error messages to users when a
|
|
|
|
|
certain version of the product doesn't support a BuildKit feature.
|
|
|
|
|
|
|
|
|
|
.PARAMETER DefaultProductLicense
|
|
|
|
|
Sets the version.DefaultProductLicense string, such as "Community Engine". This field
|
|
|
|
|
can contain a summary of the product license of the daemon if a commercial license has
|
|
|
|
|
been applied to the daemon.
|
|
|
|
|
|
|
|
|
|
.PARAMETER PackagerName
|
|
|
|
|
The name of the packager (e.g. "Docker, Inc."). This used to set CompanyName in the manifest.
|
2016-11-15 20:01:34 +00:00
|
|
|
|
#>
|
|
|
|
|
|
|
|
|
|
param(
|
|
|
|
|
[Parameter(Mandatory=$true)][string]$CommitString,
|
2017-12-06 21:02:30 +00:00
|
|
|
|
[Parameter(Mandatory=$true)][string]$DockerVersion,
|
2018-07-11 22:25:38 +00:00
|
|
|
|
[Parameter(Mandatory=$false)][string]$Platform,
|
2018-08-18 00:05:21 +00:00
|
|
|
|
[Parameter(Mandatory=$false)][string]$Product,
|
2022-04-12 11:15:54 +00:00
|
|
|
|
[Parameter(Mandatory=$false)][string]$DefaultProductLicense,
|
|
|
|
|
[Parameter(Mandatory=$false)][string]$PackagerName
|
2016-11-15 20:01:34 +00:00
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
|
|
|
|
|
|
# Utility function to get the build date/time in UTC
|
|
|
|
|
Function Get-BuildDateTime() {
|
|
|
|
|
return $(Get-Date).ToUniversalTime()
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-12 11:15:54 +00:00
|
|
|
|
Function Get-Year() {
|
|
|
|
|
return $(Get-Date).year
|
|
|
|
|
}
|
2016-11-15 20:01:34 +00:00
|
|
|
|
|
2022-04-12 11:15:54 +00:00
|
|
|
|
Function Get-FixQuadVersionNumber($number) {
|
|
|
|
|
if ($number -eq 0) {
|
|
|
|
|
return $number
|
2016-11-15 20:01:34 +00:00
|
|
|
|
}
|
2022-04-12 11:15:54 +00:00
|
|
|
|
return $number.TrimStart("0")
|
|
|
|
|
}
|
2016-11-15 20:01:34 +00:00
|
|
|
|
|
2022-04-12 11:15:54 +00:00
|
|
|
|
try {
|
|
|
|
|
$buildDateTime=Get-BuildDateTime
|
|
|
|
|
$currentYear=Get-Year
|
2016-11-15 20:01:34 +00:00
|
|
|
|
|
2022-04-12 11:15:54 +00:00
|
|
|
|
# Update PATH
|
|
|
|
|
$env:PATH="$env:GOPATH\bin;$env:PATH"
|
2016-11-15 20:01:34 +00:00
|
|
|
|
|
|
|
|
|
# Generate a version in the form major,minor,patch,build
|
2022-04-12 11:15:54 +00:00
|
|
|
|
$versionQuad=($DockerVersion -replace "[^0-9.]*")
|
|
|
|
|
if ($versionQuad -Match "^\d+`.\d+`.\d+$"){
|
|
|
|
|
$versionQuad = $versionQuad + ".0"
|
|
|
|
|
}
|
|
|
|
|
$versionMatches = $($versionQuad | Select-String -AllMatches -Pattern "(\d+)`.(\d+)`.(\d+)`.(\d+)").Matches
|
2016-11-15 20:01:34 +00:00
|
|
|
|
|
2022-04-12 11:15:54 +00:00
|
|
|
|
$mkwinresContents = '{
|
|
|
|
|
"RT_GROUP_ICON": {
|
|
|
|
|
"#1": {
|
|
|
|
|
"0409": "../../winresources/docker.ico"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"RT_MANIFEST": {
|
|
|
|
|
"#1": {
|
|
|
|
|
"0409": {
|
|
|
|
|
"identity": {},
|
|
|
|
|
"description": "Docker Engine",
|
|
|
|
|
"minimum-os": "vista",
|
|
|
|
|
"execution-level": "",
|
|
|
|
|
"ui-access": false,
|
|
|
|
|
"auto-elevate": false,
|
|
|
|
|
"dpi-awareness": "unaware",
|
|
|
|
|
"disable-theming": false,
|
|
|
|
|
"disable-window-filtering": false,
|
|
|
|
|
"high-resolution-scrolling-aware": false,
|
|
|
|
|
"ultra-high-resolution-scrolling-aware": false,
|
|
|
|
|
"long-path-aware": false,
|
|
|
|
|
"printer-driver-isolation": false,
|
|
|
|
|
"gdi-scaling": false,
|
|
|
|
|
"segment-heap": false,
|
|
|
|
|
"use-common-controls-v6": false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"RT_MESSAGETABLE": {
|
|
|
|
|
"#1": {
|
|
|
|
|
"0409": "../../winresources/event_messages.bin"
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
"RT_VERSION": {
|
|
|
|
|
"#1": {
|
|
|
|
|
"0409": {
|
|
|
|
|
"fixed": {
|
|
|
|
|
"file_version": "'+(Get-FixQuadVersionNumber($versionMatches.Groups[1].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[2].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[3].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[4].Value))+'",
|
|
|
|
|
"product_version": "'+(Get-FixQuadVersionNumber($versionMatches.Groups[1].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[2].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[3].Value))+'.'+(Get-FixQuadVersionNumber($versionMatches.Groups[4].Value))+'",
|
|
|
|
|
"type": "Unknown"
|
|
|
|
|
},
|
|
|
|
|
"info": {
|
|
|
|
|
"0000": {
|
|
|
|
|
"CompanyName": "'+$PackagerName+'",
|
|
|
|
|
"FileVersion": "'+$DockerVersion+'",
|
|
|
|
|
"LegalCopyright": "Copyright (C) 2015-'+$currentYear+' Docker Inc.",
|
|
|
|
|
"OriginalFileName": "dockerd.exe",
|
|
|
|
|
"ProductName": "'+$Product+'",
|
|
|
|
|
"ProductVersion": "'+$DockerVersion+'",
|
|
|
|
|
"SpecialBuild": "'+$CommitString+'"
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}'
|
2016-11-15 20:01:34 +00:00
|
|
|
|
|
2022-04-12 11:15:54 +00:00
|
|
|
|
# Write the file
|
|
|
|
|
$outputFile="$(Get-Location)\cli\winresources\dockerd\winres.json"
|
|
|
|
|
if (Test-Path $outputFile) { Remove-Item $outputFile }
|
|
|
|
|
[System.IO.File]::WriteAllText($outputFile, $mkwinresContents)
|
|
|
|
|
Get-Content $outputFile | Out-Host
|
|
|
|
|
|
|
|
|
|
# Create winresources package stub if removed while using tmpfs in Dockerfile
|
|
|
|
|
$stubPackage="$(Get-Location)\cli\winresources\dockerd\winresources.go"
|
|
|
|
|
if(![System.IO.File]::Exists($stubPackage)){
|
|
|
|
|
Set-Content -NoNewline -Path $stubPackage -Value 'package winresources'
|
|
|
|
|
}
|
2016-11-15 20:01:34 +00:00
|
|
|
|
|
2022-04-12 11:15:54 +00:00
|
|
|
|
# Generate
|
|
|
|
|
go generate -v "github.com/docker/docker/cmd/dockerd"
|
|
|
|
|
if ($LASTEXITCODE -ne 0) { Throw "Failed to generate version info" }
|
2016-11-15 20:01:34 +00:00
|
|
|
|
}
|
|
|
|
|
Catch [Exception] {
|
|
|
|
|
# Throw the error onto the caller to display errors. We don't expect this script to be called directly
|
|
|
|
|
Throw ".go-autogen.ps1 failed with error $_"
|
|
|
|
|
}
|
|
|
|
|
Finally {
|
|
|
|
|
$env:_ag_dockerVersion=""
|
|
|
|
|
$env:_ag_gitCommit=""
|
|
|
|
|
}
|