Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

Fixup arm and arm64 builds; Refactor Makefile; #1950

Merged
merged 1 commit into from
Apr 20, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 26 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ TEST_FLAGS?=
include docker/kubectl.version
include docker/helm.version

# NB default target architecture is amd64. If you would like to try the
# other one -- pass an ARCH variable, e.g.,
# `make ARCH=arm64`
ifeq ($(ARCH),)
ARCH=amd64
endif
CURRENT_OS_ARCH=$(shell echo `go env GOOS`-`go env GOARCH`)

# NB because this outputs absolute file names, you have to be careful
Expand All @@ -27,11 +33,21 @@ BUILD_DATE:=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
all: $(GOPATH)/bin/fluxctl $(GOPATH)/bin/fluxd $(GOPATH)/bin/helm-operator build/.flux.done build/.helm-operator.done

release-bins:
function do_build() { \
os=$$1 \
arch=$$2 \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -o "build/fluxctl_"$$os"_$$arch" $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxctl/; \
};\
for arch in amd64; do \
for os in linux darwin windows; do \
CGO_ENABLED=0 GOOS=$$os GOARCH=$$arch go build -o "build/fluxctl_"$$os"_$$arch" $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxctl/; \
do_build "$$os" "$$arch"; \
done; \
done
done; \
for arch in arm arm64; do \
for os in linux; do \
do_build "$$os" "$$arch"; \
done; \
done;

clean:
go clean
Expand All @@ -58,33 +74,33 @@ build/.helm-operator.done: build/helm-operator build/kubectl build/helm docker/s

build/fluxd: $(FLUXD_DEPS)
build/fluxd: cmd/fluxd/*.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxd
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/fluxd

build/helm-operator: $(HELM_OPERATOR_DEPS)
build/helm-operator: cmd/helm-operator/*.go
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/helm-operator
CGO_ENABLED=0 GOOS=linux GOARCH=${ARCH} go build -o $@ $(LDFLAGS) -ldflags "-X main.version=$(shell ./docker/image-tag)" ./cmd/helm-operator

build/kubectl: cache/linux-amd64/kubectl-$(KUBECTL_VERSION)
build/kubectl: cache/linux-$(ARCH)/kubectl-$(KUBECTL_VERSION)
test/bin/kubectl: cache/$(CURRENT_OS_ARCH)/kubectl-$(KUBECTL_VERSION)
build/helm: cache/linux-amd64/helm-$(HELM_VERSION)
build/helm: cache/linux-$(ARCH)/helm-$(HELM_VERSION)
test/bin/helm: cache/$(CURRENT_OS_ARCH)/helm-$(HELM_VERSION)
build/kubectl test/bin/kubectl build/helm test/bin/helm:
mkdir -p build
cp $< $@
if [ `basename $@` = "build" -a $(CURRENT_OS_ARCH) = "linux-amd64" ]; then strip $@; fi
if [ `basename $@` = "build" -a $(CURRENT_OS_ARCH) = "linux-$(ARCH)" ]; then strip $@; fi
chmod a+x $@

cache/%/kubectl-$(KUBECTL_VERSION): docker/kubectl.version
mkdir -p cache/$*
curl -L -o cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz "https://dl.k8s.io/$(KUBECTL_VERSION)/kubernetes-client-$*.tar.gz"
[ $* != "linux-amd64" ] || echo "$(KUBECTL_CHECKSUM) cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz" | shasum -a 256 -c
[ $* != "linux-$(ARCH)" ] || echo "$(KUBECTL_CHECKSUM_$(ARCH)) cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz" | shasum -a 256 -c
tar -m --strip-components 3 -C ./cache/$* -xzf cache/$*/kubectl-$(KUBECTL_VERSION).tar.gz kubernetes/client/bin/kubectl
mv ./cache/$*/kubectl $@

cache/%/helm-$(HELM_VERSION): docker/helm.version
mkdir -p cache/$*
curl -L -o cache/$*/helm-$(HELM_VERSION).tar.gz "https://storage.googleapis.com/kubernetes-helm/helm-v$(HELM_VERSION)-$*.tar.gz"
[ $* != "linux-amd64" ] || echo "$(HELM_CHECKSUM) cache/$*/helm-$(HELM_VERSION).tar.gz" | shasum -a 256 -c
[ $* != "linux-$(ARCH)" ] || echo "$(HELM_CHECKSUM_$(ARCH)) cache/$*/helm-$(HELM_VERSION).tar.gz" | shasum -a 256 -c
tar -m -C ./cache -xzf cache/$*/helm-$(HELM_VERSION).tar.gz $*/helm
mv cache/$*/helm $@

Expand All @@ -106,3 +122,4 @@ integration-test: all
check-generated:
./bin/helm/update_codegen.sh
git diff --exit-code -- integrations/apis intergrations/client

33 changes: 22 additions & 11 deletions bin/upload-binaries
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,26 @@ GITHUB_USER=${GITHUB_USER:-"${CIRCLE_PROJECT_USERNAME}"}
GITHUB_REPO=${GITHUB_REPO:-"${CIRCLE_PROJECT_REPONAME}"}
GITHUB_TAG=${GITHUB_TAG:-"${CIRCLE_TAG}"}

for arch in amd64; do
for os in linux darwin windows; do
echo "= Uploading fluxctl_${os}_${arch} to GH release ${GITHUB_TAG}"
github-release upload \
--user ${GITHUB_USER} \
--repo ${GITHUB_REPO} \
--tag ${GITHUB_TAG} \
--name "fluxctl_${os}_${arch}" \
--file "build/fluxctl_${os}_${arch}"
echo "* Finished pushing fluxctl_${os}_${arch} for ${GITHUB_TAG}"
done
function do_publish() {
os=$1
arch=$2
echo "= Uploading fluxctl_${os}_${arch} to GH release ${GITHUB_TAG}"
github-release upload \
--user ${GITHUB_USER} \
--repo ${GITHUB_REPO} \
--tag ${GITHUB_TAG} \
--name "fluxctl_${os}_${arch}" \
--file "build/fluxctl_${os}_${arch}"
echo "* Finished pushing fluxctl_${os}_${arch} for ${GITHUB_TAG}"
}

#amd64
for os in linux darwin windows; do
do_publish $os amd64
done

#arm
for arch in arm arm64; do
do_publish linux $arch
done

22 changes: 22 additions & 0 deletions checkpoint/checkpoint_linux_arm64.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package checkpoint

import (
"syscall"
)

func getKernelVersion() string {
var uts syscall.Utsname
syscall.Uname(&uts)
return cstringToString(uts.Release[:])
}

func cstringToString(arr []int8) string {
b := make([]byte, 0, len(arr))
for _, v := range arr {
if v == 0x00 {
break
}
b = append(b, byte(v))
}
return string(b)
}
4 changes: 3 additions & 1 deletion docker/helm.version
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
# that reliably supports authenticating against chart repos, so that
# wins.
HELM_VERSION=2.13.0
HELM_CHECKSUM=15eca6ad225a8279de80c7ced42305e24bc5ac60bb7d96f2d2fa4af86e02c794
HELM_CHECKSUM_amd64=15eca6ad225a8279de80c7ced42305e24bc5ac60bb7d96f2d2fa4af86e02c794
HELM_CHECKSUM_arm=adf1242eca171ba21847e621ce9fbdbb3dd2aa35ac8532fb05519b1b49fd4456
HELM_CHECKSUM_arm64=afb51c43ed83fe8bac62f7e47872019cf1c0d8a1927d69fb963959c6accc77b5
5 changes: 4 additions & 1 deletion docker/kubectl.version
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
KUBECTL_VERSION=v1.11.3
KUBECTL_CHECKSUM=14a70ac05c00fcfd7d632fc9e7a5fbc6615ce1b370bb1a0e506a24972d461493
KUBECTL_CHECKSUM_amd64=14a70ac05c00fcfd7d632fc9e7a5fbc6615ce1b370bb1a0e506a24972d461493
KUBECTL_CHECKSUM_arm=c62835797d58b50f19706d897a9106b219f5868b0a6c7bb62c6284f809c01473
KUBECTL_CHECKSUM_arm64=a43510f821d349519ecba27b24788a0e41eae31d79bc7af73b6132190b0dcce2

7 changes: 7 additions & 0 deletions site/building.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ $ make

This makes Docker images, and installs binaries to $GOPATH/bin.

Note: The default target architecture is amd64. If you would like to try to build Docker images
and binaries for a different architecture you will have to set ARCH variable,

```sh
$ make ARCH=<target_arch>
```

# Test

```sh
Expand Down