packaging: Revert "packaging: Stop providing OBS packages"

This reverts commit c0ea910273.

Two scripts are still required for release and testing, which should
have never been under obs-packaging dir in the first place.  Let's
revert, move the scripts / update references to it, and then we can
remove the remaining obs-packaging/ tooling.

Signed-off-by: Eric Ernst <eric.g.ernst@gmail.com>
This commit is contained in:
Eric Ernst 2020-10-06 08:46:39 -07:00 committed by Eric Ernst
parent 13e260a864
commit 3f6cd4d5f7
53 changed files with 6027 additions and 0 deletions

View File

@ -1,6 +1,7 @@
# Kata Containers packaging
* [Introduction](#introduction)
* [Build using OBS](#build-using-obs)
* [Build in a container](#build-in-a-container)
* [Build a snap package](#build-a-snap-package)
* [Build static binaries](#build-static-binaries)
@ -17,6 +18,10 @@
Kata Containers currently supports packages for many distributions. Tooling to
aid in creating these packages are contained within this repository.
## Build using OBS
See the [OBS documentation](obs-packaging).
## Build in a container
Kata build artifacts are available within a container image, created by a

View File

@ -0,0 +1,12 @@
ARG SUSE_VERSION=${SUSE_VERSION:-15.1}
FROM opensuse/leap:${SUSE_VERSION}
# Get OBS client, plugins and dependencies
RUN zypper -v -n install osc-plugin-install vim curl bsdtar git sudo
RUN zypper -v -n install build \
obs-service-tar_scm \
obs-service-verify_file \
obs-service-obs_scm \
obs-service-recompress \
obs-service-download_url

View File

@ -0,0 +1,8 @@
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
clean:
find . -maxdepth 2 -type d -name '*home:katacontainers*' -prune -exec sudo rm -rf {} \;

View File

@ -0,0 +1,11 @@
# Building under OBS
SUSE's [Open Build Service (OBS)](https://openbuildservice.org) is used to
build [the official Kata Containers packages](https://build.opensuse.org/project/subprojects/home:katacontainers).
This directory contains tooling and packaging metadata to build all Kata
components with OBS.
See
[the Kata installation documentation](../../../docs/install/README.md)
for instructions on how to install the official packages.

View File

@ -0,0 +1,105 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
[ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
readonly script_name="$(basename "${BASH_SOURCE[0]}")"
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
# shellcheck source=scripts/obs-docker.sh
source "${script_dir}/scripts/obs-pkgs.sh"
PUSH=${PUSH:-""}
LOCAL=${LOCAL:-""}
export BUILD_DISTROS=${BUILD_DISTROS:-xUbuntu_16.04}
# Packaging use this variable instead of use git user value
# On CI git user is not set
export AUTHOR="${AUTHOR:-user}"
export AUTHOR_EMAIL="${AUTHOR_EMAIL:-user@example.com}"
die() {
local msg="${1:-}"
local print_usage=$"${2:-}"
if [ -n "${msg}" ]; then
echo -e "ERROR: ${msg}\n"
fi
[ -n "${print_usage}" ] && usage 1
}
usage() {
exit_code=$"${1:-0}"
cat <<EOT
Usage:
${script_name} [-h | --help] <kata-branch> [PROJ1 PROJ2 ... ]
Generate OBS packages sources for the kata projects, based on branch
kata-branch.
${script_name} processes all the kata projects by default; alternatively you can
specify a subset of the projects as additional arguments.
Environment variables:
PUSH When set, push the packages sources to the openSUSE build
service.
LOCAL When set, build the packages locally.
EOT
exit "${exit_code}"
}
main() {
case "${1:-}" in
"-h"|"--help")
usage
;;
-*)
die "Invalid option: ${1:-}" "1"
;;
"")
die "missing branch" "1"
;;
*)
branch="${1:-}"
;;
esac
shift
local projectsList=("$@")
[ "${#projectsList[@]}" = "0" ] && projectsList=("${OBS_PKGS_PROJECTS[@]}")
# Make sure runtime is the last project
projectsList=($(echo "${projectsList[@]}" | sed -E "s/(^.*)(runtime)(.*$)/\1 \3 \2/"))
pushd "${script_dir}" >>/dev/null
local compare_result="$(./gen_versions_txt.sh --compare ${branch})"
[[ "$compare_result" =~ different ]] && die "$compare_result -- you need to run gen_versions_txt.sh"
for p in "${projectsList[@]}"; do
[ -d "$p" ] || die "$p is not a valid project directory"
update_cmd="./update.sh"
if [ -n "${PUSH}" ]; then
# push to obs
update_cmd+=" -p"
elif [ -n "${LOCAL}" ]; then
# local build
update_cmd+=" -l"
fi
echo "======= Updating ${p} ======="
pushd "$p" >>/dev/null
bash -c "${update_cmd} ${branch}"
popd >>/dev/null
echo ""
done
popd >> /dev/null
}
main $@

View File

@ -0,0 +1,68 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
[ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
script_dir=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
script_name="$(basename "${BASH_SOURCE[0]}")"
#where packaing repo lives
packaging_repo_dir=$(cd "${script_dir}/.." && pwd)
export USE_DOCKER=1
http_proxy=${http_proxy:-}
https_proxy=${https_proxy:-}
no_proxy=${no_proxy:-}
PUSH=${PUSH:-}
BUILD_HEAD="${BUILD_HEAD:-false}"
# shellcheck source=scripts/obs-docker.sh
source "${script_dir}/scripts/obs-docker.sh"
GO_ARCH=$(go env GOARCH)
export GO_ARCH
usage() {
msg="${1:-}"
exit_code=$"${2:-0}"
cat <<EOT
${msg}
Usage:
${script_name} <kata-branch>
EOT
exit "${exit_code}"
}
get_image() {
pushd "${script_dir}/kata-containers-image/"
local branch="${1:-}"
if [ -z "${branch}" ]; then
echo "branch not provided"
return 1
fi
if [ ${BUILD_HEAD} = "false" ] && "${script_dir}/download_image.sh" "${branch}"; then
echo "OK image downloaded"
find . -name 'kata-containers-'"${branch}"'-*.tar.gz' || die "Failed to find downloaded image"
return 0
fi
echo "Building image"
"${script_dir}/../obs-packaging/kata-containers-image/build_image.sh" -v "${branch}"
find . -name 'kata-containers-'"${branch}"'-*.tar.gz' || die "built image not found"
popd
}
main() {
local branch="${1:-}"
[ -n "${branch}" ] || usage "missing branch" "1"
#Build all kata packages
make -f "${script_dir}/Makefile" clean
get_image "${branch}"
docker_run "${packaging_repo_dir}/obs-packaging/build_all.sh ${branch}"
}
main "$@"

View File

@ -0,0 +1,191 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
[ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
script_dir=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
script_name="$(basename "${BASH_SOURCE[0]}")"
# shellcheck source=./../scripts/lib.sh
source "${script_dir}/../scripts/lib.sh"
# shellcheck source=scripts/obs-docker.sh
source "${script_dir}/scripts/obs-docker.sh"
readonly home_project="home:katacontainers"
readonly template_pkg="kata-pkg-template"
arch_target=${ARCH:-$(uname -m)}
# shellcheck source=scripts/obs-docker.sh
source "${script_dir}/scripts/obs-pkgs.sh"
pkg_exist() {
local project="$1"
local pkg="$2"
docker_run osc list "${project}" | grep "${pkg}" || return 1
return 0
}
# Array of repositories.
#
# Each element is comprised of multiple parts in the form:
#
# name::project::repository
#
typeset -a repos
read_repos(){
while read -r p; do
[[ "$p" != "#"* ]] || continue
repos+=("${p}")
echo "Adding distro: ${p}"
done < "${script_dir}/distros_${arch_target}"
}
# Array of maintainers
#
# Each element is comprised of multiple parts in the form:
#
# userid::role
#
typeset -a maintainers
read_maintainers(){
while read -r p; do
[[ "$p" != "#"* ]] || continue
maintainers+=("${p}::maintainer")
echo "Adding maintainer: ${p}"
done < "${script_dir}/maintainers"
}
create_repos_xml_nodes() {
for entry in "${repos[@]}"; do
[ -z "$entry" ] && die "found empty entry"
local name
local project
local repositories
name=$(echo "$entry" | awk -F"::" '{print $1;}')
project=$(echo "$entry" | awk -F"::" '{print $2;}')
repositories=$(echo "$entry" | awk -F"::" '{print $3;}')
[ -z "$name" ] && die "no name for entry '$entry'"
[ -z "$project" ] && die "no project for entry '$entry'"
[ -z "$repositories" ] && die "no repository for entry '$entry'"
echo " <repository name=\"${name}\">"
echo "${repositories}"| tr ',' '\n' | while read -r repository; do
echo " <path project=\"${project}\" repository=\"${repository}\"/>"
done
arch_target_obs=${arch_target}
if [ "$arch_target" == "ppc64" ]; then
arch_target_obs="ppc64le"
fi
echo " <arch>${arch_target_obs}</arch>"
echo " </repository>"
done
}
create_maintainers_xml_nodes() {
for entry in "${maintainers[@]}"; do
[ -z "$entry" ] && die "found empty entry"
local userid=$(echo "$entry" | awk -F"::" '{print $1;}')
local role=$(echo "$entry" | awk -F"::" '{print $2;}')
[ -z "$userid" ] && die "no userid for entry '$entry'"
[ -z "$role" ] && die "no role for entry '$entry'"
echo " <person userid=\"${userid}\" role=\"${role}\"/>"
done
}
create_publish_xml_node() {
# publishing is enabled by default, so only update the config
# when we want to disable publishing
if [ "${publish_repo:-true}" == "false" ];then
echo " <publish>"
echo " <disable/>"
echo " </publish>"
fi
}
create_meta_xml() {
project="${1:-}"
branch="${2:-}"
publish_repo="${3:-true}"
[ -n "${project}" ] || die "project is empty"
[ -n "${branch}" ] || die "branch is empty"
read_maintainers
read_repos
cat >meta_project.xml <<EOT
<project name="${project}">
<title>Branch project for Kata Containers branch ${branch}</title>
<description>This project is the Kata Containers branch ${branch}</description>
$(create_publish_xml_node)
$(create_maintainers_xml_nodes)
$(create_repos_xml_nodes)
</project>
EOT
}
usage() {
msg="${1:-}"
exit_code=$"${2:-0}"
cat <<EOT
${msg}
Usage:
${script_name} <kata-branch>
EOT
exit "${exit_code}"
}
main() {
case "${1:-}" in
"-h"|"--help")
usage Help
;;
--ci)
create_ci_subproject=true
publish_repo=false
shift
;;
-*)
die "Invalid option: ${1:-}"
;;
esac
local branch="${1:-}"
[ -n "${branch}" ] || usage "missing branch" "1"
if [ "${create_ci_subproject:-false}" == "true" ];then
release_type="ci"
elif [ "$arch_target" == "ppc64le" ]; then
release_type="alpha"
else
release_type="releases"
fi
project_branch="${home_project}:${release_type}:${arch_target}:${branch}"
create_meta_xml "${project_branch}" "${branch}" "${publish_repo}"
info "Creating/Updating project with name ${project_branch}"
# Update /Create project metadata.
docker_run osc meta prj "${project_branch}" -F meta_project.xml
docker_run osc meta prjconf "${project_branch}" -F projectconfig
for pkg in "${OBS_PKGS_PROJECTS[@]}"; do
if ! pkg_exist "${project_branch}" "${pkg}"; then
echo "Package ${pkg} does not exit in ${project_branch}, creating ..."
docker_run osc branch "${home_project}" "${template_pkg}" "${project_branch}" "${pkg}"
fi
pkg_dir="${project_branch}/${pkg}"
[ -d "${pkg_dir}/.osc" ] || docker_run osc co "${pkg_dir}"
done
}
main $@

View File

@ -0,0 +1,12 @@
# Repositories.
#
# Each element is comprised of multiple parts in the form:
#
# name::project::repository
#
CentOS_7::CentOS:CentOS-7::standard
Fedora_30::Fedora:30::standard
SLE_12_SP3::SUSE:SLE-12-SP3:GA::standard
openSUSE_Leap_15.0::openSUSE:Leap:15.0:Ports::ports
xUbuntu_16.04::Ubuntu:16.04:Ports::universe,update
xUbuntu_18.04::Ubuntu:18.04:Ports::universe

View File

@ -0,0 +1,20 @@
# Repositories.
#
# Each element is comprised of multiple parts in the form:
#
# name::project::repository
#
CentOS_7::CentOS:CentOS-7::standard
CentOS_8::CentOS:CentOS-8::standard
Debian_9::Debian:9.0::standard
# Qemu vanilla is broken see https://github.com/kata-containers/packaging/issues/1051
#Debian_10::Debian:10::standard
Fedora_30::Fedora:30::standard
# FIXME: https://github.com/kata-containers/packaging/issues/510
#RHEL_7::RedHat:RHEL-7::standard
SLE_15_SP1::SUSE:SLE-15-SP1:GA::standard
openSUSE_Leap_15.1::openSUSE:Leap:15.1::standard
openSUSE_Tumbleweed::openSUSE:Factory::snapshot
xUbuntu_16.04::Ubuntu:16.04::universe,universe-update,update
xUbuntu_18.04::Ubuntu:18.04::universe
xUbuntu_20.04::Ubuntu:20.04::universe

View File

@ -0,0 +1,53 @@
#!/bin/bash
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
set -o errexit
set -o nounset
set -o pipefail
set -o errtrace
script_dir=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
source "${script_dir}/scripts/obs-docker.sh"
source "${script_dir}/scripts/pkglib.sh"
handle_error() {
local exit_code="${?}"
local line_number="${1:-}"
echo "Failed at $line_number: ${BASH_COMMAND}"
exit "${exit_code}"
}
trap 'handle_error $LINENO' ERR
die() {
echo >&2 "ERROR: $*"
exit 1
}
BRANCH=${1:-master}
agent_repository="https://github.com/kata-containers/agent.git"
kata_version_url="https://raw.githubusercontent.com/kata-containers/runtime/${BRANCH}/VERSION"
echo "Download kata image from branch ${BRANCH}"
if ! version=$(curl -s --fail -L "${kata_version_url}"); then
die "failed to get version from branch ${BRANCH}"
fi
if ! out=$(git ls-remote "${agent_repository}"); then
die "failed to query agent git repo"
fi
if ! tag_info=$(echo "$out" | grep "${version}^{}"); then
die "failed to find version info $version: ${out}"
fi
commit=$(echo "$tag_info" | awk '{print $1}')
echo "$commit"
agent_repository="github.com/kata-containers/agent"
tarball_name="kata-containers-${version}-${commit:0:${short_commit_length}}-$(uname -m).tar.gz"
image_url="https://${agent_repository}/releases/download/${version}/${tarball_name}"
#curl -OL "${image_url}"
#tar xvf "${tarball_name}"

View File

@ -0,0 +1,188 @@
#!/bin/bash
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
[ -z "${DEBUG}" ] || set -x
set -e
set -o errexit
set -o nounset
set -o pipefail
readonly script_name="$(basename "${BASH_SOURCE[0]}")"
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly versions_txt="versions.txt"
project="kata-containers"
source "${script_dir}/../scripts/lib.sh"
ARCH=${ARCH:-$(arch_to_golang "$(uname -m)")}
get_kata_version() {
cat "${script_dir}/../../../VERSION"
}
gen_version_file() {
local branch="$1"
local kata_version="$2"
local ref="refs/heads/${branch}"
if [ "${kata_version}" == "HEAD" ]; then
kata_version="${branch}"
ref="refs/heads/${branch}"
else
ref="refs/tags/${kata_version}^{}"
fi
qemu_vanilla_branch=$(get_from_kata_deps "assets.hypervisor.qemu.version" "${kata_version}")
# Check if qemu.version can be used to get the version and hash, otherwise use qemu.tag
qemu_vanilla_ref="refs/heads/${qemu_vanilla_branch}"
if ! (git ls-remote --heads "https://github.com/qemu/qemu.git" | grep -q "refs/heads/${qemu_vanilla_branch}"); then
qemu_vanilla_branch=$(get_from_kata_deps "assets.hypervisor.qemu.tag" "${kata_version}")
qemu_vanilla_ref="refs/tags/${qemu_vanilla_branch}^{}"
fi
qemu_vanilla_version=$(curl -s -L "https://raw.githubusercontent.com/qemu/qemu/${qemu_vanilla_branch}/VERSION")
qemu_vanilla_hash=$(git ls-remote https://github.com/qemu/qemu.git | grep "${qemu_vanilla_ref}" | awk '{print $1}')
kernel_version=$(get_from_kata_deps "assets.kernel.version" "${kata_version}")
#Remove extra 'v'
kernel_version=${kernel_version#v}
golang_version=$(get_from_kata_deps "languages.golang.meta.newest-version" "${kata_version}")
# - is not a valid char for rpmbuild
# see https://github.com/semver/semver/issues/145
kata_version=$(get_kata_version)
kata_version=${kata_version/-/\~}
cat > "$versions_txt" <<EOT
# This is a generated file from ${script_name}
kata_version=${kata_version}
# Dependencies
kata_osbuilder_version=${kata_version}
qemu_vanilla_version=${qemu_vanilla_version}
qemu_vanilla_hash=${qemu_vanilla_hash}
kernel_version=${kernel_version}
# Golang
go_version=${golang_version}
EOT
}
die() {
local msg="${1:-}"
local print_usage=$"${2:-}"
if [ -n "${msg}" ]; then
echo -e "ERROR: ${msg}\n"
fi
[ -n "${print_usage}" ] && usage 1
}
usage() {
exit_code=$"${1:-0}"
cat <<EOT
Usage:
${script_name} [--compare | -h | --help] <kata-branch>
Generate a ${versions_txt} file, containing version numbers and commit hashes
of all the kata components under the git branch <kata-branch>.
Options:
-h, --help Print this help.
--compare Only compare the kata version at branch <kata-branch> with the
one in ${versions_txt} and leave the file untouched.
--head Use <kata-branch>'s head to generate the versions file.
EOT
exit "${exit_code}"
}
main() {
local compareOnly=
local use_head=
local use_tag=
case "${1:-}" in
"-h"|"--help")
usage
;;
--compare)
compareOnly=1
shift
;;
--head)
use_head=1
shift
;;
--tag)
use_tag=1
shift
;;
-*)
die "Invalid option: ${1:-}" "1"
shift
;;
esac
local kata_version=
if [ -n "$use_tag" ]; then
if [ -n "${use_head}" ]; then
die "tag and head options are mutually exclusive"
fi
# We are generating versions based on the provided tag
local tag="${1:-}"
[ -n "${tag}" ] || die "No tag specified" "1"
# use the runtime's repository to determine branch information
local repo="github.com/kata-containers/kata-containers"
local repo_dir="kata-containers"
git clone --quiet "https://${repo}.git" "${repo_dir}"
pushd "${repo_dir}" >> /dev/null
local branch=$(git branch -r -q --contains "${tag}" | grep -E "master|stable|2.0-dev" | grep -v HEAD)
popd >> /dev/null
rm -rf ${repo_dir}
[ -n "${branch}" ] || die "branch for tag ${tag} not found"
# in the event this is on master as well as stable, or multiple stables, just pick the first branch
# (ie, 1.8.0-alpha0 may live on stable-1.8 as well as master: we'd just use master in this case)
branch=$(echo ${branch} | awk -F" " '{print $1}')
# format will be origin/<branch-name> - let's drop origin:
branch=$(echo ${branch} | awk -F"/" '{print $2}')
echo "generating versions for tag ${tag} which is on branch ${branch}"
kata_version=${tag}
else
local branch="${1:-}"
[ -n "${branch}" ] || die "No branch specified" "1"
if [ -n "${use_head}" ]; then
kata_version="HEAD"
else
kata_version=$(get_kata_version)
fi
fi
if [ -n "$compareOnly" ]; then
source "./${versions_txt}" || exit 1
kata_version=${kata_version/\~/-}
[ -n "${kata_version}" ] || die "${version_file} does not contain a valid kata_version variable"
# Replacing ~ with -, as - is not a valid char for rpmbuild
# see https://github.com/semver/semver/issues/145
[ "$(get_kata_version)" = "${kata_version/\~/-}" ] && compare_result="matches" || compare_result="is different from"
echo "${kata_version} in ${versions_txt} ${compare_result} the version at branch ${branch}"
return
fi
gen_version_file "${branch}" "${kata_version}"
}
main $@

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,120 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
[ -z "${DEBUG}" ] || set -x
set -o errexit
set -o nounset
set -o pipefail
readonly script_name="$(basename "${BASH_SOURCE[0]}")"
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly tmp_dir=$(mktemp -d -t build-image-tmp.XXXXXXXXXX)
export GOPATH="${tmp_dir}/go"
export GOPATH=${GOPATH:-${HOME}/go}
source "${script_dir}/../../scripts/lib.sh"
source "${script_dir}/../scripts/pkglib.sh"
exit_handler() {
[ -d "${tmp_dir}" ] && sudo rm -rf "$tmp_dir"
}
trap exit_handler EXIT
arch_target="$(uname -m)"
source "${script_dir}/../versions.txt"
readonly destdir="${PWD}"
build_initrd() {
sudo -E PATH="$PATH" make initrd \
DISTRO="$initrd_distro" \
DEBUG="${DEBUG:-}" \
OS_VERSION="${initrd_os_version}" \
ROOTFS_BUILD_DEST="${tmp_dir}/initrd-image" \
USE_DOCKER=1 \
AGENT_INIT="yes"
}
build_image() {
sudo -E PATH="${PATH}" make image \
DISTRO="${img_distro}" \
DEBUG="${DEBUG:-}" \
USE_DOCKER="1" \
IMG_OS_VERSION="${img_os_version}" \
ROOTFS_BUILD_DEST="${tmp_dir}/rootfs-image"
}
create_tarball() {
agent_sha=$(get_repo_hash "${script_dir}")
#reduce sha size for short names
agent_sha=${agent_sha:0:${short_commit_length}}
tarball_name="kata-containers-${kata_version}-${agent_sha}-${arch_target}.tar.gz"
image_name="kata-containers-image_${img_distro}_${kata_version}_agent_${agent_sha}.img"
initrd_name="kata-containers-initrd_${initrd_distro}_${kata_version}_agent_${agent_sha}.initrd"
mv "${script_dir}/../../../osbuilder/kata-containers.img" "${image_name}"
mv "${script_dir}/../../../osbuilder/kata-containers-initrd.img" "${initrd_name}"
sudo tar cfzv "${tarball_name}" "${initrd_name}" "${image_name}"
}
usage() {
return_code=${1:-0}
cat <<EOT
Create image and initrd in a tarball for kata containers.
Use it to build an image to distribute kata.
Usage:
${script_name} [options]
Options:
-v <version> : Kata version to build images. Use kata release for
for agent and osbuilder.
EOT
exit "${return_code}"
}
main() {
while getopts "v:h" opt; do
case "$opt" in
h) usage 0 ;;
v) kata_version="${OPTARG}" ;;
*)
echo "Invalid option $opt"
usage 1
;;
esac
done
install_yq
#image information
img_distro=$(get_from_kata_deps "assets.image.architecture.${arch_target}.name" "${kata_version}")
#In old branches this is not defined, use a default
img_distro=${img_distro:-clearlinux}
img_os_version=$(get_from_kata_deps "assets.image.architecture.${arch_target}.version" "${kata_version}")
#initrd information
initrd_distro=$(get_from_kata_deps "assets.initrd.architecture.${arch_target}.name" "${kata_version}")
#In old branches this is not defined, use a default
initrd_distro=${initrd_distro:-alpine}
initrd_os_version=$(get_from_kata_deps "assets.image.architecture.${arch_target}.version" "${kata_version}")
shift "$((OPTIND - 1))"
pushd "${script_dir}/../../../osbuilder/"
build_initrd
build_image
create_tarball
cp "${tarball_name}" "${destdir}"
popd
}
main $*

View File

@ -0,0 +1,12 @@
Source: kata-containers-image
Section: devel
Priority: optional
Maintainer: Kata containers team <https://github.com/kata-containers/>
Standards-Version: 3.9.6
Homepage: https://katacontainers.io
Build-Depends: debhelper (>= 9), flex, bison
Package: kata-containers-image
Architecture: @deb_arch@
Description: Kata containers image

View File

@ -0,0 +1 @@
usr/share/kata-containers

View File

@ -0,0 +1,17 @@
#!/usr/bin/make -f
%:
dh $@
override_dh_auto_build:
override_dh_auto_install:
mkdir -p debian/kata-containers-image ; \
tar xzf /usr/src/packages/SOURCES/kata-containers.tar.gz -C /usr/src/packages/SOURCES/ ; \
image=$$(find /usr/src/packages/SOURCES/ -type f -name '*.img') ; \
initrd=$$(find /usr/src/packages/SOURCES/ -type f -name '*.initrd') ; \
install -m 0400 -D $${image} ./debian/kata-containers-image/usr/share/kata-containers/ ; \
install -m 0400 -D $${initrd} ./debian/kata-containers-image/usr/share/kata-containers/ ; \
ln -s /usr/share/kata-containers/$$(basename $${image}) \
./debian/kata-containers-image/usr/share/kata-containers/kata-containers.img ; \
ln -s /usr/share/kata-containers/$$(basename $${initrd}) \
./debian/kata-containers-image/usr/share/kata-containers/kata-containers-initrd.img ;

View File

@ -0,0 +1,14 @@
Format: 3.0 (quilt)
Source: kata-containers-image
Version: @VERSION@-@RELEASE@
Section: devel
Priority: optional
Maintainer: Kata containers team <https://github.com/kata-containers/>
Build-Depends: debhelper (>= 9), flex, bison
Standards-Version: 3.9.6
Homepage: https://katacontainers.io
Debtransform-Tar: kata-containers.tar.gz
Package: kata-containers-image
Architecture: @deb_arch@
Description: Kata containers image

View File

@ -0,0 +1,43 @@
Name: kata-containers-image
Version: @VERSION@
Release: @RELEASE@
License: Artistic-1.0 and BSD-3-Clause and BSD-4-Clause-UC and GFDL-1.3 and GPL-2.0 and GPL-2.0+ and GPL-3.0 and GPL-3.0+ and LGPL-2.0 and LGPL-2.0+ and LGPL-2.1 and LGPL-3.0+ and MIT and MPL-2.0
Summary: Kata Containers Image
Url: https://github.com/kata-containers/osbuilder
Group: image
Source0: kata-containers.tar.gz
Source1: LICENSE
%global debug_package %{nil}
@RPM_PATCH_LIST@
%description
Kata Containers rootfs image
%prep
# Patches
@RPM_APPLY_PATCHES@
%install
ImageDir=%{buildroot}/usr/share/kata-containers
mkdir -p ${ImageDir}
pushd %{_sourcedir}
tar xfz kata-containers.tar.gz
image=$(find ${PWD} -type f -name '*.img')
initrd=$(find ${PWD} -type f -name '*.initrd')
popd
install -m 0400 -p "${image}" ${ImageDir}/
install -m 0400 -p "${initrd}" ${ImageDir}/
ln -s /usr/share/kata-containers/$(basename "${image}") ${ImageDir}/kata-containers.img
ln -s /usr/share/kata-containers/$(basename "${initrd}") ${ImageDir}/kata-containers-initrd.img
%files
%if 0%{?suse_version}
%dir /usr/share/kata-containers
%endif
/usr/share/kata-containers/kata-containers-image*.img
/usr/share/kata-containers/kata-containers.img
/usr/share/kata-containers/kata-containers-initrd*.initrd
/usr/share/kata-containers/kata-containers-initrd.img

View File

@ -0,0 +1,62 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# Automation script to create specs to build kata-containers-image
# Default image to build is the one specified in file versions.txt
# located at the root of the repository.
[ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt
source ../scripts/pkglib.sh
SCRIPT_NAME=$0
SCRIPT_DIR=$(dirname $0)
PKG_NAME="kata-containers-image"
VERSION=$kata_osbuilder_version
GENERATED_FILES=(kata-containers-image.spec kata-containers-image.dsc debian.rules debian.control)
STATIC_FILES=(LICENSE debian.compat debian.dirs kata-containers.tar.gz)
# Parse arguments
cli "$@"
[ "$VERBOSE" == "true" ] && set -x
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/kata-containers-image}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
function check_image() {
[ ! -f "${SCRIPT_DIR}/kata-containers.tar.gz" ] && die "No kata-containers.tar.gz found!\nUse the build_image.sh script" || echo "Image: OK"
}
replace_list=(
"VERSION=$VERSION"
"RELEASE=$RELEASE"
)
verify
rm -rf kata-containers.tar.gz
image_tarball=$(find . -name 'kata-containers-'"${VERSION/\~/-}"'-'"${kata_agent_hash:0:${short_commit_length}}"'*-*.tar.gz')
[ -f "${image_tarball}" ] || die "image not found"
cp "${image_tarball}" kata-containers.tar.gz
check_image
echo "Verify succeed."
get_git_info
#TODO delete me: used by changelog_update
hash_tag="nocommit"
changelog_update $VERSION
generate_files "$SCRIPT_DIR" "${replace_list[@]}"
build_pkg "${PROJECT_REPO}"

View File

@ -0,0 +1,25 @@
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
# Installation variables
DESTDIR :=
DEFAULTSDIR := /usr/share/
PROJECT_DIR := Kata-containers
VMLINUX := @VMLINUX@
VMLINUZ := @VMLINUZ@
DESTSYSCONFDIR := $(abspath $(DESTDIR)/$(DEFAULTSDIR)/$(PROJECT_DIR))
VMLINUX_DEST := $(abspath $(DESTSYSCONFDIR)/$(VMLINUX))
VMLINUZ_DEST := $(abspath $(DESTSYSCONFDIR)/$(VMLINUZ))
install:
install -D --owner root --group root --mode 0644 $(VMLINUX) $(VMLINUX_DEST)
install -D --owner root --group root --mode 0644 $(VMLINUZ) $(VMLINUZ_DEST)
ln -sf $(VMLINUX_DEST) $(DESTSYSCONFDIR)/vmlinuz.container
ln -sf $(VMLINUZ_DEST) $(DESTSYSCONFDIR)/vmlinux.container

View File

@ -0,0 +1,13 @@
<!--- XML Structure defined here: https://en.opensuse.org/openSUSE:Build_Service_Concept_SourceService -->
<services>
<service name="download_url">
<param name="protocol">https</param>
<param name="host">cdn.kernel.org</param>
<param name="path">/pub/linux/kernel/v5.x/linux-@VERSION@.tar.xz</param>
</service>
<service name="verify_file">
<param name="file">_service:download_url:linux-@VERSION@.tar.xz</param>
<param name="verifier">sha256</param>
<param name="checksum">@KERNEL_SHA256@</param>
</service>
</services>

View File

@ -0,0 +1 @@
9

View File

@ -0,0 +1,18 @@
Source: kata-linux-container
Section: devel
Priority: optional
Maintainer: Kata containers team <https://github.com/kata-containers/>
Build-Depends: debhelper (>= 9), cpio, libelf-dev, libnewt-dev, libiberty-dev, rsync, libdw-dev, libpci-dev, pkg-config, flex, bison, libunwind8-dev, openssl, libaudit-dev, bc, python-dev, gawk, autoconf, automake, libtool, libssl-dev
Standards-Version: 3.9.6
Homepage: https://katacontainers.io
Package: kata-linux-container
Architecture: @deb_arch@
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends},
Description: linux kernel optimised for container-like workloads.
Linux kernel optimised for container-like workloads
Package: kata-linux-container-debug
Architecture: @deb_arch@
Description: Debug components for the kata-linux-container package.
This package includes the kernel config and the kernel map.

View File

@ -0,0 +1,30 @@
This is the Kata containers prepackaged version of the Linux kernel.
Linux was written by Linus Torvalds <Linus.Torvalds@cs.Helsinki.FI>
and others.
This package was put together by the Kata containers team, from
sources retrieved from upstream linux git.
The sources may be found at most Linux download websites, including
https://www.kernel.org/pub/linux/kernel/
This package is currently maintained by the
Kata containers team <https://github.com/kata-containers/
Linux is copyrighted by Linus Torvalds and others.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; version 2 dated June, 1991.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
On your Linux system, the complete text of the GNU General
Public License v2 can be found in `/usr/share/common-licenses/GPL-2'.
copyright (END)

View File

@ -0,0 +1 @@
usr/share/Kata-containers

View File

@ -0,0 +1,63 @@
#!/usr/bin/make -f
include /usr/share/dpkg/default.mk
KernelDir=debian/kata-linux-container/usr/share/kata-containers
DebugDir=debian/kata-linux-container-debug/usr/share/kata-containers
KernelVer=${DEB_VERSION_UPSTREAM_REVISION}.container
HOST_ARCH=$(shell arch)
KATA_MULTIARCH="/usr/src/packages/SOURCES/kata-multiarch.sh"
KERNEL_ARCH=$(shell /bin/bash $(KATA_MULTIARCH) -a $(HOST_ARCH))
KERNEL_IMAGE=$(shell /bin/bash $(KATA_MULTIARCH) -i $(HOST_ARCH))
KERNEL_CONFIGS=kata-kernel-configs
KERNEL_FRAG_COMMON_DIR="$(KERNEL_CONFIGS)/fragments/common"
KERNEL_FRAG_ARCH_DIR="$(KERNEL_CONFIGS)/fragments/$(KERNEL_ARCH)"
# used in merge_config.sh
export KCONFIG_CONFIG=.config
export ARCH=$(KERNEL_ARCH)
%:
dh $@
override_dh_auto_build:
sed -i "s/^EXTRAVERSION.*/EXTRAVERSION = -$$(echo $(KernelVer) | cut -d'-' -f2)/" Makefile
tar xzf /usr/src/packages/SOURCES/$(KERNEL_CONFIGS).tar.gz
rm -f .config
find $(KERNEL_CONFIGS) -name "$(KERNEL_ARCH)_kata_kvm_*" -exec cp {} .config \;
if [ ! -f .config ]; then \
scripts/kconfig/merge_config.sh -r -n $(KERNEL_FRAG_COMMON_DIR)/*.conf $(KERNEL_FRAG_ARCH_DIR)/* ; \
if [ ! -f .config ]; then \
echo "ERROR: cannot find the kernel config file for the $(KERNEL_ARCH) architecture"; \
exit 1; \
fi \
fi
# https://github.com/kata-containers/packaging/issues/394 enable reproducible builds:
export KBUILD_BUILD_USER=katabuilduser
export KBUILD_BUILD_HOST=katabuildhost
# Default to zero seconds after midnight 1970-01-01 (the epoch)
export KBUILD_BUILD_TIMESTAMP="$(LANG=C date -u -d "@${SOURCE_DATE_EPOCH:-0}")"
make -s ARCH=$(KERNEL_ARCH) oldconfig > /dev/null
make -s CONFIG_DEBUG_SECTION_MISMATCH=y ARCH=$(KERNEL_ARCH)
override_dh_auto_install:
override_dh_auto_clean:
override_dh_install:
dh_install
mkdir -p $(DebugDir)
mkdir -p $(KernelDir)
install -m 644 .config $(DebugDir)/config-$(KernelVer)
install -m 644 System.map $(DebugDir)/System.map-$(KernelVer)
if [ -n "$(KERNEL_IMAGE)" ]; then \
cp $$(realpath $(KERNEL_IMAGE)) $(KernelDir)/vmlinuz-$(KernelVer); \
chmod 755 $(KernelDir)/vmlinuz-$(KernelVer); \
ln -sf vmlinuz-$(KernelVer) $(KernelDir)/vmlinuz.container; \
fi
cp vmlinux $(KernelDir)/vmlinux-$(KernelVer)
chmod 755 $(KernelDir)/vmlinux-$(KernelVer)
ln -sf vmlinux-$(KernelVer) $(KernelDir)/vmlinux.container
override_dh_strip:
override_dh_shlibdeps:

View File

@ -0,0 +1,20 @@
Format: 3.0 (quilt)
Source: kata-linux-container
Version: @VERSION@.@CONFIG_VERSION@-@RELEASE@
Section: devel
Priority: optional
Maintainer: Kata containers team <https://github.com/kata-containers/>
Build-Depends: debhelper (>= 9), cpio, libelf-dev, libnewt-dev, libiberty-dev, rsync, libdw-dev, libpci-dev, pkg-config, flex, bison, libunwind8-dev, openssl, libaudit-dev, bc, python-dev, gawk, autoconf, automake, libtool, libssl-dev
Standards-Version: 3.9.6
Homepage: https://katacontainers.io
Debtransform-Tar: linux-@VERSION@.tar.xz
Package: kata-linux-container
Architecture: @deb_arch@
Description: linux kernel optimised for container-like workloads.
Linux kernel optimised for container-like workloads
Package: kata-linux-container-debug
Architecture: @deb_arch@
Description: Debug components for the kata-linux-container package.
This package includes the kernel config and the kernel map.

View File

@ -0,0 +1,165 @@
#
# This is a special configuration of the Linux kernel, aimed exclusively
# for running inside a container
# This specialization allows us to optimize memory footprint and boot time.
#
Name: kata-linux-container
Version: @VERSION@.@CONFIG_VERSION@
Release: @RELEASE@
License: GPL-2.0
Summary: The Linux kernel optimized for running inside a container
Group: System/Kernel
Url: http://www.kernel.org/
Source0: https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-@VERSION@.tar.xz
Source1: kata-kernel-configs.tar.gz
Source2: kata-multiarch.sh
%define kversion %{version}-%{release}.container
BuildRequires: bash >= 2.03
BuildRequires: bc
BuildRequires: binutils-devel
%if 0%{?rhel_version}
BuildRequires: elfutils-devel
%endif
%if 0%{?suse_version}
BuildRequires: libelf-devel
BuildRequires: fdupes
%endif
%if 0%{?fedora} || 0%{?centos} <= 7
BuildRequires: pkgconfig(libelf)
%endif
%if 0%{?centos} >= 8
BuildRequires: elfutils-libelf-devel
%endif
BuildRequires: make >= 3.78
BuildRequires: openssl-devel
BuildRequires: flex
BuildRequires: bison
# don't strip .ko files!
%global __os_install_post %{nil}
%define debug_package %{nil}
%define __strip /bin/true
# Patches
@RPM_PATCH_LIST@
%description
The Linux kernel.
%package debug
Summary: Debug components for the %{name} package
Group: System/Kernel
%description debug
Debug components for the kata-linux-container package.
This package includes the kernel config and the kernel map.
%prep
%setup -q -n linux-@VERSION@
%setup -q -T -D -n linux-@VERSION@ -a 1
cp %{SOURCE2} .
chmod +x $(basename %{SOURCE2})
# Patches
@RPM_APPLY_PATCHES@
%build
BuildKernel() {
local kernelArch=$(./kata-multiarch.sh -a %{_arch})
ExtraVer="-%{release}.container"
perl -p -i -e "s/^EXTRAVERSION.*/EXTRAVERSION = ${ExtraVer}/" Makefile
make -s mrproper
# Runtime .config selection based on kernelArch
rm -f .config
find kata-kernel-configs -name "${kernelArch}_kata_kvm_*" -exec cp {} .config \;
if [ ! -f .config ]; then
# Use fragments to generate the .config
frag_dir="kata-kernel-configs/fragments"
KCONFIG_CONFIG=.config ARCH=${kernelArch} scripts/kconfig/merge_config.sh -r -n ${frag_dir}/common/*.conf ${frag_dir}/${kernelArch}/*
fi
[ -f .config ] || (echo "ERROR: cannot find the kernel config file for the ${kernelArch} architecture"; exit 1)
%if 0%{?rhel_version} || 0%{?suse_version}
# RHEL in OBS has updated gcc.
# https://github.com/kata-containers/packaging/pull/370#issuecomment-469620154
sed -i -e 's/CONFIG_RETPOLINE=y/CONFIG_RETPOLINE=n/g' .config
%endif
%if 0%{?fedora}
#Fedora uses gcc 8, build is failing due to warnings.
export CFLAGS="-Wno-error=restrict"
export EXTRA_CFLAGS="-Wno-format-truncation -Wno-cast-function-type -Wno-error=restrict -Wno-error"
%endif
# https://github.com/kata-containers/packaging/issues/394 enable reproducible builds:
export KBUILD_BUILD_USER=katabuilduser
export KBUILD_BUILD_HOST=katabuildhost
# Default to zero seconds after midnight 1970-01-01 (the epoch)
export KBUILD_BUILD_TIMESTAMP="$(LANG=C date -u -d "@${SOURCE_DATE_EPOCH:-0}")"
make -s ARCH=$kernelArch oldconfig > /dev/null
make -s CONFIG_DEBUG_SECTION_MISMATCH=y %{?_smp_mflags} ARCH=$kernelArch %{?sparse_mflags} || exit 1
}
BuildKernel
%install
InstallKernel() {
compressedImage=$(./kata-multiarch.sh -i %{_arch})
rawImage="vmlinux"
KernelVer=%{kversion}
KernelDir=%{buildroot}/usr/share/kata-containers
mkdir -p ${KernelDir}
if [ -n "$compressedImage" ]; then
cp "$compressedImage" ${KernelDir}/vmlinuz-$KernelVer
chmod 755 ${KernelDir}/vmlinuz-$KernelVer
ln -sf vmlinuz-$KernelVer ${KernelDir}/vmlinuz.container
fi
cp $rawImage ${KernelDir}/vmlinux-$KernelVer
chmod 755 ${KernelDir}/vmlinux-$KernelVer
ln -sf vmlinux-$KernelVer ${KernelDir}/vmlinux.container
cp .config "${KernelDir}/config-${KernelVer}"
cp System.map "${KernelDir}/System.map-${KernelVer}"
rm -f %{buildroot}/usr/lib/modules/$KernelVer/build
rm -f %{buildroot}/usr/lib/modules/$KernelVer/source
}
InstallKernel
rm -rf %{buildroot}/usr/lib/firmware
%if 0%{?suse_version}
%fdupes -s %{buildroot}
%endif
%files
%dir /usr/share/kata-containers
/usr/share/kata-containers/vmlinux-%{kversion}
/usr/share/kata-containers/vmlinux.container
%ifnarch ppc64le
/usr/share/kata-containers/vmlinuz-%{kversion}
/usr/share/kata-containers/vmlinuz.container
%endif
%files debug
%defattr(-,root,root,-)
/usr/share/kata-containers/config-%{kversion}
/usr/share/kata-containers/System.map-%{kversion}

View File

@ -0,0 +1,60 @@
#!/usr/bin/env bash
set -e
# Convert architecture to the name used by the Linux kernel build system
arch_to_kernel() {
local -r arch="$1"
case "${arch}" in
aarch64) echo "arm64";;
ppc64le) echo "powerpc";;
s390|s390x) echo "s390";;
x86_64) echo "${arch}";;
*) echo "unsupported architecture: ${arch}" >&2; exit 1;;
esac
}
# Convert architecture to the location of the compressed linux image
arch_to_image() {
local -r arch="$1"
case "${arch}" in
aarch64)
echo "arch/arm64/boot/Image"
;;
ppc64le)
# No compressed image
;;
s390|s390x)
echo "arch/s390/boot/image"
;;
*)
echo "arch/${arch}/boot/bzImage"
;;
esac
}
usage() {
echo "$(basename $0) FLAG ARCHITECTURE"
echo "Allowed flags:"
echo " -a : Print kernel architecture"
echo " -i : Print kernel compressed image location (may be empty)"
}
if [ "$#" != "2" ]; then
echo -e "Invalid options\n\n$(usage)" >&2
exit 1
fi
case "$1" in
-a)
arch_to_kernel $2
;;
-i)
arch_to_image $2
;;
*)
echo -e "Invalid options\n\n$(usage)" >&2
exit 1
;;
esac

View File

@ -0,0 +1,72 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# Automation script to create specs to build Kata containers kernel
[ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt
source ../scripts/pkglib.sh
SCRIPT_NAME=$0
SCRIPT_DIR=$(dirname $0)
PKG_NAME="kata-linux-container"
VERSION=$kernel_version
KATA_CONFIG_VERSION=$(cat "${SCRIPT_DIR}/../../kernel/kata_config_version")
KR_SERIES="$(echo $VERSION | cut -d "." -f 1).x"
KR_LTS=$(echo $VERSION | cut -d "." -f 1,2)
ln -sfT "${SCRIPT_DIR}/../../kernel/patches/${KR_LTS}.x" "${SCRIPT_DIR}/patches"
KR_PATCHES=$(eval find "${SCRIPT_DIR}/patches" -type f -name "*.patch")
KR_REL=https://www.kernel.org/releases.json
KR_SHA=https://cdn.kernel.org/pub/linux/kernel/v"${KR_SERIES}"/sha256sums.asc
KR_CONFIGS="kata-kernel-configs"
GENERATED_FILES=(kata-linux-container.dsc kata-linux-container.spec _service debian.control ${KR_CONFIGS}.tar.gz)
STATIC_FILES=(debian.dirs debian.rules debian.compat debian.copyright kata-multiarch.sh)
#STATIC_FILES+=($KR_PATCHES)
# Parse arguments
cli "$@"
[ "$VERBOSE" == "true" ] && set -x
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/linux-container}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
kernel_sha256=$(curl -L -s -f ${KR_SHA} | awk '/linux-'${VERSION}'.tar.xz/ {print $1}')
# Copy the kernel config files and fragments for all architecture
mkdir -p configs
readonly configs_dir="kernel/configs"
find "${SCRIPT_DIR}/../../${configs_dir}" \( -name "*_kata_kvm_${KR_LTS}.x" -o -name fragments \) -exec tar --transform="s,${configs_dir},${KR_CONFIGS}," -czf ${KR_CONFIGS}.tar.gz {} +
replace_list=(
"VERSION=${VERSION}"
"CONFIG_VERSION=${KATA_CONFIG_VERSION}"
"RELEASE=$RELEASE"
"KERNEL_SHA256=$kernel_sha256"
)
verify
echo "Verify succeed."
get_git_info
#TODO delete me: used by changelog_update
hash_tag="nocommit"
changelog_update "${VERSION}-${KATA_CONFIG_VERSION}"
generate_files "$SCRIPT_DIR" "${replace_list[@]}"
build_pkg "${PROJECT_REPO}"

View File

@ -0,0 +1,3 @@
egernst
jcvenega
nitkon

View File

@ -0,0 +1 @@
ExpandFlags: module:python36-3.6

View File

@ -0,0 +1,16 @@
<!--- XML Structure defined here: https://en.opensuse.org/openSUSE:Build_Service_Concept_SourceService -->
<services>
<service name="tar_scm">
<param name="scm">git</param>
<param name="url">https://github.com/qemu/qemu.git</param>
<param name="exclude">.git</param>
<param name="filename">qemu-vanilla</param>
<!--- %h in the version format is a hash from a given revision -->
<param name="versionformat">@VERSION@+git.%h</param>
<param name="revision">@QEMU_VANILLA_HASH@</param>
</service>
<service name="recompress">
<param name="file">*.tar*</param>
<param name="compression">gz</param>
</service>
</services>

View File

@ -0,0 +1 @@
9

View File

@ -0,0 +1,13 @@
Source: qemu-vanilla
Section: devel
Priority: optional
Maintainer: Kata containers team <https://github.com/kata-containers/>
Build-Depends: debhelper (>= 9), cpio, libelf-dev, rsync, libdw-dev, pkg-config, flex, bison, libaudit-dev, bc, python3-dev, gawk, autoconf, automake, libtool, libltdl-dev, libglib2.0-dev, libglib2.0-0, libcap-dev, libcap-ng-dev, libattr1-dev, m4, libnuma-dev, zlib1g-dev, libpixman-1-0, libpixman-1-dev, libselinux1-dev, libffi-dev, libmount-dev, libblkid-dev
Standards-Version: 3.9.6
Homepage: https://katacontainers.io
Package: qemu-vanilla
Architecture: @deb_arch@
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends},
Description: linux kernel optimised for container-like workloads.
Linux kernel optimised for container-like workloads

View File

@ -0,0 +1,26 @@
#!/usr/bin/make -f
include /usr/share/dpkg/default.mk
export LANG=C
%:
dh $@
override_dh_auto_configure:
chmod a+x "../SOURCES/configure-hypervisor.sh"
eval "../SOURCES/configure-hypervisor.sh" "qemu-vanilla" | sed -e 's/--enable-libpmem//g' | xargs ./configure --prefix=/usr
override_dh_auto_build:
make
override_dh_auto_install:
dh_auto_install
for file in $(CURDIR)/debian/qemu-vanilla/usr/bin/* ; do \
dir=$$(dirname $$file) ;\
bin=$$(basename $$file) ;\
new=$$(echo $$bin | sed -e 's/qemu-/qemu-vanilla-/g' -e 's/ivshmem-/ivshmem-vanilla-/g' -e 's/virtfs-/virtfs-vanilla-/g') ;\
mv $$file "$$dir"/"$$new" ; \
done
override_dh_auto_test:
echo "Skip auto test"
override_dh_auto_clean:
echo "Skip auto clean"

View File

@ -0,0 +1 @@
setBadness('arch-dependent-file-in-usr-share', 0)

View File

@ -0,0 +1,16 @@
Format: 3.0 (quilt)
Source: qemu-vanilla
Version: @VERSION@+git.@QEMU_VANILLA_HASH@-@RELEASE@
Section: devel
Priority: optional
Maintainer: Kata containers team <https://github.com/kata-containers/>
Build-Depends: debhelper (>= 9), cpio, libelf-dev, rsync, libdw-dev, pkg-config, flex, bison, libaudit-dev, bc, python3-dev, gawk, autoconf, automake, libtool, libltdl-dev, libglib2.0-dev, libglib2.0-0, libcap-dev, libcap-ng-dev, libattr1-dev, m4, libnuma-dev, zlib1g-dev, libpixman-1-0, libpixman-1-dev, librbd-dev, libselinux1-dev, libffi-dev, libmount-dev, libblkid-dev
Standards-Version: 3.9.6
Homepage: https://katacontainers.io
Debtransform-Tar: qemu-vanilla-@VERSION@+git.@QEMU_VANILLA_HASH@.tar.gz
Package: qemu-vanilla
Architecture: @deb_arch@
Depends: ${shlibs:Depends}, ${misc:Depends}, ${perl:Depends},
Description: QEMU is a generic and open source machine & userspace emulator and
virtualizer.

View File

@ -0,0 +1,135 @@
%global qemu_vanilla_hash @QEMU_VANILLA_HASH@
Name: qemu-vanilla
Version: @VERSION@+git.%{qemu_vanilla_hash}
Release: @RELEASE@
Source0: %{name}-%{version}.tar.gz
Source1: qemu-vanilla-rpmlintrc
Source2: configure-hypervisor.sh
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}
Summary : OpenBIOS development utilities
Group : Development/Tools
License : BSD-2-Clause and BSD-3-Clause and GPL-2.0 and GPL-2.0+ and LGPL-2.0+ and LGPL-2.1
Requires: qemu-vanilla-bin
Requires: qemu-vanilla-data
BuildRequires : automake
BuildRequires : bc
BuildRequires : bison
BuildRequires : flex
BuildRequires : gcc-c++
BuildRequires : glib2-devel
BuildRequires : libattr-devel
BuildRequires : libcap-devel
BuildRequires : libcap-ng-devel
BuildRequires : libtool
BuildRequires : libtool-ltdl-devel
BuildRequires : libtool
BuildRequires : m4
BuildRequires : findutils
%if 0%{?centos_version}
BuildRequires : librbd1-devel
BuildRequires : libmount
%else
%if ! 0%{?rhel_version}
BuildRequires : librbd-devel
%endif
BuildRequires : libselinux-devel
BuildRequires : libffi-devel
BuildRequires : libmount-devel
BuildRequires : libblkid-devel
%endif
%if 0%{?suse_version}
BuildRequires : libnuma-devel
%else
BuildRequires : numactl-devel
%endif
BuildRequires : python3
BuildRequires : python3-devel
BuildRequires : zlib-devel
BuildRequires : pkgconfig(pixman-1)
BuildRequires : libpmem-devel
# Patches
@RPM_PATCH_LIST@
%description
===========
QEMU is a generic and open source machine & userspace emulator and
virtualizer.
%package bin
Summary: Bin components for the qemu-vanilla package
Group: Binaries
Requires: qemu-vanilla-data
%description bin
bin components for the qemu-vanilla package.
%package data
Summary: Data components for the qemu-vanilla package
Group: Data
%description data
data components for the qemu-vanilla package.
%global debug_package %{nil}
%prep
chmod +x %{_sourcedir}/configure-hypervisor.sh
%setup -q
# Patches
@RPM_APPLY_PATCHES@
%build
export LANG=C
# RHEL in OBS does not provide librados.
# Remove it: See https://github.com/kata-containers/packaging/issues/36
"%{_sourcedir}/configure-hypervisor.sh" "qemu-vanilla" \
%if 0%{?rhel_version}
| sed -e 's/--enable-rbd//g' \
%endif
| xargs ./configure --prefix=/usr
make V=1 %{?_smp_mflags}
%install
rm -rf %{buildroot}
#%make_install
make install DESTDIR=%{buildroot}
## make_install_append content
for file in %{buildroot}/usr/bin/*
do
dir=$(dirname "$file")
bin=$(basename "$file")
new=$(echo "$bin"|sed -e 's/qemu-/qemu-vanilla-/g' -e 's/ivshmem-/ivshmem-vanilla-/g' -e 's/virtfs-/virtfs-vanilla-/g')
mv "$file" "$dir/$new"
done
## make_install_append end
%files
%defattr(-,root,root,-)
%files bin
%defattr(-,root,root,-)
%exclude /usr/bin/qemu-vanilla-ga
%exclude /usr/bin/qemu-vanilla-pr-helper
/usr/bin/qemu-vanilla-system-*
%exclude /usr/bin/virtfs-vanilla-proxy-helper
%exclude %dir /usr/libexec
%exclude %dir /usr/libexec/qemu-vanilla
%exclude /usr/libexec/qemu-vanilla/qemu-bridge-helper
%files data
%defattr(-,root,root,-)
%dir /usr/share/qemu-vanilla
/usr/share/qemu-vanilla/*

View File

@ -0,0 +1,53 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
# Automation script to create specs to build kata containers kernel
[ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt
source ../scripts/pkglib.sh
SCRIPT_NAME=$0
SCRIPT_DIR=$(dirname $0)
PKG_NAME="qemu-vanilla"
VERSION=$qemu_vanilla_version
PATCHES_VERSION="$(echo $VERSION | cut -d "." -f 1,2).x"
ln -sfT "${SCRIPT_DIR}/../../qemu/patches/${PATCHES_VERSION}" "${SCRIPT_DIR}/patches"
GENERATED_FILES=(qemu-vanilla.dsc qemu-vanilla.spec debian.rules _service debian.control)
STATIC_FILES=(debian.compat "${SCRIPT_DIR}/../../scripts/configure-hypervisor.sh" qemu-vanilla-rpmlintrc)
# Parse arguments
cli "$@"
[ "$VERBOSE" == "true" ] && set -x
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-vanilla}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
set_versions "${qemu_vanilla_hash}"
replace_list=(
"VERSION=$VERSION"
"RELEASE=$RELEASE"
"QEMU_VANILLA_HASH=${qemu_vanilla_hash:0:${short_commit_length}}"
)
verify
echo "Verify succeed."
get_git_info
changelog_update $VERSION
generate_files "$SCRIPT_DIR" "${replace_list[@]}"
build_pkg "${PROJECT_REPO}"

View File

@ -0,0 +1,26 @@
<!--- XML Structure defined here: https://en.opensuse.org/openSUSE:Build_Service_Concept_SourceService -->
<services>
<!--- OBS plugin tar_scm (Source control manager) -->
<service name="tar_scm">
<param name="scm">git</param>
<param name="url">https://github.com/kata-containers/kata-containers.git</param>
<param name="filename">kata-runtime</param>
<!--- versionformat defines the name of the tarball. -->
<param name="versionformat">@VERSION@</param>
<param name="revision">@HASH@</param>
</service>
<service name="recompress">
<param name="file">*.tar*</param>
<param name="compression">gz</param>
</service>
<service name="download_url">
<param name="protocol">https</param>
<param name="host">storage.googleapis.com</param>
<param name="path">golang/go@GO_VERSION@.linux-@GO_ARCH@.tar.gz</param>
</service>
<service name="verify_file">
<param name="file">_service:download_url:go@GO_VERSION@.linux-@GO_ARCH@.tar.gz</param>
<param name="verifier">sha256</param>
<param name="checksum">@GO_CHECKSUM@</param>
</service>
</services>

View File

@ -0,0 +1 @@
9

View File

@ -0,0 +1,17 @@
Source: kata-runtime
Section: devel
Priority: optional
Maintainer: Kata containers team <https://github.com/kata-containers/>
Standards-Version: 3.9.6
Homepage: https://katacontainers.io
Build-Depends: dh-make, git, ca-certificates, execstack, devscripts, debhelper,
build-essential, dh-autoreconf, make
Package: kata-runtime
Architecture: @deb_arch@
Depends: kata-containers-image (= @kata_osbuilder_version_release@),
kata-linux-container (= @linux_container_version_release@),
qemu-vanilla(= @qemu_vanilla_version_release@)
Description:
An Open Containers Initiative (OCI) "runtime" that launches an Intel VT-x
secured Kata Containers hypervisor, rather than a standard Linux container.

View File

@ -0,0 +1,46 @@
#!/usr/bin/make -f
export DH_VERBOSE = 1
export PKG_NAME=kata-runtime
export DOMAIN=github.com
export ORG=kata-containers
export PROJECT=runtime
export IMPORTNAME=$(DOMAIN)/$(ORG)/$(PROJECT)
export DH_GOPKG:=$(IMPORTNAME)
export DEB_BUILD_OPTIONS=nocheck
export PATH:=/usr/src/packages/BUILD/local/go/bin:$(PATH)
export GOPATH=/usr/src/packages/BUILD/go
export GOROOT=/usr/src/packages/BUILD/local/go
export DH_OPTIONS
export DEFAULT_QEMU=qemu-vanilla-system-x86_64
GO_VERSION=@GO_VERSION@
%:
dh $@
override_dh_auto_clean:
override_dh_auto_build:
mkdir -p /usr/src/packages/BUILD/local/
mkdir -p /usr/src/packages/BUILD/go/src/$(DOMAIN)/$(ORG)/
tar xzf /usr/src/packages/SOURCES/go$(GO_VERSION).linux-@GO_ARCH@.tar.gz -C /usr/src/packages/BUILD/local
ln -s /usr/src/packages/BUILD /usr/src/packages/BUILD/go/src/$(IMPORTNAME)
cd $(GOPATH)/src/$(IMPORTNAME)/; \
make \
QEMUCMD=$(DEFAULT_QEMU) \
COMMIT=@HASH@ \
SKIP_GO_VERSION_CHECK=1
override_dh_auto_install:
mkdir -p debian/$(PKG_NAME)
cd $(GOPATH)/src/$(IMPORTNAME)/; \
make install \
DESTDIR=$(shell pwd)/debian/$(PKG_NAME)/ \
PREFIX=/usr \
COMMIT=@HASH@ \
QEMUCMD=$(DEFAULT_QEMU) \
SKIP_GO_VERSION_CHECK=1
sed -i -e '/^initrd =/d' $(shell pwd)/debian/$(PKG_NAME)/usr/share/defaults/kata-containers/configuration.toml

View File

@ -0,0 +1,22 @@
Format: 3.0 (quilt)
Source: kata-runtime
# Version is expected to be started with a digit following by an alphanumeric string
# e.g. 1.0.0+git.1234567-1
Version: @VERSION@-@RELEASE@
Section: devel
Priority: optional
Maintainer: Kata containers team <https://github.com/kata-containers/>
Standards-Version: 3.9.6
Build-Depends: dh-make, git, ca-certificates, execstack, fakeroot, devscripts, debhelper,
build-essential, dh-autoreconf, make
Homepage: https://katacontainers.io
Debtransform-Tar: kata-runtime-@VERSION@.tar.gz
Package: kata-runtime
Architecture: @deb_arch@
Depends: kata-containers-image (= @kata_osbuilder_version_release@),
kata-linux-container (= @linux_container_version_release@),
qemu-vanilla(= @qemu_vanilla_version_release@)
Description:
An Open Containers Initiative (OCI) "runtime" that launches an Intel VT-x
secured Kata Containers hypervisor, rather than a standard Linux container.

View File

@ -0,0 +1,97 @@
%global DOMAIN github.com
%global ORG kata-containers
%global PROJECT runtime
%global IMPORTNAME %{DOMAIN}/%{ORG}/%{PROJECT}
%global GO_VERSION @GO_VERSION@
%global DEFAULT_QEMU qemu-vanilla-system-x86_64
%define LIBEXECDIR /usr/libexec
%undefine _missing_build_ids_terminate_build
%define debug_package %{nil}
Name: kata-runtime
# Version is expected to be started with a digit following by an alphanumeric string
# e.g. 1.0.0+git.1234567
Version: @VERSION@
Release: @RELEASE@
Source0: %{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Summary : No detailed summary available
Group : Development/Tools
License : Apache-2.0
BuildRequires: git
Requires: kata-containers-image = @kata_osbuilder_version@
Requires: kata-linux-container = @linux_container_version@
Requires: qemu-vanilla = @qemu_vanilla_version@
# Patches
@RPM_PATCH_LIST@
%description
.. contents::
.. sectnum::
``kata-runtime``
===================
Overview
--------
%prep
mkdir local
tar -C local -xzf ../SOURCES/go%{GO_VERSION}.linux-@GO_ARCH@.tar.gz
%autosetup -N -S git
# Patches
@RPM_APPLY_PATCHES@
%build
export GOROOT=$HOME/rpmbuild/BUILD/local/go
export PATH=$PATH:$HOME/rpmbuild/BUILD/local/go/bin
export GOPATH=$HOME/rpmbuild/BUILD/go/
mkdir -p $HOME/rpmbuild/BUILD/go/src/%{DOMAIN}/%{ORG}
ln -s $HOME/rpmbuild/BUILD/kata-runtime-%{version} $HOME/rpmbuild/BUILD/go/src/%{IMPORTNAME}
cd $HOME/rpmbuild/BUILD/go/src/%{IMPORTNAME}
make \
QEMUCMD=%{DEFAULT_QEMU} \
COMMIT=@HASH@ \
SKIP_GO_VERSION_CHECK=1
%check
export http_proxy=http://127.0.0.1:9/
export https_proxy=http://127.0.0.1:9/
export no_proxy=localhost
%install
export GOROOT=$HOME/rpmbuild/BUILD/local/go
export PATH=$PATH:$HOME/rpmbuild/BUILD/local/go/bin
export GOPATH=$HOME/rpmbuild/BUILD/go/
cd $HOME/rpmbuild/BUILD/go/src/%{IMPORTNAME}
make \
DESTDIR=%{buildroot} \
PREFIX=/usr \
QEMUCMD=%{DEFAULT_QEMU} \
COMMIT=@HASH@ \
SKIP_GO_VERSION_CHECK=1 \
install
sed -i -e '/^initrd =/d' %{buildroot}/usr/share/defaults/kata-containers/configuration.toml
%files
%defattr(-,root,root,-)
/usr/bin/kata-runtime
/usr/bin/containerd-shim-kata-v2
%{LIBEXECDIR}
%{LIBEXECDIR}/kata-containers
%{LIBEXECDIR}/kata-containers/kata-netmon
/usr/bin/kata-collect-data.sh
/usr/share/defaults/
/usr/share/defaults/kata-containers/
/usr/share/defaults/kata-containers/configuration*.toml
/usr/share/bash-completion
/usr/share/bash-completion/completions
/usr/share/bash-completion/completions/kata-runtime

View File

@ -0,0 +1,135 @@
#!/bin/bash
#
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
#
# Automation script to create specs to build kata-runtime
# Default: Build is the one specified in file configure.ac
# located at the root of the repository.
[ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt
source ../scripts/pkglib.sh
SCRIPT_NAME=$0
SCRIPT_DIR=$(dirname "$0")
replace_list=()
# Package information
# Used by pkglib.sh
export PKG_NAME="kata-runtime"
VERSION=$kata_runtime_version
# Used by pkglib
export GENERATED_FILES=(kata-runtime.spec kata-runtime.dsc debian.control debian.rules _service)
# Used by pkglib
export STATIC_FILES=(debian.compat)
#cli flags
LOCAL_BUILD=false
OBS_PUSH=false
VERBOSE=false
#
# Given the name of a package returns the full package version to be used for
# DEB and RPM dependency constraints as follows, composed of:
# - a version,
# - an optional hash (only for select packages),
# - a release number (only for "deb" packages)
#
pkg_required_ver() {
local pkg="$1"
local versionVar="${pkg}_version"
local hashVar="${pkg}_hash"
local version=$(echo ${!versionVar})
local gitHash=
# Make pkg match the package name on OBS
pkg="${pkg#kata_}"
pkg="${pkg//_/-}"
pkg="${pkg//osbuilder/kata-containers-image}"
pkg="${pkg//kernel/linux-container}"
if [ -n "${PROJECT_REPO:-}" ]; then
local proj="${PROJECT_REPO%/runtime}"
else
local proj="home:${OBS_PROJECT}:${OBS_SUBPROJECT}"
fi
local release="$(get_obs_pkg_release "${proj}/${pkg//_/-}")"
case "$pkg" in
linux-container)
version="${version}.$(cat "${SCRIPT_DIR}/../../kernel/kata_config_version")"
;;
qemu-*)
gitHash=$(echo ${!hashVar}})
;;
esac
local debVer=$(pkg_version "$version" "$release" "$gitHash")
local rpmVer=$(pkg_version "$version" "" "$gitHash")
echo "${debVer}" "${rpmVer}"
}
# Parse arguments
cli "$@"
[ "$VERBOSE" == "true" ] && set -x
declare -a pkgVersions
# Package depedencies
info "Requires:"
declare -A KERNEL_REQUIRED_VERSION
pkgVersions=($(pkg_required_ver "kernel"))
KERNEL_REQUIRED_VERSION["deb"]=${pkgVersions[0]}
KERNEL_REQUIRED_VERSION["rpm"]=${pkgVersions[1]}
info "kata-linux-container ${KERNEL_REQUIRED_VERSION[@]}"
declare -A KATA_IMAGE_REQUIRED_VERSION
pkgVersions=($(pkg_required_ver "kata_osbuilder"))
KATA_IMAGE_REQUIRED_VERSION["deb"]=${pkgVersions[0]}
KATA_IMAGE_REQUIRED_VERSION["rpm"]=${pkgVersions[1]}
info "image ${KATA_IMAGE_REQUIRED_VERSION[@]}"
declare -A KATA_QEMU_VANILLA_REQUIRED_VERSION
pkgVersions=($(pkg_required_ver "qemu_vanilla"))
KATA_QEMU_VANILLA_REQUIRED_VERSION["deb"]=${pkgVersions[0]}
KATA_QEMU_VANILLA_REQUIRED_VERSION["rpm"]=${pkgVersions[1]}
info "qemu-vanilla ${KATA_QEMU_VANILLA_REQUIRED_VERSION[@]}"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/runtime}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++))
set_versions "$kata_runtime_hash"
replace_list+=(
"GO_CHECKSUM=$go_checksum"
"GO_VERSION=$go_version"
"GO_ARCH=$GO_ARCH"
"HASH=$short_hashtag"
"RELEASE=$RELEASE"
"VERSION=$VERSION"
"linux_container_version=${KERNEL_REQUIRED_VERSION["rpm"]}"
"linux_container_version_release=${KERNEL_REQUIRED_VERSION["deb"]}"
"qemu_vanilla_version=${KATA_QEMU_VANILLA_REQUIRED_VERSION["rpm"]}"
"qemu_vanilla_version_release=${KATA_QEMU_VANILLA_REQUIRED_VERSION["deb"]}"
)
verify
echo "Verify succeed."
get_git_info
changelog_update $VERSION
generate_files "$SCRIPT_DIR" "${replace_list[@]}"
build_pkg "${PROJECT_REPO}"

View File

@ -0,0 +1,68 @@
#!/bin/bash
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
_obs_docker_packaging_repo_dir=$(cd $(dirname "${BASH_SOURCE[0]}") && cd ../.. && pwd)
GO_ARCH=$(go env GOARCH)
setup_oscrc() {
# oscrc exists at different places on different distros
[ -f "${HOME}/.config/osc/oscrc" ] && OSCRC="${HOME}/.config/osc/oscrc"
OSCRC=${OSCRC:-"${HOME}/.oscrc"}
(
# do not log OBS credentials even in debug mode
set +x
OBS_API="https://api.opensuse.org"
if [ -n "${OBS_USER:-}" ] && [ -n "${OBS_PASS:-}" ] && [ ! -e "${OSCRC}" ]; then
echo "Creating ${OSCRC} with user $OBS_USER"
mkdir -p $(dirname $OSCRC)
cat <<eom >"${OSCRC}"
[general]
apiurl = ${OBS_API}
[${OBS_API}]
user = ${OBS_USER}
pass = ${OBS_PASS}
eom
fi
) >>/dev/null
if [ ! -e "${OSCRC}" ]; then
echo "${OSCRC}, please do 'export OBS_USER=your_user ; export OBS_PASS=your_pass' to configure osc for first time."
exit 1
fi
echo "OK - osc configured"
}
docker_run() {
local cmd="$*"
local obs_image="obs-kata"
#where results will be stored
local host_datadir="${PWD}/pkgs"
local cache_dir=${PWD}/obs-cache
setup_oscrc
sudo docker build \
--build-arg http_proxy="${http_proxy:-}" \
--build-arg https_proxy="${https_proxy:-}" \
-t $obs_image "${_obs_docker_packaging_repo_dir}/obs-packaging"
sudo docker run \
--rm \
--env http_proxy="${http_proxy:-}" \
--env https_proxy="${https_proxy:-}" \
--env no_proxy="${no_proxy:-}" \
--env GO_ARCH="${GO_ARCH}" \
--env PUSH="${PUSH:-}" \
--env DEBUG="${DEBUG:-}" \
--env OBS_PROJECT="${OBS_PROJECT:-}" \
--env OBS_SUBPROJECT="${OBS_SUBPROJECT:-}" \
-v "${cache_dir}":/var/tmp/osbuild-packagecache/ \
-v "${_obs_docker_packaging_repo_dir}":"${_obs_docker_packaging_repo_dir}" \
-v "${host_datadir}":/var/packaging \
-v "${OSCRC}":/root/.oscrc \
-v "${PWD}":"${PWD}" \
-w "${PWD}" \
-ti "${obs_image}" bash -c "${cmd}"
}

View File

@ -0,0 +1,19 @@
#!/bin/bash
# Copyright (c) 2018 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
#NOTES:
# - update qemu and the kernel first, they take longer to build
# - runtime is always built at the end, as it depends on all the other listed
# packages, and we need to get the full version of all those.
typeset -a OBS_PKGS_PROJECTS
OBS_PKGS_PROJECTS+=(
qemu-vanilla
linux-container
kata-containers-image
runtime
)

View File

@ -0,0 +1,389 @@
#!/bin/bash
# This is a helper library for the setup scripts of each package
# in this repository.
source_dir_pkg_lib=$(dirname "${BASH_SOURCE[0]}")
source_dir_pkg_lib=$(realpath "${source_dir_pkg_lib}")
source "${source_dir_pkg_lib}/../../scripts/lib.sh"
# Verify that versions.txt exists
version_file="${source_dir_pkg_lib}/../versions.txt"
if [ -f "${version_file}" ]; then
source "${version_file}"
else
die "${version_file} does not exist, you need to run first the gen_versions_txt.sh"
fi
PACKAGING_DIR=/var/packaging
LOG_DIR=${PACKAGING_DIR}/build_logs
# OBS Project info
OBS_PROJECT="${OBS_PROJECT:-katacontainers}"
OBS_SUBPROJECT="${OBS_SUBPROJECT:-alpha}"
# BUILD OPTIONS
BUILD_DISTROS=${BUILD_DISTROS:-Fedora_27 xUbuntu_16.04 CentOS_7}
BUILD_ARCH="$(uname -m)"
COMMIT=false
BRANCH=false
LOCAL_BUILD=false
OBS_PUSH=false
VERBOSE=false
arch_to_golang()
{
local -r arch="$1"
case "$arch" in
aarch64) echo "arm64";;
ppc64le) echo "$arch";;
x86_64) echo "amd64";;
s390x) echo "s390x";;
*) die "unsupported architecture: $arch";;
esac
}
# Used for debian.control files
# Architecture: The architecture specifies which type of hardware this
# package was compiled for.
short_commit_length=10
arch=$(uname -m)
DEB_ARCH=$(arch_to_golang "$arch")
if [[ $DEB_ARCH == "ppc64le" ]]; then
DEB_ARCH="ppc64el"
fi
GO_ARCH=$(arch_to_golang "$arch")
export GO_ARCH
function display_help() {
cat <<-EOL
$SCRIPT_NAME
This script is intended to create Kata Containers packages for the OBS
(Open Build Service) platform.
Usage:
$SCRIPT_NAME [options]
Options:
-l --local-build Build the runtime locally
-b --branch Build with a given branch name
-p --push Push changes to OBS
-a --api-url Especify an OBS API (e.g. custom private OBS)
-r --obs-repository An OBS repository to push the changes.
-w --workdir Directory of a working copy of the OBS runtime repo
-v --verbose Set the -x flag for verbosity
-C --clean Clean the repository
-V --verify Verify the environment
-h --help Display this help message
Usage examples:
$SCRIPT_NAME --local-build --branch staging
$SCRIPT_NAME --push --api-url http://127.0.0.1
$SCRIPT_NAME --push --obs-repository home:userx/repository
$SCRIPT_NAME --push
EOL
exit 1
}
die() {
msg="$*"
echo >&2 "ERROR: $msg"
exit 1
}
info() {
msg="$*"
echo "INFO: $msg"
}
function verify() {
# This function perform some checks in order to make sure
# the script will run flawlessly.
# Make sure this script is called from ./
[ "$SCRIPT_DIR" != "." ] && die "The script must be called from its base dir."
# Verify if osc is installed, exit otherwise.
[ ! -x "$(command -v osc)" ] && die "osc is not installed."
info "OK"
}
function clean() {
# This function clean generated files
for file in "$@"; do
[ -e $file ] && rm -v $file
done
[ -e ./debian.changelog ] && git checkout ./debian.changelog
[ -e ./release ] && git checkout ./release
echo "Clean done."
}
function get_git_info() {
AUTHOR=${AUTHOR:-$(git config user.name)}
AUTHOR_EMAIL=${AUTHOR_EMAIL:-$(git config user.email)}
}
function set_versions() {
local commit_hash="$1"
hash_tag="$commit_hash"
short_hashtag="${hash_tag:0:7}"
}
function changelog_update() {
d=$(date -R)
cat <<<"$PKG_NAME ($VERSION) stable; urgency=medium
* Update $PKG_NAME $VERSION ${hash_tag:0:7}
-- $AUTHOR <$AUTHOR_EMAIL> $d
" >debian.changelog
# Append, so it can be copied to the OBS repository
GENERATED_FILES+=('debian.changelog')
}
function local_build() {
[ ! -e $PACKAGING_DIR ] && mkdir $PACKAGING_DIR
[ ! -e $LOG_DIR ] && mkdir $LOG_DIR
pushd "${obs_repo_dir}"
BUILD_ARGS=('--local-package' '--no-verify' '--noservice' '--trust-all-projects' '--keep-pkgs=/var/packaging/results')
[ "$OFFLINE" == "true" ] && BUILD_ARGS+=('--offline')
osc service run
for distro in ${BUILD_DISTROS[@]}; do
# If more distros are supported, add here the relevant validations.
if [[ $distro =~ ^Fedora.* ]] || [[ $distro =~ ^CentOS.* ]]; then
echo "Perform a local build for ${distro}"
osc build ${BUILD_ARGS[@]} \
${distro} $BUILD_ARCH *.spec | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log
elif [[ $distro =~ ^xUbuntu.* ]]; then
echo "Perform a local build for ${distro}"
osc build ${BUILD_ARGS[@]} \
${distro} $BUILD_ARCH *.dsc | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log
fi
done
popd
}
function checkout_repo() {
local repo="${1}"
export obs_repo_dir="${repo}"
mkdir -p "${obs_repo_dir}"
osc co "${repo}" -o "${obs_repo_dir}"
find "${obs_repo_dir}" -maxdepth 1 -mindepth 1 ! -name '.osc' -prune -exec echo remove {} \; -exec rm -rf {} \;
mv "${GENERATED_FILES[@]}" "${obs_repo_dir}"
cp "${STATIC_FILES[@]}" "$obs_repo_dir"
}
function obs_push() {
pushd "${obs_repo_dir}"
osc addremove
osc commit -m "Update ${PKG_NAME} $VERSION: ${hash_tag:0:7}"
popd
}
function cli() {
OPTS=$(getopt -o abclprwvCVh: --long api-url,branch,commit-id,local-build,push,obs-repository,workdir,verbose,clean,verify,help -- "$@")
while true; do
case "${1}" in
-b | --branch)
BRANCH="true"
OBS_REVISION="$2"
shift 2
;;
-l | --local-build)
LOCAL_BUILD="true"
shift
;;
-p | --push)
OBS_PUSH="true"
shift
;;
-r | --obs-repository)
PROJECT_REPO="$2"
shift 2
;;
-v | --verbose)
VERBOSE="true"
shift
;;
-o | --offline)
OFFLINE="true"
shift
;;
-C | --clean)
clean ${GENERATED_FILES[@]}
exit $?
;;
-V | --verify)
verify
exit $?
;;
-h | --help)
display_help
exit $?
;;
--)
shift
break
;;
*) break ;;
esac
done
}
function build_pkg() {
obs_repository="${1}"
[ -z "${obs_repository}" ] && die "${FUNCNAME}: obs repository not provided"
checkout_repo "${obs_repository}"
if [ "$LOCAL_BUILD" == "true" ]; then
info "Local build"
local_build
fi
if [ "$OBS_PUSH" == "true" ]; then
info "Push build to OBS"
obs_push
fi
}
function generate_files() {
directory=$1
replace_list=$2
template_files=$(find $directory -type f -name "*-template")
replace_list+=("deb_arch=$DEB_ARCH")
#find_patches sets $RPM_PATCH_LIST and $RPM_PATCH_LIST
# It also creates debian.series file
find_patches
replace_list+=("RPM_PATCH_LIST=$RPM_PATCH_LIST")
replace_list+=("RPM_APPLY_PATCHES=$RPM_APPLY_PATCHES")
# check replace list
# key=val
for replace in "${replace_list[@]}"; do
[[ $replace == *"="* ]] || die "invalid replace $replace"
local key="${replace%%=*}"
local value="${replace##*=}"
[ -n "$key" ] || die "${replace} key is empty"
[ -n "$value" ] || die "${replace} val is empty"
grep -q "@$key@" $template_files || die "@$key@ not found in any template file"
done
for f in ${template_files}; do
genfile="${f%-template}"
cp "$f" "${genfile}"
info "Generate file ${genfile}"
for replace in "${replace_list[@]}"; do
[[ $replace == *"="* ]] || die "invalid replace $replace"
local key="${replace%%=*}"
local value="${replace##*=}"
export k="@${key}@"
export v="$value"
perl -p -e 's/$ENV{k}/$ENV{v}/g' "${genfile}" >"${genfile}.out"
mv "${genfile}.out" ${genfile}
done
done
}
function pkg_version() {
local project_version="$1"
# Used for
# Release: in spec file
# DebianRevisionNumber in dsc files
local pkg_release="$2"
local commit_id="$3"
[ -n "${project_version}" ] || die "${FUNCNAME}: need version"
pkg_version="${project_version}"
if [ -n "$commit_id" ]; then
pkg_version+="+git.${commit_id:0:${short_commit_length}}"
fi
if [ -n "$pkg_release" ]; then
pkg_version+="-${pkg_release}"
fi
echo "$pkg_version"
}
function get_obs_pkg_release() {
local obs_pkg_name="$1"
local pkg
local repo_dir
local release=""
pkg=$(basename "${obs_pkg_name}")
repo_dir=$(mktemp -d -u -t "${pkg}.XXXXXXXXXXX")
out=$(osc -v co "${obs_pkg_name}" -o "${repo_dir}") || die "failed to checkout:$out"
spec_file=$(find "${repo_dir}" -maxdepth 1 -type f -name '*.spec' | head -1)
# Find in specfile in Release: XX field.
[ ! -f "${spec_file}" ] || release=$(grep -oP 'Release:\s+[0-9]+' "${spec_file}" | grep -oP '[0-9]+')
if [ -z "${release}" ] && [ -f "${spec_file}" ] ; then
# Not release number found find in "%define release XX"
release=$(grep -oP '%define\s+release\s+[0-9]+' "${spec_file}" | grep -oP '[0-9]+')
fi
release_file=$(find "${repo_dir}" -maxdepth 1 -type f -name 'pkg-release')
if [ -z "${release}" ] && [ -f "${release_file}" ]; then
# Release still not found check pkg-release file
release=$(grep -oP '[0-9]+' "${release_file}")
fi
if [ -z "${release}" ]; then
# Not release number found, this is a new repository.
release=1
fi
rm -r "${repo_dir}"
echo "${release}"
}
#find_patches find patches in 'patches' directory.
# sets $RPM_PATCH_LIST and $RPM_PATCH_LIST
# RPM_PATCH_LIST fomat:
# Patch<number>: patch.file
# RPM_APPLY_PATCHES fomat:
# %Patch<number> -p1
# It also creates debian.series file
function find_patches() {
export RPM_PATCH_LIST="#Patches"$'\n'
export RPM_APPLY_PATCHES="#Apply patches"$'\n'
[ ! -d patches ] && info "No patches found" && return
local patches
patches=$(find patches/ -type f -name '*.patch' -exec basename {} \; | sort -t- -k1,1n)
n="1"
rm -f debian.series
for p in ${patches}; do
STATIC_FILES+=("patches/$p")
RPM_PATCH_LIST+="Patch00${n}: $p"$'\n'
RPM_APPLY_PATCHES+="%patch00${n} -p1"$'\n'
echo "$p" >>debian.series
((n++))
done
GENERATED_FILES+=(debian.series)
}

View File

@ -0,0 +1,307 @@
#!/bin/bash
# Copyright (c) 2019 Intel Corporation
#
# SPDX-License-Identifier: Apache-2.0
#
set -o errexit
set -o nounset
set -o pipefail
set -o errtrace
script_name="$(basename "${BASH_SOURCE[0]}")"
OBS_PROJECT=${OBS_PROJECT:-"home:katacontainers:"}
# Project to wait for
project=""
handle_error() {
local exit_code="${?}"
local line_number="${1:-}"
echo "Failed at $line_number: ${BASH_COMMAND}"
exit "${exit_code}"
}
trap 'handle_error $LINENO' ERR
script_dir=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
run_in_docker() {
if [ -n "${USE_DOCKER:-}" ]; then
# shellcheck source=scripts/obs-docker.sh
source "${script_dir}/scripts/obs-docker.sh"
packaging_repo_dir=$(cd "${script_dir}/.." && pwd)
docker_run "${packaging_repo_dir}/obs-packaging/wait-obs.sh" $@
exit 0
fi
}
# project information
project=""
# repo information
repo=""
repo_state=""
repo_code=""
# package information
package=""
package_code=""
package_details=""
# packages still building
packages_building=0
fail=0
return=0
continue=0
result_handler() {
# reset project information
project=""
# reset repo information
repo=""
repo_state=""
repo_code=""
local IFS=' '
for i in $1; do
case $(echo $i | cut -d= -f1) in
project)
project=$(echo $i | cut -d= -f2 | tr -d '"')
;;
repository)
repo=$(echo $i | cut -d= -f2 | tr -d '"')
;;
code)
repo_code=$(echo $i | cut -d= -f2 | tr -d '"')
;;
state)
repo_state=$(echo $i | cut -d= -f2 | tr -d '"')
;;
esac
done
case "${repo_code}" in
blocked)
continue=1
;;
unresolvable)
fail=1
;;
excluded)
return=1
;;
esac
}
status_handler() {
# reset package information
package=""
package_code=""
package_details=""
local IFS=' '
for i in $1; do
case $(echo $i | cut -d= -f1) in
package)
package=$(echo $i | cut -d= -f2 | tr -d '"')
;;
code)
package_code=$(echo $i | cut -d= -f2 | tr -d '"')
;;
esac
done
case "${package_code}" in
blocked)
continue=1
;;
unresolvable)
fail=1
;;
excluded)
return=1
;;
esac
}
details_handler() {
# reset package details
package_details="$(echo $1 | cut -d\> -f2 | cut -d\< -f1)"
if [ "$package_details" == "failed" ]; then
fail=1
osc pr
return
fi
if [ "$package_details" == "broken" ]; then
fail=1
return
fi
if [ "${package_details}" != "succeeded" ] || [ "${package_code}" != "finished" ]; then
packages_building=$((packages_building+1))
fi
}
check_repo() {
if [ -z "${repo}" ]; then
return
fi
}
dump_info() {
echo "package: $package, code: $package_code, details: $package_details"
echo "repository: $repo, state: $repo_state, code: $repo_code"
echo "For more information go to https://build.opensuse.org/package/live_build_log/${project}/${package}/${repo}/$(uname -m)"
}
# Check all project has finshed the build
wait_finish_building() {
local out
while true; do
sleep 30
out=$(osc api "/build/${project}/_result")
continue=0
packages_building=0
local IFS=$'\n'
for i in ${out[*]}; do
i="$(echo $i | sed -e 's/^[[:space:]]*//' -e 's/^<//' -e 's/>$//')"
if echo "$i" | egrep -q "^result"; then
result_handler "$i"
elif echo "$i" | egrep -q "^status"; then
status_handler "$i"
elif echo "$i" | egrep -q "^details"; then
details_handler "$i"
fi
if [ $fail -eq 1 ]; then
echo -n "FAILED: "
dump_info
exit 1
elif [ $return -eq 1 ]; then
return
elif [ $packages_building -gt 0 ]; then
break
fi
done
if [ $continue -eq 1 ]; then
continue
fi
if [ $packages_building -gt 0 ]; then
echo -n "BULDING: "
dump_info
else
echo "FINISHED: SUCCEEDED!"
break
fi
done
}
# obs distro final status is 'published'
# Check all distros are published
is_published() {
columns=$(osc pr -q -c | head -1 | column -t -s\;)
# print to show status
for c in ${columns}; do
if [ "${c}" == '_' ]; then
continue
fi
if ! echo "${c}" | grep 'published'; then
echo "waiting for : ${c}"
return 1
fi
done
return 0
}
# Wait that all repositories are published
wait_published() {
while ! is_published; do
echo "Waitling for all repos are published"
done
}
check_failed() {
failed_query=$(osc pr -c -s F)
if [[ ${failed_query} =~ failed ]]; then
echo "ERROR: Build failed"
osc pr -V -s 'F'
exit 1
fi
echo "Nothing failed"
osc pr -q -c | tail -n +2 | column -t -s\;
return 0
}
usage() {
msg="${1:-}"
exit_code=$"${2:-0}"
cat <<EOT
${msg}
Usage:
${script_name} [--options]
options:
-h, --help: Show this help
--no-wait-publish : no wait that OBS publish packages
EOT
exit "${exit_code}"
}
main() {
run_in_docker $@
local no_wait_publish="false"
case "${1:-}" in
"-h" | "--help")
usage "Help" 0
;;
--no-wait-publish)
no_wait_publish="true"
shift
;;
-*)
usage "Invalid option: ${1:-}" 1
;;
esac
project=${1:-}
if [ "${project}" == "" ]; then
OBS_SUBPROJECT="${OBS_SUBPROJECT:-}"
project="${OBS_PROJECT}${OBS_SUBPROJECT}"
fi
echo "Checkout: ${project}"
osc co "$project" || true
cd "$project" || exit 1
echo "Wait all is build"
wait_finish_building
echo "OK - build finished"
echo "Check failed"
check_failed
echo "OK - build did not fail"
if [ "${no_wait_publish}" == "true" ]; then
echo " Requested not wait for publish"
exit
fi
echo "Wait for published"
wait_published
echo "OK - published"
}
main $@