mirror of https://github.com/k3s-io/k3s
Clean up godep scripts to be self-contained
parent
7732c8d892
commit
a29c048e33
|
@ -22,8 +22,15 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||||
source "${KUBE_ROOT}/hack/lib/util.sh"
|
source "${KUBE_ROOT}/hack/lib/util.sh"
|
||||||
|
|
||||||
|
kube::log::status "Restoring kubernetes godeps"
|
||||||
|
|
||||||
|
if kube::util::godep_restored >/dev/null 2>&1; then
|
||||||
|
kube::log::status "Dependencies appear to be current - skipping download"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
kube::util::ensure_godep_version
|
kube::util::ensure_godep_version
|
||||||
|
|
||||||
kube::log::status "Starting to download all kubernetes godeps. This takes a while"
|
kube::log::status "Downloading dependencies - this might take a while"
|
||||||
GOPATH=${GOPATH}:${KUBE_ROOT}/staging godep restore "$@"
|
GOPATH="${GOPATH}:${KUBE_ROOT}/staging" godep restore "$@"
|
||||||
kube::log::status "Download finished"
|
kube::log::status "Done"
|
||||||
|
|
|
@ -22,13 +22,35 @@ KUBE_ROOT=$(dirname "${BASH_SOURCE}")/..
|
||||||
source "${KUBE_ROOT}/hack/lib/init.sh"
|
source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||||
source "${KUBE_ROOT}/hack/lib/util.sh"
|
source "${KUBE_ROOT}/hack/lib/util.sh"
|
||||||
|
|
||||||
|
kube::log::status "Ensuring prereqs"
|
||||||
kube::util::ensure_single_dir_gopath
|
kube::util::ensure_single_dir_gopath
|
||||||
kube::util::ensure_godep_version
|
|
||||||
kube::util::ensure_no_staging_repos_in_gopath
|
kube::util::ensure_no_staging_repos_in_gopath
|
||||||
|
|
||||||
if [ -e "${KUBE_ROOT}/vendor" -o -e "${KUBE_ROOT}/Godeps" ]; then
|
kube::util::ensure_godep_version
|
||||||
echo "The directory vendor/ or Godeps/ exists. Remove them before running godep-save.sh" 1>&2
|
|
||||||
exit 1
|
BACKUP=_tmp/godep-save.$RANDOM
|
||||||
|
mkdir -p "${BACKUP}"
|
||||||
|
|
||||||
|
function kube::godep_save::cleanup() {
|
||||||
|
if [[ -d "${BACKUP}/vendor" ]]; then
|
||||||
|
kube::log::error "${BACKUP}/vendor exists, restoring it"
|
||||||
|
rm -rf vendor
|
||||||
|
mv "${BACKUP}/vendor" vendor
|
||||||
|
fi
|
||||||
|
if [[ -d "${BACKUP}/Godeps" ]]; then
|
||||||
|
kube::log::error "${BACKUP}/Godeps exists, restoring it"
|
||||||
|
rm -rf Godeps
|
||||||
|
mv "${BACKUP}/Godeps" Godeps
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
kube::util::trap_add kube::godep_save::cleanup EXIT
|
||||||
|
|
||||||
|
# Clear old state, but save it in case of error
|
||||||
|
if [[ -d vendor ]]; then
|
||||||
|
mv vendor "${BACKUP}/vendor"
|
||||||
|
fi
|
||||||
|
if [[ -d Godeps ]]; then
|
||||||
|
mv Godeps "${BACKUP}/Godeps"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Some things we want in godeps aren't code dependencies, so ./...
|
# Some things we want in godeps aren't code dependencies, so ./...
|
||||||
|
@ -39,23 +61,29 @@ REQUIRED_BINS=(
|
||||||
"./..."
|
"./..."
|
||||||
)
|
)
|
||||||
|
|
||||||
pushd "${KUBE_ROOT}" > /dev/null
|
kube::log::status "Running godep save - this might take a while"
|
||||||
echo "Running godep save. This will take around 15 minutes."
|
# This uses $(pwd) rather than ${KUBE_ROOT} because KUBE_ROOT will be
|
||||||
GOPATH=${GOPATH}:${KUBE_ROOT}/staging godep save "${REQUIRED_BINS[@]}"
|
# realpath'ed, and godep barfs ("... is not using a known version control
|
||||||
|
# system") on our staging dirs.
|
||||||
|
GOPATH="${GOPATH}:$(pwd)/staging" godep save "${REQUIRED_BINS[@]}"
|
||||||
|
|
||||||
# create a symlink in vendor directory pointing to the staging client. This
|
# create a symlink in vendor directory pointing to the staging client. This
|
||||||
# let other packages use the staging client as if it were vendored.
|
# let other packages use the staging client as if it were vendored.
|
||||||
for repo in $(ls ${KUBE_ROOT}/staging/src/k8s.io); do
|
for repo in $(ls staging/src/k8s.io); do
|
||||||
if [ ! -e "vendor/k8s.io/${repo}" ]; then
|
if [ ! -e "vendor/k8s.io/${repo}" ]; then
|
||||||
ln -s "../../staging/src/k8s.io/${repo}" "vendor/k8s.io/${repo}"
|
ln -s "../../staging/src/k8s.io/${repo}" "vendor/k8s.io/${repo}"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
popd > /dev/null
|
|
||||||
|
|
||||||
# Workaround broken symlink in docker repo because godep copies the link, but not the target
|
# Workaround broken symlink in docker repo because godep copies the link, but
|
||||||
rm -rf ${KUBE_ROOT}/vendor/github.com/docker/docker/project/
|
# not the target
|
||||||
|
rm -rf vendor/github.com/docker/docker/project/
|
||||||
|
|
||||||
echo
|
kube::log::status "Updating BUILD files"
|
||||||
echo "Don't forget to run:"
|
hack/update-bazel.sh >/dev/null
|
||||||
echo "- hack/update-bazel.sh to recreate the BUILD files"
|
|
||||||
echo "- hack/update-godep-licenses.sh if you added or removed a dependency!"
|
kube::log::status "Updating LICENSES file"
|
||||||
|
hack/update-godep-licenses.sh >/dev/null
|
||||||
|
|
||||||
|
# Clean up
|
||||||
|
rm -rf "${BACKUP}"
|
||||||
|
|
|
@ -85,7 +85,7 @@ kube::util::trap_add() {
|
||||||
if [[ -z "${existing_cmd}" ]]; then
|
if [[ -z "${existing_cmd}" ]]; then
|
||||||
new_cmd="${trap_add_cmd}"
|
new_cmd="${trap_add_cmd}"
|
||||||
else
|
else
|
||||||
new_cmd="${existing_cmd};${trap_add_cmd}"
|
new_cmd="${trap_add_cmd};${existing_cmd}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Assign the test
|
# Assign the test
|
||||||
|
|
|
@ -53,12 +53,7 @@ if ! $ALL ; then
|
||||||
echo "Running in short-circuit mode; run with -a to force all scripts to run."
|
echo "Running in short-circuit mode; run with -a to force all scripts to run."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
kube::util::ensure_godep_version
|
"${KUBE_ROOT}/hack/godep-restore.sh" ${V}
|
||||||
|
|
||||||
if ! kube::util::godep_restored 2>&1 | sed 's/^/ /'; then
|
|
||||||
echo "Running godep restore"
|
|
||||||
"${KUBE_ROOT}/hack/godep-restore.sh" ${V}
|
|
||||||
fi
|
|
||||||
|
|
||||||
BASH_TARGETS="
|
BASH_TARGETS="
|
||||||
update-generated-protobuf
|
update-generated-protobuf
|
||||||
|
|
|
@ -25,10 +25,17 @@ source "${KUBE_ROOT}/hack/lib/init.sh"
|
||||||
rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.go"
|
rm -f "${KUBE_ROOT}/pkg/generated/openapi/zz_generated.openapi.go"
|
||||||
|
|
||||||
# The git commit sha1s here should match the values in $KUBE_ROOT/WORKSPACE.
|
# The git commit sha1s here should match the values in $KUBE_ROOT/WORKSPACE.
|
||||||
kube::util::go_install_from_commit github.com/kubernetes/repo-infra/kazel 4eaf9e671bbb549fb4ec292cf251f921d7ef80ac
|
kube::util::go_install_from_commit \
|
||||||
kube::util::go_install_from_commit github.com/bazelbuild/rules_go/go/tools/gazelle/gazelle 82483596ec203eb9c1849937636f4cbed83733eb
|
github.com/kubernetes/repo-infra/kazel \
|
||||||
|
4eaf9e671bbb549fb4ec292cf251f921d7ef80ac
|
||||||
|
kube::util::go_install_from_commit \
|
||||||
|
github.com/bazelbuild/rules_go/go/tools/gazelle/gazelle \
|
||||||
|
82483596ec203eb9c1849937636f4cbed83733eb
|
||||||
|
|
||||||
touch "${KUBE_ROOT}/vendor/BUILD"
|
touch "${KUBE_ROOT}/vendor/BUILD"
|
||||||
|
|
||||||
gazelle fix -build_file_name=BUILD,BUILD.bazel -external=vendored -mode=fix -repo_root="$(kube::realpath ${KUBE_ROOT})"
|
gazelle fix \
|
||||||
kazel -root="$(kube::realpath ${KUBE_ROOT})"
|
-build_file_name=BUILD,BUILD.bazel \
|
||||||
|
-external=vendored \
|
||||||
|
-mode=fix
|
||||||
|
kazel
|
||||||
|
|
|
@ -61,10 +61,7 @@ kube::util::ensure_godep_version
|
||||||
# Create a fake git repo the root of the repo to prevent godeps from complaining
|
# Create a fake git repo the root of the repo to prevent godeps from complaining
|
||||||
kube::util::create-fake-git-tree "${KUBE_ROOT}"
|
kube::util::create-fake-git-tree "${KUBE_ROOT}"
|
||||||
|
|
||||||
kube::log::status "Checking whether godeps are restored"
|
"${KUBE_ROOT}/hack/godep-restore.sh"
|
||||||
if ! kube::util::godep_restored 2>&1 | sed 's/^/ /'; then
|
|
||||||
${KUBE_ROOT}/hack/godep-restore.sh
|
|
||||||
fi
|
|
||||||
|
|
||||||
kube::util::ensure-temp-dir
|
kube::util::ensure-temp-dir
|
||||||
TMP_GOPATH="${KUBE_TEMP}/go"
|
TMP_GOPATH="${KUBE_TEMP}/go"
|
||||||
|
|
Loading…
Reference in New Issue