Compare vendor with hack/versions and update hack/versions

Signed-off-by: Yanqiang Miao <miao.yanqiang@zte.com.cn>
This commit is contained in:
Yanqiang Miao 2017-12-14 15:57:22 +08:00
parent fe5a21d977
commit 0520ebc67a
2 changed files with 31 additions and 5 deletions

View File

@ -56,7 +56,7 @@ help:
@echo " * 'uninstall' - Remove installed binaries from system locations" @echo " * 'uninstall' - Remove installed binaries from system locations"
@echo " * 'version' - Print current cri-containerd release version" @echo " * 'version' - Print current cri-containerd release version"
verify: lint gofmt boiler verify: lint gofmt boiler deps-version
version: version:
@echo $(VERSION) @echo $(VERSION)
@ -73,6 +73,10 @@ boiler:
@echo "checking boilerplate" @echo "checking boilerplate"
@./hack/verify-boilerplate.sh @./hack/verify-boilerplate.sh
deps-version:
@echo "checking /hack/versions"
@./hack/update-vendor.sh -only-verify
$(BUILD_DIR)/cri-containerd: $(SOURCES) $(BUILD_DIR)/cri-containerd: $(SOURCES)
$(GO) build -o $@ \ $(GO) build -o $@ \
-tags '$(BUILD_TAGS)' \ -tags '$(BUILD_TAGS)' \

View File

@ -18,15 +18,37 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail 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 )"/.. ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/..
cd ${ROOT} cd ${ROOT}
echo "Sort vendor.conf..." echo "Sort vendor.conf..."
sort vendor.conf -o 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..." echo "Please commit the change made by this file..."