From 41cba3a4579aeabe4feb56729ab1d637035f9341 Mon Sep 17 00:00:00 2001 From: Harshavardhana Date: Fri, 18 Mar 2016 13:02:06 -0700 Subject: [PATCH] buildscripts: compress release binaries. Fix update command as well to show compressed files in updates. --- Makefile | 4 ++-- buildscripts/build.sh | 38 +++++++++++++++++++++++++++++++++++++- update-main.go | 7 ++++--- 3 files changed, 43 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 1d91965d5..69f9e20db 100644 --- a/Makefile +++ b/Makefile @@ -138,10 +138,10 @@ dockerimage: checkdocker verifiers $(UI_ASSETS) @rm minio.dockerimage release: verifiers - @MINIO_RELEASE=RELEASE GO15VENDOREXPERIMENT=1 ./buildscripts/build.sh + @MINIO_RELEASE=RELEASE ./buildscripts/build.sh experimental: verifiers - @MINIO_RELEASE=EXPERIMENTAL GO15VENDOREXPERIMENT=1 ./buildscripts/build.sh + @MINIO_RELEASE=EXPERIMENTAL ./buildscripts/build.sh clean: @echo "Cleaning up all the generated files:" diff --git a/buildscripts/build.sh b/buildscripts/build.sh index 1fd07a663..8fc744767 100755 --- a/buildscripts/build.sh +++ b/buildscripts/build.sh @@ -24,6 +24,12 @@ _init() { # List of supported architectures SUPPORTED_OSARCH='linux/386 linux/amd64 linux/arm windows/386 windows/amd64 darwin/amd64' + + ## System binaries + CP="/bin/cp" + SHASUM="/usr/bin/shasum" + GZIP="/usr/bin/gzip" + ZIP="/usr/bin/zip" } go_build() { @@ -33,7 +39,37 @@ go_build() { package=$(go list -f '{{.ImportPath}}') echo -n "-->" printf "%15s:%s\n" "${osarch}" "${package}" - GO15VENDOREXPERIMENT=1 GOOS=$os GOARCH=$arch go build --ldflags "${LDFLAGS}" -o $release_str/$os-$arch/$(basename $package).$release_tag + + # Release binary name + release_bin="$release_str/$os-$arch/$(basename $package).$release_tag" + # Release binary downloadable name + release_real_bin="$release_str/$os-$arch/$(basename $package)" + # Release shasum name + release_shasum="$release_str/$os-$arch/$(basename $package).shasum" + # Release zip file. + release_real_zip="$release_str/$os-$arch/$(basename $package).zip" + release_real_gz="$release_str/$os-$arch/$(basename $package).gz" + + # Go build to build the binary. + GOOS=$os GOARCH=$arch go build --ldflags "${LDFLAGS}" -o $release_bin + + # Create copy + $CP -p $release_bin $release_real_bin + + # Calculate shasum + $SHASUM $release_bin > $release_shasum + + # Create a compressed file. + if [ $os == "windows" ]; then + $ZIP -r $release_real_zip $release_real_bin + elif [ $os == "darwin" ]; then + $ZIP -r $release_real_zip $release_real_bin + elif [ $os == "linux" ]; then + $GZIP -c $release_real_bin > $release_real_gz + else + echo "$os operating system is not supported." + exit 1 + fi } main() { diff --git a/update-main.go b/update-main.go index 5d1c829b8..b51345d44 100644 --- a/update-main.go +++ b/update-main.go @@ -172,11 +172,12 @@ func getReleaseUpdate(updateURL string) { } var downloadURL string - if runtime.GOOS == "windows" { - downloadURL = newUpdateURLPrefix + "/minio.exe" + if runtime.GOOS == "windows" || runtime.GOOS == "darwin" { + downloadURL = newUpdateURLPrefix + "/minio.zip" } else { - downloadURL = newUpdateURLPrefix + "/minio" + downloadURL = newUpdateURLPrefix + "/minio.gz" } + updateMsg := updateMessage{ Download: downloadURL, Version: minioVersion,