From c7225fe0c836569a4caadb39709e5ccc525ab29e Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Mon, 15 Apr 2019 19:19:37 -0500 Subject: [PATCH] obs: Remove golang from osc dockerfile Reduce pipeline time by not installing golang. golang is not needed to use osc, it makes slower the image creation. - remove go dependency from pacakge lib Remove calls to golang, this will be not not installed in the docker image. Signed-off-by: Jose Carlos Venegas Munoz --- obs-packaging/Dockerfile | 13 ------------- obs-packaging/gen_versions_txt.sh | 3 ++- obs-packaging/scripts/pkglib.sh | 28 ++++++++++++++++++++-------- scripts/lib.sh | 13 +++++++++++++ 4 files changed, 35 insertions(+), 22 deletions(-) diff --git a/obs-packaging/Dockerfile b/obs-packaging/Dockerfile index be75723f88..1f6dd07666 100644 --- a/obs-packaging/Dockerfile +++ b/obs-packaging/Dockerfile @@ -1,8 +1,6 @@ FROM opensuse:leap -ARG GO_VERSION=${GO_VERSION:-1.10.2} ARG SUSE_VERSION=${SUSE_VERSION:-42.3} -ARG GO_ARCH=${GO_ARCH:-amd64} # Get OBS client, plugins and dependencies RUN zypper -v -n install osc-plugin-install vim curl bsdtar git sudo @@ -15,14 +13,3 @@ RUN zypper -v -n install build \ obs-service-obs_scm \ obs-service-recompress \ obs-service-download_url - -# Set Go environment -RUN curl -OL https://dl.google.com/go/go${GO_VERSION}.linux-${GO_ARCH}.tar.gz -RUN tar -C /usr/local -xzf go${GO_VERSION}.linux-${GO_ARCH}.tar.gz - -# Local build dependencies -RUN zypper -v -n install make gcc yum xz pcre-tools - -# Add go compiler to the PATH -ENV PATH /usr/local/go/bin:$PATH -ENV GOPATH /root/go diff --git a/obs-packaging/gen_versions_txt.sh b/obs-packaging/gen_versions_txt.sh index 2426334aeb..09d96cafc3 100755 --- a/obs-packaging/gen_versions_txt.sh +++ b/obs-packaging/gen_versions_txt.sh @@ -14,10 +14,11 @@ readonly script_name="$(basename "${BASH_SOURCE[0]}")" readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly versions_txt="versions.txt" project="kata-containers" -ARCH=${ARCH:-$(go env GOARCH)} source "${script_dir}/../scripts/lib.sh" +ARCH=${ARCH:-$(arch_to_golang "$(uname -m)")} + get_kata_version() { local branch="$1" curl -SsL "https://raw.githubusercontent.com/${project}/runtime/${branch}/VERSION" diff --git a/obs-packaging/scripts/pkglib.sh b/obs-packaging/scripts/pkglib.sh index 014140484a..d9e15a4062 100644 --- a/obs-packaging/scripts/pkglib.sh +++ b/obs-packaging/scripts/pkglib.sh @@ -3,7 +3,10 @@ # This is a helper library for the setup scripts of each package # in this repository. -source ../versions.txt +source_dir_pkg_lib=$(dirname "${BASH_SOURCE[ ${#BASH_SOURCE[@]} - 1 ]}") +source "${source_dir_pkg_lib}/../../scripts/lib.sh" +source "${source_dir_pkg_lib}/../versions.txt" + PACKAGING_DIR=/var/packaging LOG_DIR=${PACKAGING_DIR}/build_logs @@ -21,19 +24,28 @@ LOCAL_BUILD=false OBS_PUSH=false VERBOSE=false +arch_to_golang() +{ + local -r arch="$1" + + case "$arch" in + aarch64) echo "arm64";; + ppc64le) echo "$arch";; + x86_64) echo "amd64";; + s390x) echo "s390x";; + *) die "unsupported architecture: $arch";; + esac +} # Used for debian.control files # Architecture: The architecture specifies which type of hardware this # package was compiled for. -DEB_ARCH="$(go env GOARCH)" short_commit_length=10 -if command -v go; then - export GO_ARCH=$(go env GOARCH) -else - export GO_ARCH=amd64 - echo "Go not installed using $GO_ARCH to install go in dockerfile" -fi +arch=$(uname -m) +DEB_ARCH=$(arch_to_golang "$arch") +GO_ARCH=$(arch_to_golang "$arch") +export GO_ARCH function display_help() { cat <<-EOL diff --git a/scripts/lib.sh b/scripts/lib.sh index 2f2e3ff618..87a72a2ec9 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -95,3 +95,16 @@ get_kata_hash_from_tag() { repo=$1 git ls-remote --tags "https://github.com/${project}/${repo}.git" | grep "refs/tags/${kata_version}^{}" | awk '{print $1}' } + +arch_to_golang() +{ + local -r arch="$1" + + case "$arch" in + aarch64) echo "arm64";; + ppc64le) echo "$arch";; + x86_64) echo "amd64";; + s390x) echo "s390x";; + *) die "unsupported architecture: $arch";; + esac +}