From 0520ebc67a05de07b105c89b0eca42cc23c6c6cb Mon Sep 17 00:00:00 2001 From: Yanqiang Miao Date: Thu, 14 Dec 2017 15:57:22 +0800 Subject: [PATCH] Compare vendor with hack/versions and update hack/versions Signed-off-by: Yanqiang Miao --- Makefile | 6 +++++- hack/update-vendor.sh | 30 ++++++++++++++++++++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 89d5149fe..bc12a5291 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ help: @echo " * 'uninstall' - Remove installed binaries from system locations" @echo " * 'version' - Print current cri-containerd release version" -verify: lint gofmt boiler +verify: lint gofmt boiler deps-version version: @echo $(VERSION) @@ -73,6 +73,10 @@ boiler: @echo "checking boilerplate" @./hack/verify-boilerplate.sh +deps-version: + @echo "checking /hack/versions" + @./hack/update-vendor.sh -only-verify + $(BUILD_DIR)/cri-containerd: $(SOURCES) $(GO) build -o $@ \ -tags '$(BUILD_TAGS)' \ diff --git a/hack/update-vendor.sh b/hack/update-vendor.sh index 9f20cf35f..44703594e 100755 --- a/hack/update-vendor.sh +++ b/hack/update-vendor.sh @@ -18,15 +18,37 @@ set -o errexit set -o nounset set -o pipefail -# This is a temporary hack, rewrite all `github.com/Sirupsen/logrus` to -# lower case. -# TODO(random-liu): Remove this after #106 is resolved. ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/.. cd ${ROOT} echo "Sort vendor.conf..." sort vendor.conf -o vendor.conf -# TODO(random-liu): Compare vendor with hack/versions. +echo "Compare vendor with hack/versions..." +need_update=false +declare -A map=() +map["RUNC_VERSION"]="github.com/opencontainers/runc" +map["CNI_VERSION"]="github.com/containernetworking/cni" +map["CONTAINERD_VERSION"]="github.com/containerd/containerd" +map["KUBERNETES_VERSION"]="k8s.io/kubernetes" +for key in ${!map[@]} +do + vendor_commitid=$(grep ${map[${key}]} vendor.conf | awk '{print $2}') + version_commitid=$(grep ${key} hack/versions | awk -F "=" '{print $2}') + if [ ${vendor_commitid} != ${version_commitid} ]; then + if [ $# -gt 0 ] && [ ${1} = "-only-verify" ]; then + need_update=true + echo "Need to update the value of ${key} from ${version_commitid} to ${vendor_commitid}." + else + echo "Updating the value of ${key} from ${version_commitid} to ${vendor_commitid}." + sed -i "s/${version_commitid}/${vendor_commitid}/g" hack/versions + fi + fi +done + +if [ ${need_update} = true ]; then + echo "Please update \"hack/versions\" by executing \"hack/update-vendor.sh\"!" + exit 1 +fi echo "Please commit the change made by this file..."