Merge pull request #626 from devimc/topic/snap/fixSnap

snap: fix and release new snap
This commit is contained in:
Salvador Fuentes
2019-07-10 13:46:14 -05:00
committed by GitHub
2 changed files with 79 additions and 86 deletions

View File

@@ -28,7 +28,7 @@ if [ "$SNAP_CI" == "true" ] && [ "$ID" == "ubuntu" ]; then
sudo -E PATH="$PATH" bash -c \
"make functional docker crio docker-compose network netmon \
docker-stability oci openshift kubernetes swarm \
entropy ramdisk shimv2 tracing"
entropy ramdisk tracing"
else
.ci/run.sh
fi

View File

@@ -1,5 +1,5 @@
name: kata-containers
version: "1.8.0-alpha0"
version: "1.8.0-rc0"
summary: Build lightweight VMs that seamlessly plug into the containers ecosystem
description: |
Kata Containers is an open source project and community working to build a
@@ -10,10 +10,40 @@ grade: stable
confinement: classic
parts:
go:
yq:
plugin: nil
prime:
- -*
build-packages:
- curl
override-build: |
yq_path="yq"
yq_pkg="github.com/mikefarah/yq"
goos="linux"
case "$(uname -m)" in
aarch64) goarch="arm64";;
ppc64le) goarch="ppc64le";;
x86_64) goarch="amd64";;
s390x) goarch="s390x";;
*) echo "unsupported architecture: $(uname -m)"; exit 1;;
esac
# Workaround to get latest release from github (to not use github token).
# Get the redirection to latest release on github.
yq_latest_url=$(curl -Ls -o /dev/null -w %{url_effective} "https://${yq_pkg}/releases/latest")
# The redirected url should include the latest release version
# https://github.com/mikefarah/yq/releases/tag/<VERSION-HERE>
yq_version=$(basename "${yq_latest_url}")
yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_${goos}_${goarch}"
curl -o "${yq_path}" -LSsf ${yq_url}
chmod +x ${yq_path}
go:
after: [yq]
override-build: |
yq=$(realpath ../../yq/build/yq)
versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${SNAPCRAFT_PROJECT_VERSION}/versions.yaml
version="$(curl -sSL ${versions_url} | yq r - languages.golang.version)"
version="$(curl -sSL ${versions_url} | ${yq} r - languages.golang.version)"
curl -LO https://dl.google.com/go/go${version}.src.tar.gz
tar -xf go${version}.src.tar.gz --strip-components=1
cd src && env GOROOT_BOOTSTRAP=$(go env GOROOT | tr -d '\n') ./make.bash
@@ -21,8 +51,6 @@ parts:
- golang-go
- g++
- curl
build-snaps:
- yq
plugin: nil
prime:
- -*
@@ -113,17 +141,20 @@ parts:
make install LIBEXECDIR=${SNAPCRAFT_PART_INSTALL}/usr/libexec
image:
source: http://github.com/kata-containers/osbuilder
source-type: git
after: [go]
plugin: make
plugin: nil
build-packages:
- docker.io
- cpio
override-build: |
yq=$(realpath ../../yq/build/yq)
pkg_name=osbuilder
# set GOPATH
export GOPATH=$(realpath go)
mkdir -p "${GOPATH}"
pkg_gopath=${GOPATH}/src/github.com/${SNAPCRAFT_PROJECT_NAME}/${pkg_name}
mkdir -p ${pkg_gopath}
# go was built in parts/go/build
export GOROOT=$(realpath ../../go/build)
export PATH="${GOROOT}/bin:${PATH}"
@@ -133,6 +164,10 @@ parts:
sudo -E systemctl set-environment https_proxy=$https_proxy || true
fi
# Copy yq binary. It's used in the container
mkdir -p "${GOPATH}/bin/"
cp -a "${yq}" "${GOPATH}/bin/"
echo "Unmasking docker service"
sudo -E systemctl unmask docker.service || true
sudo -E systemctl unmask docker.socket || true
@@ -143,8 +178,9 @@ parts:
echo "Starting docker"
sudo -E systemctl start docker || true
# use the same go version for all packages
sed -i 's|^GO_VERSION=.*|GO_VERSION='$(go version | cut -d' ' -f3 | tr -d go)'|g' rootfs-builder/versions.txt
# download source
git clone -b ${SNAPCRAFT_PROJECT_VERSION} https://github.com/kata-containers/${pkg_name} ${pkg_gopath}
cd ${pkg_gopath}
sudo -E PATH=$PATH make AGENT_VERSION=${SNAPCRAFT_PROJECT_VERSION} DISTRO=alpine AGENT_INIT=yes USE_DOCKER=1 initrd
@@ -178,65 +214,22 @@ parts:
TARGET=kata-ksm-throttler
kernel:
override-pull: |
versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${SNAPCRAFT_PROJECT_VERSION}/versions.yaml
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
after: [kernel-dump, scripts-dump, yq]
plugin: nil
build-packages:
- libelf-dev
- curl
- build-essential
- bison
- flex
build-snaps:
- yq
override-build: |
versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${SNAPCRAFT_PROJECT_VERSION}/versions.yaml
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}"
;;
yq=$(realpath ../../yq/build/yq)
"ppc64le")
config="powerpc_kata_kvm_${x_version}"
;;
"aarch64")
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
# Say 'no' to everithing, fix issues with incomplete .config files
yes "n" | ${SNAPCRAFT_STAGE}/kernel/build-kernel.sh setup
kernel_dir_prefix="kata-linux-"
cd ${kernel_dir_prefix}*
version=$(basename ${PWD} | sed 's|'"${kernel_dir_prefix}"'||' | cut -d- -f1)
make -j $(($(nproc)-1)) EXTRAVERSION=".container"
kernel_suffix=${version}.container
@@ -261,9 +254,17 @@ parts:
prime:
- -*
scripts-dump:
source: scripts
plugin: dump
organize:
'*' : scripts/
prime:
- -*
qemu:
plugin: make
after: [qemu-scripts-dump, qemu-lite-patches-dump, qemu-aarch64-patches-dump]
after: [scripts-dump, qemu-patches-dump, qemu-aarch64-patches-dump, yq]
build-packages:
- gcc
- python
@@ -278,26 +279,25 @@ parts:
- libfdt-dev
- curl
- libcapstone-dev
build-snaps:
- yq
override-build: |
yq=$(realpath ../../yq/build/yq)
pkg_name="qemu"
versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${SNAPCRAFT_PROJECT_VERSION}/versions.yaml
# arch-specific definition
case "$(uname -m)" in
"aarch64")
branch="$(curl -sSL ${versions_url} | yq r - assets.hypervisor.qemu.architecture.aarch64.branch)"
url="$(curl -sSL ${versions_url} | yq r - assets.hypervisor.qemu.url)"
commit="$(curl -sSL ${versions_url} | yq r - assets.hypervisor.qemu.architecture.aarch64.commit)"
branch="$(curl -sSL ${versions_url} | ${yq} r - assets.hypervisor.qemu.architecture.aarch64.branch)"
url="$(curl -sSL ${versions_url} | ${yq} r - assets.hypervisor.qemu.url)"
commit="$(curl -sSL ${versions_url} | ${yq} r - assets.hypervisor.qemu.architecture.aarch64.commit)"
patch_dir="${SNAPCRAFT_STAGE}/qemu-aarch64/patches/"
;;
*)
branch="$(curl -sSL ${versions_url} | yq r - assets.hypervisor.qemu-lite.branch)"
url="$(curl -sSL ${versions_url} | yq r - assets.hypervisor.qemu-lite.url)"
commit="$(curl -sSL ${versions_url} | yq r - assets.hypervisor.qemu-lite.commit)"
patch_dir="${SNAPCRAFT_STAGE}/qemu-lite/patches/"
branch="$(curl -sSL ${versions_url} | ${yq} r - assets.hypervisor.qemu.tag)"
url="$(curl -sSL ${versions_url} | ${yq} r - assets.hypervisor.qemu.url)"
patch_dir="${SNAPCRAFT_STAGE}/qemu/patches/4.0.x"
commit=""
;;
esac
@@ -305,7 +305,7 @@ parts:
pkg_repo_dir="${pkg_name}-repo"
git clone --branch ${branch} --single-branch ${url} "${pkg_repo_dir}"
cd ${pkg_repo_dir}
git checkout ${commit}
[ -z "${commit}" ] || git checkout ${commit}
[ -n "$(ls -A ui/keycodemapdb)" ] || git clone https://github.com/qemu/keycodemapdb ui/keycodemapdb/
[ -n "$(ls -A capstone)" ] || git clone https://github.com/qemu/capstone capstone
@@ -320,9 +320,9 @@ parts:
--input "$patch"
done
chmod +x ${SNAPCRAFT_STAGE}/qemu/scripts/configure-hypervisor.sh
chmod +x ${SNAPCRAFT_STAGE}/scripts/configure-hypervisor.sh
# static build
echo "$(${SNAPCRAFT_STAGE}/qemu/scripts/configure-hypervisor.sh -s qemu) \
echo "$(${SNAPCRAFT_STAGE}/scripts/configure-hypervisor.sh -s qemu) \
--disable-rbd
--prefix=/snap/${SNAPCRAFT_PROJECT_NAME}/current/usr \
--datadir=/snap/${SNAPCRAFT_PROJECT_NAME}/current/usr/share \
@@ -345,18 +345,11 @@ parts:
# Hack: move qemu to /
"snap/kata-containers/current/": "./"
qemu-scripts-dump:
source: scripts
qemu-patches-dump:
source: qemu/patches/
plugin: dump
organize:
'*' : qemu/scripts/
prime:
- -*
qemu-lite-patches-dump:
source: obs-packaging/qemu-lite/patches/
plugin: dump
organize:
'*' : qemu-lite/patches/
'*' : qemu/patches/
prime:
- -*
qemu-aarch64-patches-dump: