Skip to content

Commit

Permalink
Merge commit 'da9eaba42e9b93d6975059b7f37c7863e54e1db1'
Browse files Browse the repository at this point in the history
  • Loading branch information
tamalsaha committed Jul 31, 2018
2 parents e6370a8 + da9eaba commit dd3cf1c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions hack/libbuild/common/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ detect_tag() {
echo "commit_timestamp = $commit_timestamp"

# write TAG info to a file so that it can be loaded by a different command or script
if [ "$1" != '' ]; then
if [ $# -gt 0 ] && [ "$1" != '' ]; then
cat >"$1" <<EOL
TAG=$TAG
TAG_STRATEGY=$TAG_STRATEGY
Expand Down Expand Up @@ -136,7 +136,7 @@ hub_canary() {
hub_up

# ref: https://www.gnu.org/software/bash/manual/html_node/Conditional-Constructs.html#Conditional-Constructs
if [[ "$TAG_STRATEGY" == "commit_hash" && "$git_branch" == "master" ]]; then
if [[ "${TAG_STRATEGY:-}" == "commit_hash" && "${git_branch:-}" == "master" ]]; then
local cmd="docker tag $DOCKER_REGISTRY/$IMG:$TAG $DOCKER_REGISTRY/$IMG:canary"
echo $cmd
$cmd
Expand Down
8 changes: 6 additions & 2 deletions hack/libbuild/libbuild.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,13 +174,15 @@ def go_build(name, goos, goarch, main, compress=False, upx=False):
if linker_opts:
ldflags = "-ldflags '{}'".format(' '.join(linker_opts))

tags = "-tags 'osusergo netgo static_build'"

bindir = 'dist/{name}'.format(name=name)
if not os.path.isdir(bindir):
os.makedirs(bindir)
if goos == 'alpine':
repo_dir = REPO_ROOT[len(GOPATH):]
uid = check_output('id -u').strip()
cmd = "docker run --rm -u {uid} -v /tmp:/.cache -v {repo_root}:/go{repo_dir} -w /go{repo_dir} -e {cgo_env} golang:1.9-alpine {goc} build -o {bindir}/{name}-{goos}-{goarch}{ext} {cgo} {ldflags} {main}".format(
cmd = "docker run --rm -u {uid} -v /tmp:/.cache -v {repo_root}:/go{repo_dir} -w /go{repo_dir} -e {cgo_env} golang:1.9-alpine {goc} build -o {bindir}/{name}-{goos}-{goarch}{ext} {cgo} {ldflags} {tags} {main}".format(
repo_root=REPO_ROOT,
repo_dir=repo_dir,
uid=uid,
Expand All @@ -192,11 +194,12 @@ def go_build(name, goos, goarch, main, compress=False, upx=False):
cgo_env=cgo_env,
cgo=cgo,
ldflags=ldflags,
tags=tags,
ext='.exe' if goos == 'windows' else '',
main=main
)
else:
cmd = "GOOS={goos} GOARCH={goarch} {cgo_env} {goc} build -o {bindir}/{name}-{goos}-{goarch}{ext} {cgo} {ldflags} {main}".format(
cmd = "GOOS={goos} GOARCH={goarch} {cgo_env} {goc} build -o {bindir}/{name}-{goos}-{goarch}{ext} {cgo} {ldflags} {tags} {main}".format(
name=name,
goc=GOC,
goos=goos,
Expand All @@ -205,6 +208,7 @@ def go_build(name, goos, goarch, main, compress=False, upx=False):
cgo_env=cgo_env,
cgo=cgo,
ldflags=ldflags,
tags=tags,
ext='.exe' if goos == 'windows' else '',
main=main
)
Expand Down

0 comments on commit dd3cf1c

Please sign in to comment.