Build client on Windows in a temporary directory
Signed-off-by: John Stephens <johnstep@docker.com>
This commit is contained in:
parent
80bb6a46a3
commit
32d47be263
|
@ -397,16 +397,38 @@ Try {
|
||||||
# Perform the actual build
|
# Perform the actual build
|
||||||
if ($Daemon) { Execute-Build "daemon" "daemon" "dockerd" }
|
if ($Daemon) { Execute-Build "daemon" "daemon" "dockerd" }
|
||||||
if ($Client) {
|
if ($Client) {
|
||||||
$dockerCliRepo = (findstr DOCKERCLI_REPO hack\dockerfile\binaries-commits).split("=")[1]
|
# Get the repo and commit of the client to build.
|
||||||
$dockerCliCommit = (findstr DOCKERCLI_COMMIT hack\dockerfile\binaries-commits).split("=")[1]
|
"hack\dockerfile\binaries-commits" | ForEach-Object {
|
||||||
Push-Location ..
|
$dockerCliRepo = ((Get-Content $_ | Select-String "DOCKERCLI_REPO") -split "=")[1]
|
||||||
# TODO: check if cli folder exists already
|
$dockerCliCommit = ((Get-Content $_ | Select-String "DOCKERCLI_COMMIT") -split "=")[1]
|
||||||
git clone $dockerCliRepo
|
}
|
||||||
cd cli
|
|
||||||
git checkout $dockerCliCommit
|
# Build from a temporary directory.
|
||||||
# TODO: update CI script to not assume binary is in docker/docker
|
$tempLocation = "$env:TEMP\$(New-Guid)"
|
||||||
go build -o ..\docker\bundles\docker.exe github.com/docker/cli/cmd/docker
|
New-Item -ItemType Directory $tempLocation | Out-Null
|
||||||
Pop-Location
|
|
||||||
|
# Temporarily override GOPATH, then clone, checkout, and build.
|
||||||
|
$saveGOPATH = $env:GOPATH
|
||||||
|
Try {
|
||||||
|
$env:GOPATH = $tempLocation
|
||||||
|
$dockerCliRoot = "$env:GOPATH\src\$($dockerCliRepo.Split("/", 3)[2])"
|
||||||
|
Write-Host "INFO: Cloning client repository..."
|
||||||
|
Invoke-Expression "git clone -q $dockerCliRepo $dockerCliRoot"
|
||||||
|
if ($LASTEXITCODE -ne 0) { Throw "Failed to clone client repository $dockerCliRepo" }
|
||||||
|
Invoke-Expression "git -C $dockerCliRoot checkout -q $dockerCliCommit"
|
||||||
|
if ($LASTEXITCODE -ne 0) { Throw "Failed to checkout client commit $dockerCliCommit" }
|
||||||
|
Write-Host "INFO: Building client..."
|
||||||
|
Invoke-Expression "go build -o $root\bundles\docker.exe github.com/docker/cli/cmd/docker"
|
||||||
|
if ($LASTEXITCODE -ne 0) { Throw "Failed to compile client" }
|
||||||
|
}
|
||||||
|
Catch [Exception] {
|
||||||
|
Throw $_
|
||||||
|
}
|
||||||
|
Finally {
|
||||||
|
# Always restore GOPATH and remove the temporary directory.
|
||||||
|
$env:GOPATH = $saveGOPATH
|
||||||
|
Remove-Item -Force -Recurse $tempLocation
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue