diff --git a/README.md b/README.md new file mode 100644 index 0000000..8656b80 --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +### Go Windows Buildpack User Documentation + +### Building the Buildpack +To use this buildpack, run the following command from the buildpack's directory: + +1. Build the buildpack +```bash +./scripts/build.ps1 +``` + +1. Use [cfwindowsstager](https://github.com/dgodd/cfwindowsstager/releases) to test the buildpack +```bash +cfwindowsstager.exe --app .\fixtures\simple --buildpack .\go_buildpack-windows2016-v0.0.0.zip +``` + +1. Use in Cloud Foundry +Upload the buildpack to your Cloud Foundry and optionally specify it by name + +```bash +cf create-buildpack [BUILDPACK_NAME] [BUILDPACK_ZIP_FILE_PATH] 1 +cf push my_app [-b BUILDPACK_NAME] +``` + +### Reporting Issues +Open an issue on this project + +## Disclaimer +This buildpack is intended purely for educational use and is not intended for production use. diff --git a/VERSION b/VERSION index 77d6f4c..8acdd82 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.0.0 +0.0.1 diff --git a/bin/compile b/bin/compile index 0ecbe07..8d3e476 100755 --- a/bin/compile +++ b/bin/compile @@ -1,19 +1,3 @@ #!/usr/bin/env bash -# This script is a deprecated but is provided for compatibility with Heroku and older versions of Cloud Foundry -# It is an alternative to bin/supply and bin/finalize - -set -euo pipefail - -BUILD_DIR=$1 -CACHE_DIR=$2 -BUILDPACK_PATH=$(dirname $(readlink -f ${BASH_SOURCE%/*})) -DEPS_DIR="$BUILD_DIR/.cloudfoundry" - -mkdir -p $CACHE_DIR -mkdir -p "$DEPS_DIR/0" -mkdir -p "$BUILD_DIR/.profile.d" - -echo "export DEPS_DIR=\$HOME/.cloudfoundry" > "$BUILD_DIR/.profile.d/0000_set-deps-dir.sh" - -$BUILDPACK_PATH/bin/supply "$BUILD_DIR" "$CACHE_DIR" "$DEPS_DIR" 0 -$BUILDPACK_PATH/bin/finalize "$BUILD_DIR" "$CACHE_DIR" "$DEPS_DIR" 0 +echo "bin/compile is deprecated, but is provided so that CF will accept the zip file" +exit 1 diff --git a/bin/detect b/bin/detect deleted file mode 100755 index 6e2b08d..0000000 --- a/bin/detect +++ /dev/null @@ -1,12 +0,0 @@ -#!/usr/bin/env bash -# bin/detect -set -e - -build=$(cd "$1/" && pwd) - -if test -f "$build/go.mod"; then - echo go - exit 0 -fi - -exit 1 diff --git a/bin/detect.bat b/bin/detect.bat old mode 100755 new mode 100644 diff --git a/bin/finalize b/bin/finalize deleted file mode 100755 index 5148644..0000000 --- a/bin/finalize +++ /dev/null @@ -1,19 +0,0 @@ -#!/usr/bin/env bash -# This script prepares and configures the app for launch. - -set -euo pipefail - -BUILD_DIR=$1 -CACHE_DIR=$2 -DEPS_DIR=$3 -DEPS_IDX=$4 -PROFILE_DIR=${5:-} - -export BUILDPACK_DIR=`dirname $(readlink -f ${BASH_SOURCE%/*})` -source "$BUILDPACK_DIR/scripts/install_go.sh" -output_dir=$(mktemp -d -t finalizeXXX) - -echo "-----> Running go build finalize" -GOROOT=$GoInstallDir/go GOPATH=$BUILDPACK_DIR $GoInstallDir/go/bin/go build -o $output_dir/finalize ./finalize/cli - -$output_dir/finalize "$BUILD_DIR" "$CACHE_DIR" "$DEPS_DIR" "$DEPS_IDX" "$PROFILE_DIR" diff --git a/bin/finalize.bat b/bin/finalize.bat new file mode 100644 index 0000000..b88f3ba --- /dev/null +++ b/bin/finalize.bat @@ -0,0 +1,3 @@ +@ECHO OFF +SET ScriptDir=%~dp0 +PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%ScriptDir%finalize.ps1' %1 %2 %3 %4"; diff --git a/bin/finalize.ps1 b/bin/finalize.ps1 new file mode 100644 index 0000000..1a46123 --- /dev/null +++ b/bin/finalize.ps1 @@ -0,0 +1,19 @@ +[CmdletBinding()] +Param( +[Parameter(Mandatory=$True,Position=1)] [string]$BuildDir, +[Parameter(Mandatory=$True,Position=2)] [string]$CacheDir, +[Parameter(Mandatory=$True,Position=3)] [string]$DepsDir, +[Parameter(Mandatory=$True,Position=4)] [string]$DepsIdx +) + +$ErrorActionPreference = "Stop" +$env:PATH += ";$DepsDir/$DepsIdx/bin" + +Write-Output "-----> Build app" +Set-Location $BuildDir +go build -o myapp.exe . +if ($lastexitcode -ne 0) { + Write-Output "ERROR building app with go" + Write-Output "EXITCODE: $lastexitcode" + Exit 1 +} diff --git a/bin/release b/bin/release deleted file mode 100755 index d957143..0000000 --- a/bin/release +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash -set -euo pipefail - -BUILD_DIR=$1 -cat /tmp/go-buildpack-release-step.yml diff --git a/bin/release.bat b/bin/release.bat index afeb6dc..9ca1242 100644 --- a/bin/release.bat +++ b/bin/release.bat @@ -1,2 +1,4 @@ @echo off -type c:\tmp\go-buildpack-release-step.yml +echo --- +echo default_process_types: +echo web: .\myapp.exe diff --git a/bin/supply b/bin/supply deleted file mode 100755 index 4ae7203..0000000 --- a/bin/supply +++ /dev/null @@ -1,17 +0,0 @@ -#!/bin/bash -# This script provides dependencies for an app - - -set -euo pipefail - -BUILD_DIR=$1 -CACHE_DIR=$2 -DEPS_DIR=$3 -DEPS_IDX=$4 - -export BUILDPACK_DIR=`dirname $(readlink -f ${BASH_SOURCE%/*})` -source "$BUILDPACK_DIR/scripts/install_go.sh" -output_dir=$(mktemp -d -t supplyXXX) -echo "-----> Running go build supply" -GOROOT=$GoInstallDir/go $GoInstallDir/go/bin/go build -o $output_dir/supply ./supply/cli -$output_dir/supply "$BUILD_DIR" "$CACHE_DIR" "$DEPS_DIR" "$DEPS_IDX" diff --git a/bin/supply.bat b/bin/supply.bat new file mode 100644 index 0000000..32af74c --- /dev/null +++ b/bin/supply.bat @@ -0,0 +1,3 @@ +@ECHO OFF +SET ScriptDir=%~dp0 +PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '%ScriptDir%supply.ps1' %1 %2 %3 %4"; diff --git a/bin/supply.ps1 b/bin/supply.ps1 new file mode 100644 index 0000000..ea02d8f --- /dev/null +++ b/bin/supply.ps1 @@ -0,0 +1,33 @@ +[CmdletBinding()] +Param( +[Parameter(Mandatory=$True,Position=1)] [string]$BuildDir, +[Parameter(Mandatory=$True,Position=2)] [string]$CacheDir, +[Parameter(Mandatory=$True,Position=3)] [string]$DepsDir, +[Parameter(Mandatory=$True,Position=4)] [string]$DepsIdx +) + +$ErrorActionPreference = "Stop" + +$Version = (Get-Content "$PSScriptRoot/../VERSION" -Raw).Replace("`n","").Replace("`r","") +Write-Output "-----> Go Buildpack (version $Version)" +# Write-Output " BuildDir: $BuildDir" +# Write-Output " CacheDir: $CacheDir" +# Write-Output " DepsDir: $DepsDir" +# Write-Output " DepsIdx: $DepsIdx" +# Write-Output "" + + +Write-Output "-----> Download go" +$ProgressPreference = 'SilentlyContinue' +(New-Object System.Net.WebClient).DownloadFile('https://dl.google.com/go/go1.11.4.windows-amd64.zip', "$DepsDir/$DepsIdx/go.zip") +$ExpectedSHA = 'eeb20e21702f2b9469d9381df5de85e2f731b64a1f54effe196d0f7d0227fe14' +$ActualSHA = (Get-FileHash "$DepsDir/$DepsIdx/go.zip" -Algorithm SHA256).Hash +If ($ExpectedSHA -ne $ActualSHA) { + Write-Output "go.zip checksum did not match. expected '$ExpectedSHA', found '$ActualSHA'" + Exit 1 +} + +Write-Output "-----> Extract go" +Expand-Archive -Path "$DepsDir/$DepsIdx/go.zip" -DestinationPath "$DepsDir/$DepsIdx" -Force +Move-Item -Path "$DepsDir/$DepsIdx/go/*" -Destination "$DepsDir/$DepsIdx" +Remove-Item -Path "$DepsDir/$DepsIdx/go" diff --git a/finalize.go b/finalize.go deleted file mode 100644 index b1cd0eb..0000000 --- a/finalize.go +++ /dev/null @@ -1,45 +0,0 @@ -package gowindowsbuildpack - -import ( - "os" - "os/exec" - - "github.com/cloudfoundry/libbuildpack" -) - -type Finalizer struct { - Manifest Manifest - Stager Stager - Command Command - Log *libbuildpack.Logger -} - -func (f *Finalizer) Run() error { - f.Log.BeginStep("Go Build") - cmd := exec.Command("go", "build", "-o", "myapp", ".") - cmd.Stdout = os.Stdout - cmd.Stderr = os.Stderr - cmd.Dir = f.Stager.BuildDir() - cmd.Env = append(os.Environ(), "GOROOT="+f.Stager.DepDir()) - if err := f.Command.Run(cmd); err != nil { - return err - } - - f.Log.BeginStep("Configuring go") - return f.WriteReleaseYAML() -} - -func (f *Finalizer) WriteReleaseYAML() error { - data := map[string]map[string]string{ - "default_process_types": map[string]string{ - "web": "./myapp", - }, - } - releasePath := "/tmp/go-buildpack-release-step.yml" - if err := libbuildpack.NewYAML().Write(releasePath, data); err != nil { - f.Log.Error("Error writing release YAML: %v", err) - return err - } - - return nil -} diff --git a/finalize/main.go b/finalize/main.go deleted file mode 100644 index a682a8e..0000000 --- a/finalize/main.go +++ /dev/null @@ -1,60 +0,0 @@ -package main - -import ( - "os" - "time" - - "github.com/cloudfoundry/libbuildpack" - bp "github.com/dgodd/go-windows-buildpack" -) - -func main() { - logger := libbuildpack.NewLogger(os.Stdout) - - buildpackDir, err := libbuildpack.GetBuildpackDir() - if err != nil { - logger.Error("Unable to determine buildpack directory: %s", err.Error()) - os.Exit(9) - } - - manifest, err := libbuildpack.NewManifest(buildpackDir, logger, time.Now()) - if err != nil { - logger.Error("Unable to load buildpack manifest: %s", err.Error()) - os.Exit(10) - } - - stager := libbuildpack.NewStager(os.Args[1:], logger, manifest) - - if err = manifest.ApplyOverride(stager.DepsDir()); err != nil { - logger.Error("Unable to apply override.yml files: %s", err) - os.Exit(17) - } - - if err := stager.SetStagingEnvironment(); err != nil { - logger.Error("Unable to setup environment variables: %s", err.Error()) - os.Exit(11) - } - - f := bp.Finalizer{ - Manifest: manifest, - Stager: stager, - Command: &libbuildpack.Command{}, - Log: logger, - } - - if err := f.Run(); err != nil { - os.Exit(12) - } - - if err := libbuildpack.RunAfterCompile(stager); err != nil { - logger.Error("After Compile: %s", err.Error()) - os.Exit(13) - } - - if err := stager.SetLaunchEnvironment(); err != nil { - logger.Error("Unable to setup launch environment: %s", err.Error()) - os.Exit(14) - } - - stager.StagingComplete() -} diff --git a/go.mod b/go.mod deleted file mode 100644 index b4fb314..0000000 --- a/go.mod +++ /dev/null @@ -1,3 +0,0 @@ -module github.com/dgodd/go-windows-buildpack - -require github.com/cloudfoundry/libbuildpack v0.0.0-20190115190946-c10a4cd29881 diff --git a/go.sum b/go.sum deleted file mode 100644 index 7c62f09..0000000 --- a/go.sum +++ /dev/null @@ -1,53 +0,0 @@ -github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/Masterminds/semver v1.4.2 h1:WBLTQ37jOCzSLtXNdoo8bNM8876KhNqOKvrlGITgsTc= -github.com/Masterminds/semver v1.4.2/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y= -github.com/blang/semver v3.5.1+incompatible h1:cQNTCjp13qL8KC3Nbxr/y2Bqb63oX6wdnnjpJbkM4JQ= -github.com/blang/semver v3.5.1+incompatible/go.mod h1:kRBLl5iJ+tD4TcOOxsy/0fnwebNt5EWlYSAyrTnjyyk= -github.com/cloudfoundry/libbuildpack v0.0.0-20190115190946-c10a4cd29881 h1:640+S316H9WsAQKPvI99n+0k6n/Wp1cFIHRql6fRkqM= -github.com/cloudfoundry/libbuildpack v0.0.0-20190115190946-c10a4cd29881/go.mod h1:rdSHSV2PLp7YHbdQgYbYMSmE6NJ1ZOAYnhMBQdkUVx0= -github.com/elazarl/goproxy v0.0.0-20181111060418-2ce16c963a8a/go.mod h1:/Zj4wYkgs4iZTTu3o/KG3Itv/qCCa8VVMlb3i9OVuzc= -github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I= -github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo= -github.com/golang/mock v1.2.0 h1:28o5sBqPkBsMGnC6b4MvE2TzSr5/AT4c/1fLqVGIwlk= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/protobuf v1.2.0 h1:P3YflyNX/ehuJFLhxviNdFxQPkGK5cDcApsge1SqnvM= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/google/subcommands v0.0.0-20181012225330-46f0354f6315/go.mod h1:ZjhPrFU+Olkh9WazFPsl27BQ4UPiG37m3yTrtFlrHVk= -github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= -github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= -github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= -github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/ginkgo v1.7.0 h1:WSHQ+IS43OoUrWtD1/bbclrwK8TTH5hzp+umCiuxHgs= -github.com/onsi/ginkgo v1.7.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= -github.com/onsi/gomega v1.4.3 h1:RE1xgDvH7imwFD45h+u2SgIfERHlS2yNG4DObb5BSKU= -github.com/onsi/gomega v1.4.3/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= -github.com/tidwall/gjson v1.1.3/go.mod h1:c/nTNbUr0E0OrXEhq1pwa8iEgc2DOt4ZZqAt1HtCkPA= -github.com/tidwall/match v1.0.1/go.mod h1:LujAq0jyVjBy028G1WhWfIzbpQfMO8bBZ6Tyb0+pL9E= -golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3 h1:eH6Eip3UpmR+yM/qI9Ijluzb1bNv/cAU/n+6l8tRSis= -golang.org/x/net v0.0.0-20181220203305-927f97764cc3/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4 h1:YUO/7uOKsKeq9UokNS62b8FYywz3ker1l1vDZRCRefw= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sys v0.0.0-20180909124046-d0be0721c37e/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6 h1:IcgEB62HYgAhX0Nd/QrVgZlxlcyxbGQHElLUhW2X4Fo= -golang.org/x/sys v0.0.0-20181221143128-b4a75ba826a6/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/text v0.3.0 h1:g61tztE5qeGQ89tm6NTjjM9VPIm088od1l6aSorWRWg= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127 h1:qIbj1fsPNlZgppZ+VLlY7N33q108Sa+fhmuc+sWQYwY= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/fsnotify.v1 v1.4.7 h1:xOHLXZwVvI9hhs+cLKq5+I5onOuwQLhQwiu63xxlHs4= -gopkg.in/fsnotify.v1 v1.4.7/go.mod h1:Tz8NjZHkW78fSQdbUxIjBTcgA1z1m8ZHf0WmKUhAMys= -gopkg.in/jarcoal/httpmock.v1 v1.0.0-20181117152235-275e9df93516 h1:H6trpavCIuipdInWrab8l34Mf+GGVfphniHostMdMaQ= -gopkg.in/jarcoal/httpmock.v1 v1.0.0-20181117152235-275e9df93516/go.mod h1:d3R+NllX3X5e0zlG1Rful3uLvsGC/Q3OHut5464DEQw= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7 h1:uRGJdciOHaEIrze2W8Q3AKkepLTh2hOroT7a+7czfdQ= -gopkg.in/tomb.v1 v1.0.0-20141024135613-dd632973f1e7/go.mod h1:dt/ZhP58zS4L8KSrWDmTeBkI65Dw0HsyUHuEVlX15mw= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/interfaces.go b/interfaces.go deleted file mode 100644 index 6152341..0000000 --- a/interfaces.go +++ /dev/null @@ -1,28 +0,0 @@ -package gowindowsbuildpack - -import ( - "io" - "os/exec" - - "github.com/cloudfoundry/libbuildpack" -) - -type Stager interface { - BuildDir() string - CacheDir() string - DepDir() string -} - -type Manifest interface { - DefaultVersion(string) (libbuildpack.Dependency, error) -} - -type Installer interface { - InstallOnlyVersion(string, string) error -} - -type Command interface { - Execute(string, io.Writer, io.Writer, string, ...string) error - Run(*exec.Cmd) error - // Output(dir string, program string, args ...string) (string, error) -} diff --git a/manifest.yml b/manifest.yml deleted file mode 100644 index 4305e1c..0000000 --- a/manifest.yml +++ /dev/null @@ -1,39 +0,0 @@ ---- -language: go -default_versions: -dependency_deprecation_dates: - -dependencies: -- name: go - version: 1.11.4 - uri: https://dl.google.com/go/go1.11.4.linux-amd64.tar.gz - sha256: fb26c30e6a04ad937bbc657a1b5bba92f80096af1e8ee6da6430c045a8db3a5b - cf_stacks: - - cflinuxfs2 - - cflinuxfs3 -include_files: - - VERSION - - bin/detect - - bin/compile - - bin/supply - - bin/finalize - - bin/release - - manifest.yml -pre_package: scripts/build.sh - -# dependencies: -# - name: go -# version: 1.11.4 -# uri: https://dl.google.com/go/go1.11.4.windows-amd64.zip -# sha256: eeb20e21702f2b9469d9381df5de85e2f731b64a1f54effe196d0f7d0227fe14 -# cf_stacks: -# - windows2016 -# include_files: -# - VERSION -# - bin/detect.bat -# - bin/compile -# - bin/supply.exe -# - bin/finalize.exe -# - bin/release.bat -# - manifest.yml -# pre_package: .\scripts\build.bat diff --git a/scripts/build.bat b/scripts/build.bat deleted file mode 100755 index 3686ec3..0000000 --- a/scripts/build.bat +++ /dev/null @@ -1,4 +0,0 @@ -@echo off -go build -ldflags="-s -w" -o .\bin\supply.exe .\supply -go build -ldflags="-s -w" -o .\bin\finalize.exe .\finalize -del .\bin\supply .\bin\finalize diff --git a/scripts/build.ps1 b/scripts/build.ps1 new file mode 100644 index 0000000..ffe8d7b --- /dev/null +++ b/scripts/build.ps1 @@ -0,0 +1,7 @@ +$ErrorActionPreference = "Stop" + +$Version = (Get-Content "$PSScriptRoot/../VERSION" -Raw).Replace("`n","").Replace("`r","") + +cd "$PSScriptRoot/.." +Compress-Archive -LiteralPath bin, VERSION -CompressionLevel Optimal -DestinationPath "$PSScriptRoot/../go_buildpack-windows2016-v$Version.zip" -Force + diff --git a/scripts/build.sh b/scripts/build.sh deleted file mode 100755 index 88d2378..0000000 --- a/scripts/build.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env bash -set -exuo pipefail - -cd "$( dirname "${BASH_SOURCE[0]}" )/.." - -GOOS=linux go build -ldflags="-s -w" -o bin/supply ./supply -GOOS=linux go build -ldflags="-s -w" -o bin/finalize ./finalize diff --git a/scripts/unit.sh b/scripts/unit.sh deleted file mode 100755 index 7b8704e..0000000 --- a/scripts/unit.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/usr/bin/env bash -# Runs the unit tests for this buildpack - -set -euo pipefail - -cd "$( dirname "${BASH_SOURCE[0]}" )/.." - -go test . ./supply ./finalize diff --git a/supply.go b/supply.go deleted file mode 100644 index dd6bde8..0000000 --- a/supply.go +++ /dev/null @@ -1,37 +0,0 @@ -package gowindowsbuildpack - -import ( - "io/ioutil" - "os" - "path/filepath" - - "github.com/cloudfoundry/libbuildpack" -) - -type Supplier struct { - Manifest Manifest - Installer Installer - Stager Stager - Command Command - Log *libbuildpack.Logger -} - -func (s *Supplier) Run() error { - s.Log.BeginStep("Supplying go") - - if err := s.Installer.InstallOnlyVersion("go", s.Stager.DepDir()); err != nil { - return err - } - files, err := ioutil.ReadDir(filepath.Join(s.Stager.DepDir(), "go")) - if err != nil { - return err - } - for _, file := range files { - os.Remove(filepath.Join(s.Stager.DepDir(), file.Name())) - if err := os.Rename(filepath.Join(s.Stager.DepDir(), "go", file.Name()), filepath.Join(s.Stager.DepDir(), file.Name())); err != nil { - return err - } - } - - return os.Remove(filepath.Join(s.Stager.DepDir(), "go")) -} diff --git a/supply/main.go b/supply/main.go deleted file mode 100644 index 7735c80..0000000 --- a/supply/main.go +++ /dev/null @@ -1,84 +0,0 @@ -package main - -import ( - "os" - "path/filepath" - "time" - - "github.com/cloudfoundry/libbuildpack" - bp "github.com/dgodd/go-windows-buildpack" -) - -func main() { - logger := libbuildpack.NewLogger(os.Stdout) - - buildpackDir, err := libbuildpack.GetBuildpackDir() - if err != nil { - logger.Error("Unable to determine buildpack directory: %s", err.Error()) - os.Exit(9) - } - - manifest, err := libbuildpack.NewManifest(buildpackDir, logger, time.Now()) - if err != nil { - logger.Error("Unable to load buildpack manifest: %s", err.Error()) - os.Exit(10) - } - installer := libbuildpack.NewInstaller(manifest) - - stager := libbuildpack.NewStager(os.Args[1:], logger, manifest) - if err := stager.CheckBuildpackValid(); err != nil { - os.Exit(11) - } - - os.MkdirAll(filepath.Join(stager.DepDir(), "bin"), 0755) - os.MkdirAll(filepath.Join(stager.DepDir(), "lib"), 0755) - - if err = installer.SetAppCacheDir(stager.CacheDir()); err != nil { - logger.Error("Unable to setup app cache dir: %s", err) - os.Exit(18) - } - if err = manifest.ApplyOverride(stager.DepsDir()); err != nil { - logger.Error("Unable to apply override.yml files: %s", err) - os.Exit(17) - } - - err = libbuildpack.RunBeforeCompile(stager) - if err != nil { - logger.Error("Before Compile: %s", err.Error()) - os.Exit(12) - } - - if err := os.MkdirAll(filepath.Join(stager.DepDir(), "bin"), 0755); err != nil { - logger.Error("Unable to create bin directory: %s", err.Error()) - os.Exit(13) - } - - err = stager.SetStagingEnvironment() - if err != nil { - logger.Error("Unable to setup environment variables: %s", err.Error()) - os.Exit(14) - } - - s := bp.Supplier{ - Manifest: manifest, - Installer: installer, - Stager: stager, - Command: &libbuildpack.Command{}, - Log: logger, - } - - err = s.Run() - if err != nil { - logger.Error("Error: %s", err) - os.Exit(15) - } - - if err := stager.WriteConfigYml(nil); err != nil { - logger.Error("Error writing config.yml: %s", err.Error()) - os.Exit(16) - } - if err = installer.CleanupAppCache(); err != nil { - logger.Error("Unable clean up app cache: %s", err) - os.Exit(19) - } -}