From 2e93dbd737d004ccfc8f0a5e3777d6ce76eeeb8e Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Tue, 8 Jan 2019 15:23:12 -0600 Subject: [PATCH 1/4] kernel: build: Use local kernel version. If the runtime repository is already cloned get version from it, else keep getting from github. Fixes: #299 Signed-off-by: Jose Carlos Venegas Munoz --- kernel/build-kernel.sh | 17 +++++++++++++---- scripts/lib.sh | 16 ++++++++++------ 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/kernel/build-kernel.sh b/kernel/build-kernel.sh index c0105f420..72d3e8d86 100755 --- a/kernel/build-kernel.sh +++ b/kernel/build-kernel.sh @@ -145,7 +145,16 @@ get_default_kernel_config() { echo "${config}" } +get_config_and_patches() { + if [ -z "${patches_path}" ]; then + info "Clone config and patches" + patches_path="${default_patches_dir}" + [ -d "${patches_path}" ] || git clone "https://${patches_repo}.git" "${patches_repo_dir}" + fi +} + get_config_version() { + get_config_and_patches config_version_file="${default_patches_dir}/../kata_config_version" if [ -f "${config_version_file}" ]; then cat "${config_version_file}" @@ -172,10 +181,7 @@ setup_kernel() { [ -n "$kernel_path" ] || die "failed to find kernel source path" - if [ -z "${patches_path}" ]; then - patches_path="${default_patches_dir}" - [ -d "${patches_path}" ] || git clone "https://${patches_repo}.git" "${patches_repo_dir}" - fi + get_config_and_patches [ -d "${patches_path}" ] || die " patches path '${patches_path}' does not exist" @@ -292,6 +298,9 @@ main() { kernel_path="${PWD}/kata-linux-${kernel_version}-${config_version}" fi + info "Kernel version: ${kernel_version}" + info "Config version: ${config_version}" + case "${subcmd}" in build) build_kernel "${kernel_path}" diff --git a/scripts/lib.sh b/scripts/lib.sh index 732bb1f58..d86a2246f 100644 --- a/scripts/lib.sh +++ b/scripts/lib.sh @@ -35,12 +35,16 @@ get_from_kata_deps() { local branch="${2:-master}" local runtime_repo="github.com/kata-containers/runtime" GOPATH=${GOPATH:-${HOME}/go} - # This is needed in order to retrieve the version for qemu-lite - install_yq >&2 - yaml_url="https://raw.githubusercontent.com/kata-containers/runtime/${branch}/versions.yaml" - versions_file="versions_${branch}.yaml" - [ ! -e "${versions_file}" ] || download_on_new_flag="-z ${versions_file}" - curl --silent -o "${versions_file}" ${download_on_new_flag:-} "$yaml_url" + versions_file="${GOPATH}/src/github.com/kata-containers/runtime/versions.yaml" + if [ ! -e "${versions_file}" ]; then + yaml_url="https://raw.githubusercontent.com/kata-containers/runtime/${branch}/versions.yaml" + echo "versions file (${versions_file}) does not exist" >&2 + echo "Download from ${yaml_url}" >&2 + #make sure yq is installed + install_yq >&2 + versions_file="versions_${branch}.yaml" + curl --silent -o "${versions_file}" "$yaml_url" + fi result=$("${GOPATH}/bin/yq" read "$versions_file" "$dependency") [ "$result" = "null" ] && result="" echo "$result" From a5c2a2c8138753905cffc8bfb9df65f0b508cb61 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Tue, 8 Jan 2019 16:25:28 -0600 Subject: [PATCH 2/4] kernel: test: Fix detection on kernel changes. Kernele changes are not being detected, fix it. Signed-off-by: Jose Carlos Venegas Munoz --- .ci/test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.ci/test.sh b/.ci/test.sh index 6bf8f9bc3..9925642b1 100755 --- a/.ci/test.sh +++ b/.ci/test.sh @@ -19,7 +19,7 @@ make_target() { pushd "${script_dir}/.." >>/dev/null - if [ -n "${CI}" ] && ! git whatchanged origin/master..HEAD "${dir}" | grep "${dir}" >>/dev/null; then + if ! git diff --name-only origin/master..HEAD ${dir} | grep ${dir}; then echo "Not changes in ${dir}" return fi From 789970bc4303295ef3b1a6c0ca5d40b25702605a Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Tue, 8 Jan 2019 16:26:27 -0600 Subject: [PATCH 3/4] kernel: config: bump config Kernel dir changed. Depends-on:github.com/kata-containers/tests#1033 Signed-off-by: Jose Carlos Venegas Munoz --- kernel/kata_config_version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/kata_config_version b/kernel/kata_config_version index aabe6ec39..2bd5a0a98 100644 --- a/kernel/kata_config_version +++ b/kernel/kata_config_version @@ -1 +1 @@ -21 +22 From 95fef541c207c9060d3d765e6049ca3752c840a6 Mon Sep 17 00:00:00 2001 From: Jose Carlos Venegas Munoz Date: Wed, 9 Jan 2019 11:21:13 -0600 Subject: [PATCH 4/4] kernel: test: improve error handler print output from last command that failed. Signed-off-by: Jose Carlos Venegas Munoz --- kernel/build-kernel.sh | 2 +- kernel/build-kernel_test.sh | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/kernel/build-kernel.sh b/kernel/build-kernel.sh index 72d3e8d86..4284e4f63 100755 --- a/kernel/build-kernel.sh +++ b/kernel/build-kernel.sh @@ -296,10 +296,10 @@ main() { if [ -z "${kernel_path}" ]; then config_version=$(get_config_version) kernel_path="${PWD}/kata-linux-${kernel_version}-${config_version}" + info "Config version: ${config_version}" fi info "Kernel version: ${kernel_version}" - info "Config version: ${config_version}" case "${subcmd}" in build) diff --git a/kernel/build-kernel_test.sh b/kernel/build-kernel_test.sh index 1ff0bae65..8a4fb5a4d 100755 --- a/kernel/build-kernel_test.sh +++ b/kernel/build-kernel_test.sh @@ -7,6 +7,7 @@ set -o errexit set -o nounset set -o pipefail +set -o errtrace readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly build_kernel_sh="${script_dir}/build-kernel.sh" @@ -17,6 +18,16 @@ exit_handler() { } trap exit_handler EXIT +err_report() { + echo "Error:" + echo "line: $1" + echo "Last saved output:" + echo "${out:-}" +} + +trap 'err_report $LINENO' ERR + + OK() { echo "OK" }