Skip to content

Commit

Permalink
Merge pull request #300 from jcvenegas/use-local-kernel-version
Browse files Browse the repository at this point in the history
kernel: build: Use local kernel version.
  • Loading branch information
Eric Ernst committed Jan 9, 2019
2 parents 8a3f7cf + 95fef54 commit a60cd13
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .ci/test.sh
Expand Up @@ -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
Expand Down
17 changes: 13 additions & 4 deletions kernel/build-kernel.sh
Expand Up @@ -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}"
Expand All @@ -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"

Expand Down Expand Up @@ -290,8 +296,11 @@ 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}"

case "${subcmd}" in
build)
build_kernel "${kernel_path}"
Expand Down
11 changes: 11 additions & 0 deletions kernel/build-kernel_test.sh
Expand Up @@ -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"
Expand All @@ -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"
}
Expand Down
2 changes: 1 addition & 1 deletion kernel/kata_config_version
@@ -1 +1 @@
21
22
16 changes: 10 additions & 6 deletions scripts/lib.sh
Expand Up @@ -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"
Expand Down

0 comments on commit a60cd13

Please sign in to comment.