Cirrus: Ensure GOPATH is properly set during image-builds

Signed-off-by: Chris Evich <cevich@redhat.com>
This commit is contained in:
Chris Evich 2020-07-02 11:55:38 -04:00
parent 80add2902c
commit 18a1514139
No known key found for this signature in database
GPG Key ID: 03EDC70FD578067F
4 changed files with 19 additions and 3 deletions

View File

@ -5,7 +5,8 @@ PACKER_DIST_FILENAME := packer_${PACKER_VER}_linux_${GOARCH}.zip
# Only needed for libpod_base_images target # Only needed for libpod_base_images target
TIMESTAMP := $(shell date +%s) TIMESTAMP := $(shell date +%s)
GOSRC ?= $(shell realpath "./../../../") GOPATH ?= /var/tmp/go
GOSRC ?= $(GOPATH)/src/github.com/containers/libpod
PACKER_BASE ?= contrib/cirrus/packer PACKER_BASE ?= contrib/cirrus/packer
SCRIPT_BASE ?= contrib/cirrus SCRIPT_BASE ?= contrib/cirrus
POST_MERGE_BUCKET_SUFFIX ?= POST_MERGE_BUCKET_SUFFIX ?=
@ -54,6 +55,7 @@ libpod_images: guard-PACKER_BUILDS libpod_images.json packer
./packer build \ ./packer build \
-force \ -force \
$(shell test -z "${PACKER_BUILDS}" || echo "-only=${PACKER_BUILDS}") \ $(shell test -z "${PACKER_BUILDS}" || echo "-only=${PACKER_BUILDS}") \
-var GOPATH=$(GOPATH) \
-var GOSRC=$(GOSRC) \ -var GOSRC=$(GOSRC) \
-var PACKER_BASE=$(PACKER_BASE) \ -var PACKER_BASE=$(PACKER_BASE) \
-var SCRIPT_BASE=$(SCRIPT_BASE) \ -var SCRIPT_BASE=$(SCRIPT_BASE) \

View File

@ -168,5 +168,9 @@ fi
echo "Installing runtime tooling" echo "Installing runtime tooling"
# Save some runtime by having these already available # Save some runtime by having these already available
cd $GOSRC cd $GOSRC
# Required since initially go was not installed
source $GOSRC/$SCRIPT_BASE/lib.sh
echo "Go environment has been setup:"
go env
$SUDO make install.tools $SUDO make install.tools
$SUDO $GOSRC/hack/install_catatonit.sh $SUDO $GOSRC/hack/install_catatonit.sh

View File

@ -3,6 +3,7 @@
# All of these are required # All of these are required
variables: variables:
BUILT_IMAGE_SUFFIX: '{{env `BUILT_IMAGE_SUFFIX`}}' BUILT_IMAGE_SUFFIX: '{{env `BUILT_IMAGE_SUFFIX`}}'
GOPATH: '{{env `GOPATH`}}'
GOSRC: '{{env `GOSRC`}}' GOSRC: '{{env `GOSRC`}}'
PACKER_BASE: '{{env `PACKER_BASE`}}' PACKER_BASE: '{{env `PACKER_BASE`}}'
SCRIPT_BASE: '{{env `SCRIPT_BASE`}}' SCRIPT_BASE: '{{env `SCRIPT_BASE`}}'
@ -62,15 +63,20 @@ builders:
# The brains of the operation, making actual modifications to the base-image. # The brains of the operation, making actual modifications to the base-image.
provisioners: provisioners:
- type: 'shell'
inline:
- mkdir -p '${{user `GOSRC`}}'
- type: 'file' - type: 'file'
source: '{{user `GOSRC`}}' source: '{{user `GOSRC`}}'
destination: '/tmp/libpod' destination: '{{user `GOSRC`}}'
- type: 'shell' - type: 'shell'
script: '{{user `GOSRC`}}/{{user `PACKER_BASE`}}/{{split build_name "-" 0}}_setup.sh' script: '{{user `GOSRC`}}/{{user `PACKER_BASE`}}/{{split build_name "-" 0}}_setup.sh'
environment_vars: environment_vars:
- 'PACKER_BUILDER_NAME={{build_name}}' - 'PACKER_BUILDER_NAME={{build_name}}'
- 'GOSRC=/tmp/libpod' - 'GOPATH={{user `GOPATH`}}'
- 'GOSRC={{user `GOSRC`}}'
- 'PACKER_BASE={{user `PACKER_BASE`}}' - 'PACKER_BASE={{user `PACKER_BASE`}}'
- 'SCRIPT_BASE={{user `SCRIPT_BASE`}}' - 'SCRIPT_BASE={{user `SCRIPT_BASE`}}'

View File

@ -154,6 +154,10 @@ fi
echo "Installing runtime tooling" echo "Installing runtime tooling"
cd $GOSRC cd $GOSRC
# Required since initially go was not installed
source $GOSRC/$SCRIPT_BASE/lib.sh
echo "Go environment has been setup:"
go env
$SUDO hack/install_catatonit.sh $SUDO hack/install_catatonit.sh
$SUDO make install.libseccomp.sudo $SUDO make install.libseccomp.sudo
$SUDO make install.tools $SUDO make install.tools