Merge pull request #774 from devimc/topic/snap/fixLaunchpad

snap: make launchpad happy again
This commit is contained in:
Julio Montes
2019-11-01 10:07:32 -06:00
committed by GitHub

View File

@@ -1,16 +1,39 @@
name: kata-containers name: kata-containers
version: "master"
summary: Build lightweight VMs that seamlessly plug into the containers ecosystem summary: Build lightweight VMs that seamlessly plug into the containers ecosystem
description: | description: |
Kata Containers is an open source project and community working to build a Kata Containers is an open source project and community working to build a
standard implementation of lightweight Virtual Machines (VMs) that feel and standard implementation of lightweight Virtual Machines (VMs) that feel and
perform like containers, but provide the workload isolation and security perform like containers, but provide the workload isolation and security
advantages of VMs advantages of VMs
grade: stable
confinement: classic confinement: classic
adopt-info: metadata
parts: parts:
metadata:
plugin: nil
prime:
- -*
build-packages:
- git
- git-extras
override-pull: |
branch="master"
# kata CI or launchpad snap-master
if [ "${CI}" = "true" ] || echo "${SNAPCRAFT_IMAGE_INFO}" | egrep -o "build_url.*" | grep -q "${branch}"; then
snapcraftctl set-grade "devel"
else
# Get the latest stable version
runtime_url="https://github.com/kata-containers/runtime"
branch=$(git ls-remote --tags ${runtime_url} | egrep -o "refs.*" | egrep -v "\-alpha|\-rc|{}" | cut -d/ -f3 | sort -r | head -1)
snapcraftctl set-grade "stable"
fi
snapcraftctl set-version "${branch}"
echo "${branch}" | tee ${SNAPCRAFT_STAGE}/kata_version
yq: yq:
after: [metadata]
plugin: nil plugin: nil
prime: prime:
- -* - -*
@@ -41,8 +64,9 @@ parts:
go: go:
after: [yq] after: [yq]
override-build: | override-build: |
kata_version=$(cat ${SNAPCRAFT_STAGE}/kata_version)
yq=$(realpath ../../yq/build/yq) yq=$(realpath ../../yq/build/yq)
versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${SNAPCRAFT_PROJECT_VERSION}/versions.yaml versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${kata_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 curl -LO https://dl.google.com/go/go${version}.src.tar.gz
tar -xf go${version}.src.tar.gz --strip-components=1 tar -xf go${version}.src.tar.gz --strip-components=1
@@ -56,10 +80,11 @@ parts:
- -* - -*
runtime: runtime:
after: [go] after: [go, image]
plugin: nil plugin: nil
build-attributes: [no-patchelf] build-attributes: [no-patchelf]
override-build: | override-build: |
kata_version=$(cat ${SNAPCRAFT_STAGE}/kata_version)
pkg_name=runtime pkg_name=runtime
# set GOPATH # set GOPATH
@@ -71,7 +96,7 @@ parts:
mkdir -p ${pkg_gopath} mkdir -p ${pkg_gopath}
# download source # download source
git clone -b ${SNAPCRAFT_PROJECT_VERSION} https://github.com/kata-containers/${pkg_name} ${pkg_gopath} git clone -b ${kata_version} https://github.com/kata-containers/${pkg_name} ${pkg_gopath}
cd ${pkg_gopath} cd ${pkg_gopath}
# build and install # build and install
@@ -90,14 +115,20 @@ parts:
SKIP_GO_VERSION_CHECK=1 \ SKIP_GO_VERSION_CHECK=1 \
QEMUCMD=qemu-system-$arch QEMUCMD=qemu-system-$arch
# Set rootfs image by default if [ -e ${SNAPCRAFT_STAGE}/kata-containers.img ]; then
sed -i -e '/^initrd =/d' ${SNAPCRAFT_PART_INSTALL}/usr/share/defaults/${SNAPCRAFT_PROJECT_NAME}/configuration.toml # Use rootfs image by default
sed -i -e '/^initrd =/d' ${SNAPCRAFT_PART_INSTALL}/usr/share/defaults/${SNAPCRAFT_PROJECT_NAME}/configuration.toml
else
# Use initrd by default
sed -i -e '/^image =/d' ${SNAPCRAFT_PART_INSTALL}/usr/share/defaults/${SNAPCRAFT_PROJECT_NAME}/configuration.toml
fi
proxy: proxy:
after: [go] after: [go]
plugin: nil plugin: nil
build-attributes: [no-patchelf] build-attributes: [no-patchelf]
override-build: | override-build: |
kata_version=$(cat ${SNAPCRAFT_STAGE}/kata_version)
pkg_name=proxy pkg_name=proxy
# set GOPATH # set GOPATH
@@ -109,7 +140,7 @@ parts:
mkdir -p ${pkg_gopath} mkdir -p ${pkg_gopath}
# download source # download source
git clone -b ${SNAPCRAFT_PROJECT_VERSION} https://github.com/kata-containers/${pkg_name} ${pkg_gopath} git clone -b ${kata_version} https://github.com/kata-containers/${pkg_name} ${pkg_gopath}
cd ${pkg_gopath} cd ${pkg_gopath}
# build and install # build and install
@@ -121,6 +152,7 @@ parts:
plugin: nil plugin: nil
build-attributes: [no-patchelf] build-attributes: [no-patchelf]
override-build: | override-build: |
kata_version=$(cat ${SNAPCRAFT_STAGE}/kata_version)
pkg_name=shim pkg_name=shim
# set GOPATH # set GOPATH
@@ -132,7 +164,7 @@ parts:
mkdir -p ${pkg_gopath} mkdir -p ${pkg_gopath}
# download source # download source
git clone -b ${SNAPCRAFT_PROJECT_VERSION} https://github.com/kata-containers/${pkg_name} ${pkg_gopath} git clone -b ${kata_version} https://github.com/kata-containers/${pkg_name} ${pkg_gopath}
cd ${pkg_gopath} cd ${pkg_gopath}
# build and install # build and install
@@ -143,11 +175,16 @@ parts:
after: [go] after: [go]
plugin: nil plugin: nil
build-packages: build-packages:
- docker.io
- cpio - cpio
- git
- iptables
- software-properties-common
- uidmap
override-build: | override-build: |
kata_version=$(cat ${SNAPCRAFT_STAGE}/kata_version)
yq=$(realpath ../../yq/build/yq) yq=$(realpath ../../yq/build/yq)
pkg_name=osbuilder pkg_name=osbuilder
cni_plugings_repo="github.com/containernetworking/plugins"
# set GOPATH # set GOPATH
export GOPATH=$(realpath go) export GOPATH=$(realpath go)
@@ -157,41 +194,65 @@ parts:
# go was built in parts/go/build # go was built in parts/go/build
export GOROOT=$(realpath ../../go/build) export GOROOT=$(realpath ../../go/build)
export PATH="${GOROOT}/bin:${PATH}" export PATH="${GOROOT}/bin:${PATH}"
if [ -n "$http_proxy" ]; then
echo "Setting proxy $http_proxy" # install podman
sudo -E systemctl set-environment http_proxy=$http_proxy || true sudo add-apt-repository -y ppa:projectatomic/ppa
sudo -E systemctl set-environment https_proxy=$https_proxy || true sudo apt-get update
fi sudo apt-get -y install podman
# Build and install cni plugings
echo "Retrieve CNI plugins repository"
go get -d ${cni_plugings_repo} || true
cd $GOPATH/src/${cni_plugings_repo}
echo "Build CNI plugins"
./build_linux.sh
echo "Install CNI binaries"
cni_bin_path="/opt/cni"
sudo mkdir -p ${cni_bin_path}
sudo cp -a bin ${cni_bin_path}
# Copy yq binary. It's used in the container # Copy yq binary. It's used in the container
mkdir -p "${GOPATH}/bin/" mkdir -p "${GOPATH}/bin/"
cp -a "${yq}" "${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
echo "Adding $USER into docker group"
sudo -E gpasswd -a $USER docker
echo "Starting docker"
sudo -E systemctl start docker || true
# download source # download source
git clone -b ${SNAPCRAFT_PROJECT_VERSION} https://github.com/kata-containers/${pkg_name} ${pkg_gopath} git clone -b ${kata_version} https://github.com/kata-containers/${pkg_name} ${pkg_gopath}
cd ${pkg_gopath} cd ${pkg_gopath}
sudo -E PATH=$PATH make AGENT_VERSION=${SNAPCRAFT_PROJECT_VERSION} DISTRO=clearlinux AGENT_INIT=yes USE_DOCKER=1 image # build image
export AGENT_VERSION=${kata_version}
export AGENT_INIT=yes
export USE_PODMAN=1
export DEBUG=1
case "$(uname -m)" in
aarch64|ppc64le|s390x)
sudo -E PATH=$PATH DISTRO=alpine make initrd
;;
x86_64)
# In some build systems it's impossible to build a rootfs image, try with the initrd image
sudo -E PATH=$PATH DISTRO=clearlinux make image || sudo -E PATH=$PATH DISTRO=alpine make initrd
;;
*) echo "unsupported architecture: $(uname -m)"; exit 1;;
esac
# Install image
kata_image_dir=${SNAPCRAFT_PART_INSTALL}/usr/share/kata-containers kata_image_dir=${SNAPCRAFT_PART_INSTALL}/usr/share/kata-containers
mkdir -p ${kata_image_dir} mkdir -p ${kata_image_dir}
cp kata-containers.img ${kata_image_dir} cp kata-containers*.img ${kata_image_dir}
if [ -e kata-containers.img ]; then
touch ${SNAPCRAFT_STAGE}/kata-containers.img
else
touch ${SNAPCRAFT_STAGE}/kata-containers-initrd.img
fi
ksm-throttler: ksm-throttler:
after: [go] after: [go]
plugin: nil plugin: nil
build-attributes: [no-patchelf] build-attributes: [no-patchelf]
override-build: | override-build: |
kata_version=$(cat ${SNAPCRAFT_STAGE}/kata_version)
pkg_name=ksm-throttler pkg_name=ksm-throttler
# set GOPATH # set GOPATH
@@ -203,7 +264,7 @@ parts:
mkdir -p ${pkg_gopath} mkdir -p ${pkg_gopath}
# download source # download source
git clone -b ${SNAPCRAFT_PROJECT_VERSION} https://github.com/kata-containers/${pkg_name} ${pkg_gopath} git clone -b ${kata_version} https://github.com/kata-containers/${pkg_name} ${pkg_gopath}
cd ${pkg_gopath} cd ${pkg_gopath}
# build and install # build and install
@@ -280,11 +341,12 @@ parts:
- libcapstone-dev - libcapstone-dev
- bc - bc
override-build: | override-build: |
kata_version=$(cat ${SNAPCRAFT_STAGE}/kata_version)
yq=$(realpath ../../yq/build/yq) yq=$(realpath ../../yq/build/yq)
pkg_name="qemu" pkg_name="qemu"
configs_dir="${SNAPCRAFT_STAGE}/qemu/default-configs" configs_dir="${SNAPCRAFT_STAGE}/qemu/default-configs"
versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${SNAPCRAFT_PROJECT_VERSION}/versions.yaml versions_url=https://raw.githubusercontent.com/kata-containers/runtime/${kata_version}/versions.yaml
# arch-specific definition # arch-specific definition
case "$(uname -m)" in case "$(uname -m)" in
"aarch64") "aarch64")