From dfddde813dfbca3dc64a6f1b5efd2688c65a52fe Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Thu, 26 Jul 2018 17:03:15 -0500 Subject: [PATCH] lib: move build_hub to lib hub will be used by other script move it. Signed-off-by: Jose Carlos Venegas Munoz --- release/update-repository-version.sh | 28 ++-------------------------- scripts/lib.sh | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 26 deletions(-) diff --git a/release/update-repository-version.sh b/release/update-repository-version.sh index bec22e597a..6506529b4f 100755 --- a/release/update-repository-version.sh +++ b/release/update-repository-version.sh @@ -13,42 +13,18 @@ readonly script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" readonly script_name="$(basename "${BASH_SOURCE[0]}")" readonly tmp_dir=$(mktemp -t -d pr-bump.XXXX) -readonly hub_bin="${tmp_dir}/hub-bin" readonly organization="kata-containers" PUSH="false" GOPATH=${GOPATH:-${HOME}/go} +source "${script_dir}/../scripts/lib.sh" + cleanup (){ [ -d "${tmp_dir}" ] && rm -rf "${tmp_dir}" } trap cleanup EXIT -die() -{ - msg="$*" - echo "ERROR: ${msg}" >&2 - exit 1 -} - -info() -{ - msg="$*" - echo "INFO: ${msg}" >&2 -} - -build_hub() { - info "Get hub" - local hub_repo="github.com/github/hub" - local hub_repo_dir="${GOPATH}/src/${hub_repo}" - [ -d "${hub_repo_dir}" ]|| git clone --quiet --depth 1 "https://${hub_repo}.git" "${hub_repo_dir}" - pushd "${hub_repo_dir}" >> /dev/null - git checkout master - git pull - ./script/build -o "${hub_bin}" - popd >> /dev/null -} - get_changes() { local current_version=$1 [ -n "${current_version}" ] || die "current version not provided" diff --git a/scripts/lib.sh b/scripts/lib.sh index 864706e0d5..b1a02e82d6 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -1,4 +1,6 @@ +export GOPATH=${GOPATH:-${HOME}/go} readonly kata_arch_sh="${GOPATH}/src/github.com/kata-containers/tests/.ci/kata-arch.sh" +hub_bin="${tmp_dir}/hub-bin" get_kata_arch(){ go get -u github.com/kata-containers/tests || true @@ -61,3 +63,21 @@ get_repo_hash(){ popd >> /dev/null } +build_hub() { + info "Get hub" + + if cmd=$(command -v hub); then + hub_bin="${cmd}" + return + fi + + local hub_repo="github.com/github/hub" + local hub_repo_dir="${GOPATH}/src/${hub_repo}" + [ -d "${hub_repo_dir}" ]|| git clone --quiet --depth 1 "https://${hub_repo}.git" "${hub_repo_dir}" + pushd "${hub_repo_dir}" >> /dev/null + git checkout master + git pull + ./script/build -o "${hub_bin}" + popd >> /dev/null +} +