From dff694b21857e4446544b9da6a38019598c2c25e Mon Sep 17 00:00:00 2001 From: Sudarsan Reddy Date: Thu, 22 Jul 2021 16:36:49 +0100 Subject: [PATCH] TUN-4761: Added a build-all-packages target to cfsetup --- .gitignore | 1 + Makefile | 23 +++++++++++------------ build-packages.sh | 22 ++++++++++++++++++++++ cfsetup.yaml | 17 +++++++++++++++++ 4 files changed, 51 insertions(+), 12 deletions(-) create mode 100755 build-packages.sh diff --git a/.gitignore b/.gitignore index 12fc33db..d3b17958 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ cscope.* *-session.log ssh_server_tests/.env /.cover +built_artifacts/ diff --git a/Makefile b/Makefile index 141e477d..515b1639 100644 --- a/Makefile +++ b/Makefile @@ -88,7 +88,7 @@ clean: go clean .PHONY: cloudflared -cloudflared: tunnel-deps +cloudflared: ifeq ($(FIPS), true) $(info Building cloudflared with go-fips) -test -f fips/fips.go && mv fips/fips.go fips/fips.go.linux-amd64 @@ -157,6 +157,14 @@ cloudflared-deb: cloudflared cloudflared-rpm: cloudflared $(call build_package,rpm) +.PHONY: cloudflared-pkg +cloudflared-pkg: cloudflared + $(call build_package,osxpkg) + +.PHONY: cloudflared-msi +cloudflared-msi: cloudflared + wixl --define Version=$(VERSION) --define Path=$(EXECUTABLE_PATH) --output cloudflared-$(VERSION)-$(TARGET_ARCH).msi cloudflared.wxs + .PHONY: cloudflared-darwin-amd64.tgz cloudflared-darwin-amd64.tgz: cloudflared tar czf cloudflared-darwin-amd64.tgz cloudflared @@ -227,10 +235,6 @@ homebrew-release: homebrew-upload release: bin/equinox bin/equinox release $(EQUINOX_FLAGS) -- $(VERSION_FLAGS) $(IMPORT_PATH)/cmd/cloudflared -.PHONY: build-msi -build-msi: - wixl --define Version=$(VERSION) --define Path=$(EXECUTABLE_PATH) cloudflared.wxs - .PHONY: github-release github-release: cloudflared python3 github_release.py --path $(EXECUTABLE_PATH) --release-version $(VERSION) @@ -248,10 +252,9 @@ bin/equinox: mkdir -p bin curl -s https://bin.equinox.io/c/75JtLRTsJ3n/release-tool-beta-$(EQUINOX_PLATFORM).tgz | tar xz -C bin/ -.PHONY: tunnel-deps -tunnel-deps: tunnelrpc/tunnelrpc.capnp.go -tunnelrpc/tunnelrpc.capnp.go: tunnelrpc/tunnelrpc.capnp +.PHONY: tunnelrpc-deps +tunnelrpc-deps: which capnp # https://capnproto.org/install.html which capnpc-go # go get zombiezen.com/go/capnproto2/capnpc-go capnp compile -ogo tunnelrpc/tunnelrpc.capnp @@ -268,10 +271,6 @@ vet: which go-sumtype # go get github.com/BurntSushi/go-sumtype (don't do this in build directory or this will cause vendor issues) go-sumtype $$(go list -mod=vendor ./...) -.PHONY: msi -msi: cloudflared - go-msi make --msi cloudflared.msi --version $(MSI_VERSION) - .PHONY: goimports goimports: for d in $$(go list -mod=readonly -f '{{.Dir}}' -a ./... | fgrep -v tunnelrpc) ; do goimports -format-only -local github.com/cloudflare/cloudflared -w $$d ; done diff --git a/build-packages.sh b/build-packages.sh new file mode 100755 index 00000000..e416acad --- /dev/null +++ b/build-packages.sh @@ -0,0 +1,22 @@ +# This controls the directory the built artifacts go into +export ARTIFACT_DIR=built_artifacts/ +mkdir -p $ARTIFACT_DIR +windowsArchs=("amd64" "386") +export TARGET_OS=windows +for arch in ${windowsArchs[@]}; do + export TARGET_ARCH=$arch + make cloudflared-msi +done + +mv *.msi $ARTIFACT_DIR + +linuxArchs=("amd64" "386" "arm") +export TARGET_OS=linux +for arch in ${linuxArchs[@]}; do + export TARGET_ARCH=$arch + make cloudflared-deb + make cloudflared-rpm +done + +mv *.deb $ARTIFACT_DIR +mv *.rpm $ARTIFACT_DIR diff --git a/cfsetup.yaml b/cfsetup.yaml index b1170d79..7f47c0ae 100644 --- a/cfsetup.yaml +++ b/cfsetup.yaml @@ -14,6 +14,23 @@ stretch: &stretch - export GOARCH=amd64 - export FIPS=true - make cloudflared + build-all-packages: #except osxpkg + build_dir: *build_dir + builddeps: + - *pinned_go_fips + - build-essential + - fakeroot + - rubygem-fpm + - rpm + - wget + # libmsi and libgcab are libraries the wixl binary depends on. + - libmsi-dev + - libgcab-dev + pre-cache: + - wget https://github.com/sudarshan-reddy/msitools/releases/download/v0.101b/wixl -P /usr/local/bin + - chmod a+x /usr/local/bin/wixl + post-cache: + - ./build-packages.sh build-deb: build_dir: *build_dir builddeps: &build_deb_deps