mirror of
https://github.com/etcd-io/etcd.git
synced 2024-09-27 06:25:44 +00:00
build: use "bash" syntax, clean up
Signed-off-by: Gyuho Lee <gyuhox@gmail.com>
This commit is contained in:
parent
d7092b360d
commit
1da0818186
33
build
33
build
@ -1,11 +1,11 @@
|
|||||||
#!/bin/sh -e
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
# set some environment variables
|
# set some environment variables
|
||||||
ORG_PATH="github.com/coreos"
|
ORG_PATH="github.com/coreos"
|
||||||
REPO_PATH="${ORG_PATH}/etcd"
|
REPO_PATH="${ORG_PATH}/etcd"
|
||||||
|
|
||||||
GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound")
|
GIT_SHA=$(git rev-parse --short HEAD || echo "GitNotFound")
|
||||||
if [ ! -z "$FAILPOINTS" ]; then
|
if [[ ! -z "$FAILPOINTS" ]]; then
|
||||||
GIT_SHA="$GIT_SHA"-FAILPOINTS
|
GIT_SHA="$GIT_SHA"-FAILPOINTS
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -17,7 +17,7 @@ toggle_failpoints() {
|
|||||||
mode="$1"
|
mode="$1"
|
||||||
if which gofail >/dev/null 2>&1; then
|
if which gofail >/dev/null 2>&1; then
|
||||||
gofail "$mode" etcdserver/ internal/mvcc/backend/
|
gofail "$mode" etcdserver/ internal/mvcc/backend/
|
||||||
elif [ "$mode" != "disable" ]; then
|
elif [[ "$mode" != "disable" ]]; then
|
||||||
echo "FAILPOINTS set but gofail not found"
|
echo "FAILPOINTS set but gofail not found"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -26,11 +26,11 @@ toggle_failpoints() {
|
|||||||
etcd_setup_gopath() {
|
etcd_setup_gopath() {
|
||||||
echo "Setting GOPATH from vendor directory at 'gopath'"
|
echo "Setting GOPATH from vendor directory at 'gopath'"
|
||||||
d=$(dirname "$0")
|
d=$(dirname "$0")
|
||||||
CDIR=$(cd "$d" && pwd)
|
CDIR=$(cd "$d" || return && pwd)
|
||||||
cd "$CDIR"
|
cd "$CDIR" || return
|
||||||
etcdGOPATH="${CDIR}/gopath"
|
etcdGOPATH="${CDIR}/gopath"
|
||||||
# preserve old gopath to support building with unvendored tooling deps (e.g., gofail)
|
# preserve old gopath to support building with unvendored tooling deps (e.g., gofail)
|
||||||
if [ -n "$GOPATH" ]; then
|
if [[ -n "$GOPATH" ]]; then
|
||||||
GOPATH=":$GOPATH"
|
GOPATH=":$GOPATH"
|
||||||
fi
|
fi
|
||||||
rm -rf "${etcdGOPATH:?}/"
|
rm -rf "${etcdGOPATH:?}/"
|
||||||
@ -38,32 +38,35 @@ etcd_setup_gopath() {
|
|||||||
export GOPATH=${etcdGOPATH}/vendor:${etcdGOPATH}/etcd_src${GOPATH}
|
export GOPATH=${etcdGOPATH}/vendor:${etcdGOPATH}/etcd_src${GOPATH}
|
||||||
ln -s "${CDIR}/vendor" "${etcdGOPATH}/vendor/src"
|
ln -s "${CDIR}/vendor" "${etcdGOPATH}/vendor/src"
|
||||||
ln -s "${CDIR}" "${etcdGOPATH}/etcd_src/src/github.com/coreos/etcd"
|
ln -s "${CDIR}" "${etcdGOPATH}/etcd_src/src/github.com/coreos/etcd"
|
||||||
|
|
||||||
#ln -s "${CDIR}/vendor" "${etcdGOPATH}/src"
|
|
||||||
#ln -s "${CDIR}" "${etcdGOPATH}/src/github.com/coreos"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle_failpoints_default() {
|
toggle_failpoints_default() {
|
||||||
mode="disable"
|
mode="disable"
|
||||||
if [ ! -z "$FAILPOINTS" ]; then mode="enable"; fi
|
if [[ ! -z "$FAILPOINTS" ]]; then mode="enable"; fi
|
||||||
toggle_failpoints "$mode"
|
toggle_failpoints "$mode"
|
||||||
}
|
}
|
||||||
|
|
||||||
etcd_build() {
|
etcd_build() {
|
||||||
out="bin"
|
out="bin"
|
||||||
if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi
|
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
|
||||||
toggle_failpoints_default
|
toggle_failpoints_default
|
||||||
# Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK
|
|
||||||
|
|
||||||
|
# Static compilation is useful when etcd is run in a container. $GO_BUILD_FLAGS is OK
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o "${out}/etcd" ${REPO_PATH} || return
|
CGO_ENABLED=0 go build $GO_BUILD_FLAGS \
|
||||||
|
-installsuffix cgo \
|
||||||
|
-ldflags "$GO_LDFLAGS" \
|
||||||
|
-o "${out}/etcd" ${REPO_PATH} || return
|
||||||
# shellcheck disable=SC2086
|
# shellcheck disable=SC2086
|
||||||
CGO_ENABLED=0 go build $GO_BUILD_FLAGS -installsuffix cgo -ldflags "$GO_LDFLAGS" -o "${out}/etcdctl" ${REPO_PATH}/etcdctl || return
|
CGO_ENABLED=0 go build $GO_BUILD_FLAGS \
|
||||||
|
-installsuffix cgo \
|
||||||
|
-ldflags "$GO_LDFLAGS" \
|
||||||
|
-o "${out}/etcdctl" ${REPO_PATH}/etcdctl || return
|
||||||
}
|
}
|
||||||
|
|
||||||
tools_build() {
|
tools_build() {
|
||||||
out="bin"
|
out="bin"
|
||||||
if [ -n "${BINDIR}" ]; then out="${BINDIR}"; fi
|
if [[ -n "${BINDIR}" ]]; then out="${BINDIR}"; fi
|
||||||
tools_path="benchmark
|
tools_path="benchmark
|
||||||
etcd-dump-db
|
etcd-dump-db
|
||||||
etcd-dump-logs
|
etcd-dump-logs
|
||||||
|
64
test
64
test
@ -277,32 +277,6 @@ function release_pass {
|
|||||||
mv /tmp/etcd ./bin/etcd-last-release
|
mv /tmp/etcd ./bin/etcd-last-release
|
||||||
}
|
}
|
||||||
|
|
||||||
function gofmt_pass {
|
|
||||||
fmtRes=$(gofmt -l -s -d "${FMT[@]}")
|
|
||||||
if [ -n "${fmtRes}" ]; then
|
|
||||||
echo -e "gofmt checking failed:\n${fmtRes}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function govet_pass {
|
|
||||||
vetRes=$(go vet "${TEST[@]}")
|
|
||||||
if [ -n "${vetRes}" ]; then
|
|
||||||
echo -e "govet checking failed:\n${vetRes}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function govet_shadow_pass {
|
|
||||||
fmtpkgs=$(for a in "${FMT[@]}"; do dirname "$a"; done | sort | uniq | grep -v "\\.")
|
|
||||||
fmtpkgs=($fmtpkgs)
|
|
||||||
vetRes=$(go tool vet -all -shadow "${fmtpkgs[@]}" 2>&1 | grep -v '/gw/' || true)
|
|
||||||
if [ -n "${vetRes}" ]; then
|
|
||||||
echo -e "govet -all -shadow checking failed:\n${vetRes}"
|
|
||||||
exit 255
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
function shellcheck_pass {
|
function shellcheck_pass {
|
||||||
if which shellcheck >/dev/null; then
|
if which shellcheck >/dev/null; then
|
||||||
shellcheckResult=$(shellcheck -fgcc build test scripts/* 2>&1 || true)
|
shellcheckResult=$(shellcheck -fgcc build test scripts/* 2>&1 || true)
|
||||||
@ -360,6 +334,32 @@ function goword_pass {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gofmt_pass {
|
||||||
|
fmtRes=$(gofmt -l -s -d "${FMT[@]}")
|
||||||
|
if [ -n "${fmtRes}" ]; then
|
||||||
|
echo -e "gofmt checking failed:\n${fmtRes}"
|
||||||
|
exit 255
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function govet_pass {
|
||||||
|
vetRes=$(go vet "${TEST[@]}")
|
||||||
|
if [ -n "${vetRes}" ]; then
|
||||||
|
echo -e "govet checking failed:\n${vetRes}"
|
||||||
|
exit 255
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function govet_shadow_pass {
|
||||||
|
fmtpkgs=$(for a in "${FMT[@]}"; do dirname "$a"; done | sort | uniq | grep -v "\\.")
|
||||||
|
fmtpkgs=($fmtpkgs)
|
||||||
|
vetRes=$(go tool vet -all -shadow "${fmtpkgs[@]}" 2>&1 | grep -v '/gw/' || true)
|
||||||
|
if [ -n "${vetRes}" ]; then
|
||||||
|
echo -e "govet -all -shadow checking failed:\n${vetRes}"
|
||||||
|
exit 255
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function gosimple_pass {
|
function gosimple_pass {
|
||||||
if which gosimple >/dev/null; then
|
if which gosimple >/dev/null; then
|
||||||
gosimpleResult=$(gosimple "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
gosimpleResult=$(gosimple "${STATIC_ANALYSIS_PATHS[@]}" 2>&1 || true)
|
||||||
@ -483,13 +483,13 @@ function commit_title_pass {
|
|||||||
function fmt_pass {
|
function fmt_pass {
|
||||||
toggle_failpoints disable
|
toggle_failpoints disable
|
||||||
|
|
||||||
for p in gofmt \
|
for p in shellcheck \
|
||||||
govet \
|
|
||||||
govet_shadow \
|
|
||||||
shellcheck \
|
|
||||||
markdown_you \
|
markdown_you \
|
||||||
markdown_marker \
|
markdown_marker \
|
||||||
goword \
|
goword \
|
||||||
|
gofmt \
|
||||||
|
govet \
|
||||||
|
govet_shadow \
|
||||||
gosimple \
|
gosimple \
|
||||||
unused \
|
unused \
|
||||||
staticcheck \
|
staticcheck \
|
||||||
@ -499,9 +499,9 @@ function fmt_pass {
|
|||||||
receiver_name \
|
receiver_name \
|
||||||
commit_title \
|
commit_title \
|
||||||
; do
|
; do
|
||||||
echo "Starting '$p' pass at $(date)"
|
echo "'$p' started at $(date)"
|
||||||
"${p}"_pass "$@"
|
"${p}"_pass "$@"
|
||||||
echo "Finished '$p' pass at $(date)"
|
echo "'$p' completed at $(date)"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user