Clean up build scripts

Switch binaries to armhf suffix to be more clean on the on
architecture
This commit is contained in:
Darren Shepherd 2019-01-24 10:51:14 -07:00
parent 40f0deece3
commit 6fa7f5b3ae
16 changed files with 90 additions and 22 deletions

View File

@ -26,6 +26,6 @@ ENV CROSS true
ENV STATIC_BUILD true
WORKDIR ${DAPPER_SOURCE}
ENTRYPOINT ["./scripts/entry"]
ENTRYPOINT ["./scripts/entry.sh"]
CMD ["ci"]

View File

@ -1,4 +1,4 @@
TARGETS := $(shell ls scripts)
TARGETS := $(shell ls scripts | grep -v \\.sh)
.dapper:
@echo Downloading dapper
@ -18,6 +18,9 @@ trash-keep: .dapper
deps: trash
release:
./scripts/release.sh
.DEFAULT_GOAL := ci
.PHONY: $(TARGETS)

View File

@ -1,5 +1,6 @@
//go:generate go run types/codegen/cleanup/main.go
//go:generate go run types/codegen/main.go
//go:generate go fmt pkg/deploy/zz_generated_bindata.go
package main

View File

@ -182,6 +182,7 @@ type bintree struct {
Func func() (*asset, error)
Children map[string]*bintree
}
var _bintree = &bintree{nil, map[string]*bintree{
"coredns.yaml": &bintree{corednsYaml, map[string]*bintree{}},
}}
@ -232,4 +233,3 @@ func _filePath(dir, name string) string {
cannonicalName := strings.Replace(name, "\\", "/", -1)
return filepath.Join(append([]string{dir}, strings.Split(cannonicalName, "/")...)...)
}

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -e -x
source $(dirname $0)/version
source $(dirname $0)/version.sh
cd $(dirname $0)/..

View File

@ -3,6 +3,8 @@ set -e
cd $(dirname $0)
./validate
if [ -z "SKIP_VALIDATE" ]; then
./validate
fi
./build
./package

View File

@ -5,4 +5,4 @@ mkdir -p $(dirname $0)/../bin
cd $(dirname $0)/../bin
echo Running
go run -tags "apparmor" ../cmd/server/main.go --debug server --disable-agent
go run -tags "apparmor" ../main.go --debug server --disable-agent

9
scripts/download Executable file
View File

@ -0,0 +1,9 @@
#!/bin/bash
ROOT_VERSION=v0.0.1
source $(dirname $0)/version.sh
cd $(dirname $0)/..
curl --compressed -sfL https://github.com/ibuildthecloud/k3s-root/releases/download/${ROOT_VERSION}/k3s-root-${ARCH}.tar | tar xf -

View File

@ -1,13 +1,11 @@
#!/bin/bash
set -e -x
ROOT_VERSION=v0.0.1
source $(dirname $0)/version
source $(dirname $0)/version.sh
cd $(dirname $0)/..
curl --compressed -sfL https://github.com/ibuildthecloud/k3s-root/releases/download/${ROOT_VERSION}/k3s-root-${ARCH}.tar | tar xf -
./scripts/download
rm -rf bin/kubectl bin/k3s-agent bin/k3s-server bin/kubectl bin/k3s build/data
ln -s containerd bin/k3s-agent
@ -21,6 +19,7 @@ for i in bridge flannel host-local loopback portmap; do
done
rm -rf build/data
mkdir -p build/data
tar cvzf ./build/data.tar.gz --exclude ./bin/hyperkube ./bin
@ -28,14 +27,16 @@ HASH=$(sha256sum ./build/data.tar.gz | awk '{print $1}')
cp ./build/data.tar.gz ./build/data/${HASH}.tgz
BIN_SUFFIX="-${ARCH}"
if [ ${ARCH} = amd64 ]; then
cp -f ./bin/hyperkube dist/hyperkube
CMD_NAME=dist/k3s
else
cp -f ./bin/hyperkube dist/hyperkube-${ARCH}
CMD_NAME=dist/k3s-${ARCH}
BIN_SUFFIX=""
elif [ ${ARCH} = arm ]; then
BIN_SUFFIX="-armhf"
fi
cp -f ./bin/hyperkube dist/hyperkube${BIN_SUFFIX}
CMD_NAME=dist/k3s${BIN_SUFFIX}
go generate
LDFLAGS="-X github.com/rancher/k3s/version.Version=$VERSION -w -s"
STATIC="-extldflags '-static'"

View File

@ -1,7 +1,7 @@
#!/bin/bash
set -e
source $(dirname $0)/version
source $(dirname $0)/version.sh
cd $(dirname $0)/../package

View File

@ -1,3 +0,0 @@
#!/bin/bash
exec $(dirname $0)/ci

3
scripts/release-arm Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
SKIP_VALIDATE=true $(dirname $0)/ci

39
scripts/release.sh Executable file
View File

@ -0,0 +1,39 @@
#!/bin/bash
set -e
cd $(dirname $0)/..
if [ -z "$K3S_ARM64_HOST" ]; then
echo K3S_ARM_HOST must be set
exit 1
fi
if [ -z "$K3S_ARM64_HOST_USER" ]; then
echo K3S_ARM_HOST_USER must be set
exit 1
fi
if [ -z "$K3S_ARM_HOST" ]; then
K3S_ARM_HOST=${K3S_ARM64_HOST}
fi
if [ -z "$K3S_ARM_HOST_USER" ]; then
K3S_ARM_HOST_USER=${K3S_ARM64_HOST_USER}
fi
rm -rf dist
mkdir -p build
make ci > build/build-amd64.log 2>&1 &
AMD_PID=$!
DAPPER_HOST_ARCH=arm DOCKER_HOST="ssh://${K3S_ARM_HOST_USER}@${K3S_ARM_HOST}" make release-arm
DAPPER_HOST_ARCH=arm64 DOCKER_HOST="ssh://${K3S_ARM64_HOST_USER}@${K3S_ARM64_HOST}" make release-arm
echo Waiting for amd64 build to finish
wait -n $AMD_PID || {
cat build/build-amd64.log
exit 1
}
ls -la dist
echo Done

View File

@ -7,8 +7,14 @@ echo Running validation
PACKAGES="$(go list ./...)"
#echo Running: go vet
#go vet ${PACKAGES}
if [ ! -e build/data ];then
mkdir -p build/data
fi
go generate
echo Running: go vet
go vet ${PACKAGES}
echo Running: gometalinter
for i in ${PACKAGES}; do
if [ -n "$(gometalinter $i | \
@ -24,5 +30,12 @@ test -z "$failed"
echo Running: go fmt
test -z "$(go fmt ${PACKAGES} | \
grep -v 'pkg/data/zz_generated_bindata.go' | \
grep -v 'pkg/deploy/zz_generated_bindata.go' | \
tee /dev/stderr)"
. ./scripts/version.sh
if [ -n "$DIRTY" ]; then
echo Source dir is dirty
git status --porcelain --untracked-files=no
#exit 1
fi