Browse Source

Clean up build scripts

Switch binaries to armhf suffix to be more clean on the on
architecture
pull/13/head
Darren Shepherd 6 years ago
parent
commit
6fa7f5b3ae
  1. 2
      Dockerfile.dapper
  2. 5
      Makefile
  3. 1
      main.go
  4. 2
      pkg/deploy/zz_generated_bindata.go
  5. 2
      scripts/build
  6. 4
      scripts/ci
  7. 2
      scripts/dev-server.sh
  8. 9
      scripts/download
  9. 0
      scripts/entry.sh
  10. 19
      scripts/package-cli
  11. 2
      scripts/package-image
  12. 3
      scripts/release
  13. 3
      scripts/release-arm
  14. 39
      scripts/release.sh
  15. 19
      scripts/validate
  16. 0
      scripts/version.sh

2
Dockerfile.dapper

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

5
Makefile

@ -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)

1
main.go

@ -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

2
pkg/deploy/zz_generated_bindata.go

@ -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, "/")...)...)
}

2
scripts/build

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

4
scripts/ci

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

2
scripts/dev-server.sh

@ -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

@ -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 -

0
scripts/entry → scripts/entry.sh

19
scripts/package-cli

@ -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'"

2
scripts/package-image

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

3
scripts/release

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

3
scripts/release-arm

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

39
scripts/release.sh

@ -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

19
scripts/validate

@ -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

0
scripts/version → scripts/version.sh

Loading…
Cancel
Save