Skip to content

Commit

Permalink
support darwin golang; allow any golang version [fixes #80, fixes #36]
Browse files Browse the repository at this point in the history
  • Loading branch information
drnic authored and xiaozhu36 committed Jul 9, 2019
1 parent 3c9c150 commit a0ca680
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 41 deletions.
42 changes: 14 additions & 28 deletions packages/bosh-alicloud-cpi/packaging
Original file line number Diff line number Diff line change
@@ -1,39 +1,25 @@
#!/bin/bash

set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables

# Set package dependencies directory
# Available variables
# $BOSH_COMPILE_TARGET - where this package & spec'd source files are available
# $BOSH_INSTALL_TARGET - where you copy/install files to be included in package

export HOME=${HOME:-/tmp/home}
PACKAGES_DIR=${BOSH_PACKAGES_DIR:-/var/vcap/packages}

# Set Golang dependency
PLATFORM=`uname | tr '[:upper:]' '[:lower:]'`

if [ $PLATFORM = "linux" ]; then
export GOROOT=$(cd "${PACKAGES_DIR}/golang" && pwd -P)
export PATH=${GOROOT}/bin:${PATH}
fi
export GOROOT=$(cd "${PACKAGES_DIR}/golang" && pwd -P)
ls -alR $GOROOT/bin
export PATH=${GOROOT}/bin:${PATH}

# Build BOSH Alicloud CPI package
echo " ========================================== "
echo " Source Patch: " $BOSH_COMPILE_TARGET
echo " Installed in: " $BOSH_INSTALL_TARGET
echo " ========================================== "
mkdir -p ${BOSH_INSTALL_TARGET}/bin

# Build BOSH alicloud CPI package
mkdir -p ${BOSH_COMPILE_TARGET}/go/src
mv ${BOSH_COMPILE_TARGET}/Makefile ${BOSH_COMPILE_TARGET}/go/
mv ${BOSH_COMPILE_TARGET}/bosh-alicloud-cpi ${BOSH_COMPILE_TARGET}/go/src/
# mv ${BOSH_COMPILE_TARGET}/github.com ${BOSH_COMPILE_TARGET}/go/src/

cd ${BOSH_COMPILE_TARGET}/go/src/bosh-alicloud-cpi
export GOPATH=${BOSH_COMPILE_TARGET}/go

# Copy BOSH Alicloud CPI package
mkdir -p ${BOSH_INSTALL_TARGET}/bin

cd ${BOSH_COMPILE_TARGET}/go
make

## TODO replace with a single command
## EXECUTABLE=bin/alicloud_cpi
## go build -v -a -o ${EXECUTABLE} $(MAINFILE)

cp ${BOSH_COMPILE_TARGET}/go/bin/alicloud_cpi ${BOSH_INSTALL_TARGET}/bin/

go build -o ${BOSH_INSTALL_TARGET}/bin/alicloud_cpi bosh-alicloud-cpi/main
3 changes: 1 addition & 2 deletions packages/bosh-alicloud-cpi/spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,4 @@ name: bosh-alicloud-cpi
dependencies:
- golang
files:
- bosh-alicloud-cpi/**/*
- Makefile
- bosh-alicloud-cpi/**/*
17 changes: 7 additions & 10 deletions packages/golang/packaging
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#!/bin/bash

set -e # exit immediately if a simple command exits with a non-zero status
set -u # report the usage of uninitialized variables

# Grab the latest versions that are in the directory
PLATFORM=`uname | tr '[:upper:]' '[:lower:]'`

export GOLANG_VERSION=1.11.5

if [ $PLATFORM = "linux" ]; then
# Set package dependencies directory
export dir=`ls ${BOSH_COMPILE_TARGET}`
tar xzvf ${BOSH_COMPILE_TARGET}/go${GOLANG_VERSION}.linux-amd64.tar.gz
# Extract Go Programming Language package
tar xzvf ${BOSH_COMPILE_TARGET}/golang/go*.${PLATFORM}-amd64.tar.gz

# Copy Go Programming Language package
mkdir -p ${BOSH_INSTALL_TARGET}/bin
cp -a ${BOSH_COMPILE_TARGET}/go/* ${BOSH_INSTALL_TARGET}
fi
# Copy Go Programming Language package
mkdir -p ${BOSH_INSTALL_TARGET}/bin
cp -R ${BOSH_COMPILE_TARGET}/go/* ${BOSH_INSTALL_TARGET}
3 changes: 2 additions & 1 deletion packages/golang/spec
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
name: golang

files:
- go1.11.5.linux-amd64.tar.gz # from https://storage.googleapis.com/golang/go1.11.5.linux-amd64.tar.gz
- golang/go1.*.darwin-amd64.tar.gz # from https://golang.org/dl/
- golang/go1.*.linux-amd64.tar.gz # from https://golang.org/dl/

0 comments on commit a0ca680

Please sign in to comment.