|
@@ -10,6 +10,22 @@
|
|
|
|
|
|
.PARAMETER DockerVersion
|
|
|
The version such as 17.04.0-dev. This is calculated externally to this script.
|
|
|
+
|
|
|
+.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.
|
|
|
#>
|
|
|
|
|
|
param(
|
|
@@ -17,7 +33,8 @@ param(
|
|
|
[Parameter(Mandatory=$true)][string]$DockerVersion,
|
|
|
[Parameter(Mandatory=$false)][string]$Platform,
|
|
|
[Parameter(Mandatory=$false)][string]$Product,
|
|
|
- [Parameter(Mandatory=$false)][string]$DefaultProductLicense
|
|
|
+ [Parameter(Mandatory=$false)][string]$DefaultProductLicense,
|
|
|
+ [Parameter(Mandatory=$false)][string]$PackagerName
|
|
|
)
|
|
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
@@ -27,63 +44,109 @@ Function Get-BuildDateTime() {
|
|
|
return $(Get-Date).ToUniversalTime()
|
|
|
}
|
|
|
|
|
|
-try {
|
|
|
- $buildDateTime=Get-BuildDateTime
|
|
|
+Function Get-Year() {
|
|
|
+ return $(Get-Date).year
|
|
|
+}
|
|
|
|
|
|
- if (Test-Path ".\autogen") {
|
|
|
- Remove-Item ".\autogen" -Recurse -Force | Out-Null
|
|
|
+Function Get-FixQuadVersionNumber($number) {
|
|
|
+ if ($number -eq 0) {
|
|
|
+ return $number
|
|
|
}
|
|
|
+ return $number.TrimStart("0")
|
|
|
+}
|
|
|
|
|
|
- $fileContents = '
|
|
|
-// +build autogen
|
|
|
-
|
|
|
-// Package dockerversion is auto-generated at build-time
|
|
|
-package dockerversion
|
|
|
-
|
|
|
-// Default build-time variable for library-import.
|
|
|
-// This file is overridden on build with build-time information.
|
|
|
-const (
|
|
|
- GitCommit string = "'+$CommitString+'"
|
|
|
- Version string = "'+$DockerVersion+'"
|
|
|
- BuildTime string = "'+$buildDateTime+'"
|
|
|
- PlatformName string = "'+$Platform+'"
|
|
|
- ProductName string = "'+$Product+'"
|
|
|
- DefaultProductLicense string = "'+$DefaultProductLicense+'"
|
|
|
-)
|
|
|
-
|
|
|
-// AUTOGENERATED FILE; see hack\make\.go-autogen.ps1
|
|
|
-'
|
|
|
-
|
|
|
- # Write the file without BOM
|
|
|
- $outputFile="$(Get-Location)\dockerversion\version_autogen.go"
|
|
|
- if (Test-Path $outputFile) { Remove-Item $outputFile }
|
|
|
- [System.IO.File]::WriteAllText($outputFile, $fileContents, (New-Object System.Text.UTF8Encoding($False)))
|
|
|
+try {
|
|
|
+ $buildDateTime=Get-BuildDateTime
|
|
|
+ $currentYear=Get-Year
|
|
|
|
|
|
- New-Item -ItemType Directory -Path "autogen\winresources\tmp" | Out-Null
|
|
|
- New-Item -ItemType Directory -Path "autogen\winresources\dockerd" | Out-Null
|
|
|
- Copy-Item "hack\make\.resources-windows\resources.go" "autogen\winresources\dockerd"
|
|
|
+ # Update PATH
|
|
|
+ $env:PATH="$env:GOPATH\bin;$env:PATH"
|
|
|
|
|
|
# Generate a version in the form major,minor,patch,build
|
|
|
- $versionQuad=$DockerVersion -replace "[^0-9.]*" -replace "\.", ","
|
|
|
+ $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
|
|
|
|
|
|
- # Compile the messages
|
|
|
- windmc hack\make\.resources-windows\event_messages.mc -h autogen\winresources\tmp -r autogen\winresources\tmp
|
|
|
- if ($LASTEXITCODE -ne 0) { Throw "Failed to compile event message resources" }
|
|
|
+ $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+'"
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}'
|
|
|
|
|
|
- # If you really want to understand this madness below, search the Internet for powershell variables after verbatim arguments... Needed to get double-quotes passed through to the compiler options.
|
|
|
- # Generate the .syso files containing all the resources and manifest needed to compile the final docker binaries. Both 32 and 64-bit clients.
|
|
|
- $env:_ag_dockerVersion=$DockerVersion
|
|
|
- $env:_ag_gitCommit=$CommitString
|
|
|
+ # 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'
|
|
|
+ }
|
|
|
|
|
|
- windres -i hack/make/.resources-windows/dockerd.rc -o autogen/winresources/dockerd/rsrc_amd64.syso -F pe-x86-64 --use-temp-file -I autogen/winresources/tmp -D DOCKER_VERSION_QUAD=$versionQuad --% -D DOCKER_VERSION=\"%_ag_dockerVersion%\" -D DOCKER_COMMIT=\"%_ag_gitCommit%\"
|
|
|
- if ($LASTEXITCODE -ne 0) { Throw "Failed to compile daemon resources" }
|
|
|
+ # Generate
|
|
|
+ go generate -v "github.com/docker/docker/cmd/dockerd"
|
|
|
+ if ($LASTEXITCODE -ne 0) { Throw "Failed to generate version info" }
|
|
|
}
|
|
|
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 {
|
|
|
- Remove-Item .\autogen\winresources\tmp -Recurse -Force -ErrorAction SilentlyContinue | Out-Null
|
|
|
$env:_ag_dockerVersion=""
|
|
|
$env:_ag_gitCommit=""
|
|
|
}
|