snap: setup kernel using build-kernel.sh

Setup the kernel by hand is prone to errors.
Use `build-kernel.sh setup` to pull and setup the kata kernel.

fixes #438

Signed-off-by: Julio Montes <julio.montes@intel.com>
This commit is contained in:
Julio Montes 2019-07-08 15:35:42 +00:00
parent 335b8846ed
commit a0d0a20c98

View File

@ -206,65 +206,22 @@ parts:
TARGET=kata-ksm-throttler TARGET=kata-ksm-throttler
kernel: kernel:
override-pull: | after: [kernel-dump, scripts-dump, yq]
versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${SNAPCRAFT_PROJECT_VERSION}/versions.yaml plugin: nil
version="$(curl -sSL ${versions_url} | yq r - assets.kernel.version | tr -d v)"
url="$(curl -sSL ${versions_url} | yq r - assets.kernel.url)"
curl -LO ${url}/linux-${version}.tar.xz
tar -xf linux-${version}.tar.xz --strip-components=1
after: [kernel-dump]
plugin: kernel
build-packages: build-packages:
- libelf-dev - libelf-dev
- curl - curl
- build-essential - build-essential
- bison - bison
- flex - flex
build-snaps:
- yq
override-build: | override-build: |
versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${SNAPCRAFT_PROJECT_VERSION}/versions.yaml yq=$(realpath ../../yq/build/yq)
version="$(curl -sSL ${versions_url} | yq r - assets.kernel.version | tr -d v)"
x_version="$(echo $version | sed -e 's|.[[:digit:]]*$||').x"
case "$(uname -m)" in
"x86_64")
config="x86_64_kata_kvm_${x_version}"
;;
"ppc64le") # Say 'no' to everithing, fix issues with incomplete .config files
config="powerpc_kata_kvm_${x_version}" yes "n" | ${SNAPCRAFT_STAGE}/kernel/build-kernel.sh setup
;; kernel_dir_prefix="kata-linux-"
cd ${kernel_dir_prefix}*
"aarch64") version=$(basename ${PWD} | sed 's|'"${kernel_dir_prefix}"'||' | cut -d- -f1)
config="arm64_kata_kvm_${x_version}"
;;
"s390x")
config="s390_kata_kvm_${x_version}"
;;
*)
echo "ERROR: Unsupported architecture $(uname -m)"
exit 1
;;
esac
make mrproper
# Apply patches
for patch in ${SNAPCRAFT_STAGE}/kernel/patches/${x_version}/*.patch; do
echo "Applying $(basename "$patch") ..."
patch \
--batch \
--forward \
--strip 1 \
--input "$patch"
done
# Copy config file
cp ${SNAPCRAFT_STAGE}/kernel/configs/${config} .config
make -s oldconfig EXTRAVERSION=".container" > /dev/null
make -j $(($(nproc)-1)) EXTRAVERSION=".container" make -j $(($(nproc)-1)) EXTRAVERSION=".container"
kernel_suffix=${version}.container kernel_suffix=${version}.container
@ -289,6 +246,14 @@ parts:
prime: prime:
- -* - -*
scripts-dump:
source: scripts
plugin: dump
organize:
'*' : scripts/
prime:
- -*
qemu: qemu:
plugin: make plugin: make
after: [qemu-scripts-dump, qemu-lite-patches-dump, qemu-aarch64-patches-dump] after: [qemu-scripts-dump, qemu-lite-patches-dump, qemu-aarch64-patches-dump]