From 93b60a8327bc50b5feb0596f8bfde5eec7798808 Mon Sep 17 00:00:00 2001 From: Eric Ernst Date: Tue, 6 Oct 2020 08:46:39 -0700 Subject: [PATCH] packaging: Revert "packaging: Stop providing OBS packages" This reverts commit c0ea910273371f899ff2d8a1029c45ff45344260. 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 --- tools/packaging/README.md | 5 + tools/packaging/obs-packaging/Dockerfile | 12 + tools/packaging/obs-packaging/Makefile | 8 + tools/packaging/obs-packaging/README.md | 11 + tools/packaging/obs-packaging/build_all.sh | 105 + .../obs-packaging/build_from_docker.sh | 68 + .../obs-packaging/create-repo-branch.sh | 191 ++ tools/packaging/obs-packaging/distros_ppc64le | 12 + tools/packaging/obs-packaging/distros_x86_64 | 20 + .../packaging/obs-packaging/download_image.sh | 53 + .../obs-packaging/gen_versions_txt.sh | 188 ++ .../kata-containers-image/LICENSE | 2079 +++++++++++++++++ .../kata-containers-image/build_image.sh | 120 + .../kata-containers-image/debian.compat | 1 + .../debian.control-template | 12 + .../kata-containers-image/debian.dirs | 1 + .../debian.rules-template | 17 + .../kata-containers-image.dsc-template | 14 + .../kata-containers-image.spec-template | 43 + .../kata-containers-image/update.sh | 62 + .../linux-container/Makefile.dist.install | 25 + .../linux-container/_service-template | 13 + .../linux-container/debian.compat | 1 + .../linux-container/debian.control-template | 18 + .../linux-container/debian.copyright | 30 + .../obs-packaging/linux-container/debian.dirs | 1 + .../linux-container/debian.rules | 63 + .../kata-linux-container.dsc-template | 20 + .../kata-linux-container.spec-template | 165 ++ .../linux-container/kata-multiarch.sh | 60 + .../obs-packaging/linux-container/update.sh | 72 + tools/packaging/obs-packaging/maintainers | 3 + tools/packaging/obs-packaging/projectconfig | 1 + ...modification-of-the-whole-Eric-Auger.patch | 1145 +++++++++ .../qemu-vanilla/_service-template | 16 + .../obs-packaging/qemu-vanilla/debian.compat | 1 + .../qemu-vanilla/debian.control-template | 13 + .../qemu-vanilla/debian.rules-template | 26 + .../qemu-vanilla/qemu-vanilla-rpmlintrc | 1 + .../qemu-vanilla/qemu-vanilla.dsc-template | 16 + .../qemu-vanilla/qemu-vanilla.spec-template | 135 ++ .../obs-packaging/qemu-vanilla/update.sh | 53 + .../obs-packaging/runtime/_service-template | 26 + .../obs-packaging/runtime/debian.compat | 1 + .../runtime/debian.control-template | 17 + .../runtime/debian.rules-template | 46 + .../runtime/kata-runtime.dsc-template | 22 + .../runtime/kata-runtime.spec-template | 97 + .../packaging/obs-packaging/runtime/update.sh | 135 ++ .../obs-packaging/scripts/obs-docker.sh | 68 + .../obs-packaging/scripts/obs-pkgs.sh | 19 + .../packaging/obs-packaging/scripts/pkglib.sh | 389 +++ tools/packaging/obs-packaging/wait-obs.sh | 307 +++ 53 files changed, 6027 insertions(+) create mode 100644 tools/packaging/obs-packaging/Dockerfile create mode 100644 tools/packaging/obs-packaging/Makefile create mode 100644 tools/packaging/obs-packaging/README.md create mode 100755 tools/packaging/obs-packaging/build_all.sh create mode 100755 tools/packaging/obs-packaging/build_from_docker.sh create mode 100755 tools/packaging/obs-packaging/create-repo-branch.sh create mode 100644 tools/packaging/obs-packaging/distros_ppc64le create mode 100644 tools/packaging/obs-packaging/distros_x86_64 create mode 100755 tools/packaging/obs-packaging/download_image.sh create mode 100755 tools/packaging/obs-packaging/gen_versions_txt.sh create mode 100644 tools/packaging/obs-packaging/kata-containers-image/LICENSE create mode 100755 tools/packaging/obs-packaging/kata-containers-image/build_image.sh create mode 100644 tools/packaging/obs-packaging/kata-containers-image/debian.compat create mode 100644 tools/packaging/obs-packaging/kata-containers-image/debian.control-template create mode 100644 tools/packaging/obs-packaging/kata-containers-image/debian.dirs create mode 100755 tools/packaging/obs-packaging/kata-containers-image/debian.rules-template create mode 100644 tools/packaging/obs-packaging/kata-containers-image/kata-containers-image.dsc-template create mode 100644 tools/packaging/obs-packaging/kata-containers-image/kata-containers-image.spec-template create mode 100755 tools/packaging/obs-packaging/kata-containers-image/update.sh create mode 100644 tools/packaging/obs-packaging/linux-container/Makefile.dist.install create mode 100644 tools/packaging/obs-packaging/linux-container/_service-template create mode 100644 tools/packaging/obs-packaging/linux-container/debian.compat create mode 100644 tools/packaging/obs-packaging/linux-container/debian.control-template create mode 100644 tools/packaging/obs-packaging/linux-container/debian.copyright create mode 100644 tools/packaging/obs-packaging/linux-container/debian.dirs create mode 100755 tools/packaging/obs-packaging/linux-container/debian.rules create mode 100644 tools/packaging/obs-packaging/linux-container/kata-linux-container.dsc-template create mode 100644 tools/packaging/obs-packaging/linux-container/kata-linux-container.spec-template create mode 100644 tools/packaging/obs-packaging/linux-container/kata-multiarch.sh create mode 100755 tools/packaging/obs-packaging/linux-container/update.sh create mode 100644 tools/packaging/obs-packaging/maintainers create mode 100644 tools/packaging/obs-packaging/projectconfig create mode 100644 tools/packaging/obs-packaging/qemu-aarch64/patches/0001-qemu-gather-and-modification-of-the-whole-Eric-Auger.patch create mode 100644 tools/packaging/obs-packaging/qemu-vanilla/_service-template create mode 100644 tools/packaging/obs-packaging/qemu-vanilla/debian.compat create mode 100644 tools/packaging/obs-packaging/qemu-vanilla/debian.control-template create mode 100644 tools/packaging/obs-packaging/qemu-vanilla/debian.rules-template create mode 100644 tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla-rpmlintrc create mode 100644 tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla.dsc-template create mode 100644 tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla.spec-template create mode 100755 tools/packaging/obs-packaging/qemu-vanilla/update.sh create mode 100644 tools/packaging/obs-packaging/runtime/_service-template create mode 100644 tools/packaging/obs-packaging/runtime/debian.compat create mode 100644 tools/packaging/obs-packaging/runtime/debian.control-template create mode 100644 tools/packaging/obs-packaging/runtime/debian.rules-template create mode 100644 tools/packaging/obs-packaging/runtime/kata-runtime.dsc-template create mode 100644 tools/packaging/obs-packaging/runtime/kata-runtime.spec-template create mode 100755 tools/packaging/obs-packaging/runtime/update.sh create mode 100755 tools/packaging/obs-packaging/scripts/obs-docker.sh create mode 100755 tools/packaging/obs-packaging/scripts/obs-pkgs.sh create mode 100644 tools/packaging/obs-packaging/scripts/pkglib.sh create mode 100755 tools/packaging/obs-packaging/wait-obs.sh diff --git a/tools/packaging/README.md b/tools/packaging/README.md index 0fbf4be31d..7a8a7125ec 100644 --- a/tools/packaging/README.md +++ b/tools/packaging/README.md @@ -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 diff --git a/tools/packaging/obs-packaging/Dockerfile b/tools/packaging/obs-packaging/Dockerfile new file mode 100644 index 0000000000..4e3e6b755d --- /dev/null +++ b/tools/packaging/obs-packaging/Dockerfile @@ -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 diff --git a/tools/packaging/obs-packaging/Makefile b/tools/packaging/obs-packaging/Makefile new file mode 100644 index 0000000000..25139136b3 --- /dev/null +++ b/tools/packaging/obs-packaging/Makefile @@ -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 {} \; diff --git a/tools/packaging/obs-packaging/README.md b/tools/packaging/obs-packaging/README.md new file mode 100644 index 0000000000..757a410588 --- /dev/null +++ b/tools/packaging/obs-packaging/README.md @@ -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. diff --git a/tools/packaging/obs-packaging/build_all.sh b/tools/packaging/obs-packaging/build_all.sh new file mode 100755 index 0000000000..7045a30ddb --- /dev/null +++ b/tools/packaging/obs-packaging/build_all.sh @@ -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 < [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 $@ diff --git a/tools/packaging/obs-packaging/build_from_docker.sh b/tools/packaging/obs-packaging/build_from_docker.sh new file mode 100755 index 0000000000..3f52d1715f --- /dev/null +++ b/tools/packaging/obs-packaging/build_from_docker.sh @@ -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 + 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 "$@" diff --git a/tools/packaging/obs-packaging/create-repo-branch.sh b/tools/packaging/obs-packaging/create-repo-branch.sh new file mode 100755 index 0000000000..1e2ce426aa --- /dev/null +++ b/tools/packaging/obs-packaging/create-repo-branch.sh @@ -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 " " + + echo "${repositories}"| tr ',' '\n' | while read -r repository; do + echo " " + done + + arch_target_obs=${arch_target} + if [ "$arch_target" == "ppc64" ]; then + arch_target_obs="ppc64le" + fi + echo " ${arch_target_obs}" + echo " " + 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 " " + 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 " " + echo " " + echo " " + 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 < + Branch project for Kata Containers branch ${branch} + This project is the Kata Containers branch ${branch} +$(create_publish_xml_node) +$(create_maintainers_xml_nodes) +$(create_repos_xml_nodes) + +EOT +} + +usage() { + msg="${1:-}" + exit_code=$"${2:-0}" + cat < +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 $@ diff --git a/tools/packaging/obs-packaging/distros_ppc64le b/tools/packaging/obs-packaging/distros_ppc64le new file mode 100644 index 0000000000..f8e58d6191 --- /dev/null +++ b/tools/packaging/obs-packaging/distros_ppc64le @@ -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 diff --git a/tools/packaging/obs-packaging/distros_x86_64 b/tools/packaging/obs-packaging/distros_x86_64 new file mode 100644 index 0000000000..4e274d204b --- /dev/null +++ b/tools/packaging/obs-packaging/distros_x86_64 @@ -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 diff --git a/tools/packaging/obs-packaging/download_image.sh b/tools/packaging/obs-packaging/download_image.sh new file mode 100755 index 0000000000..48f4243a1a --- /dev/null +++ b/tools/packaging/obs-packaging/download_image.sh @@ -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}" diff --git a/tools/packaging/obs-packaging/gen_versions_txt.sh b/tools/packaging/obs-packaging/gen_versions_txt.sh new file mode 100755 index 0000000000..027a3fe9e3 --- /dev/null +++ b/tools/packaging/obs-packaging/gen_versions_txt.sh @@ -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" < + +Generate a ${versions_txt} file, containing version numbers and commit hashes +of all the kata components under the git branch . + +Options: + +-h, --help Print this help. +--compare Only compare the kata version at branch with the + one in ${versions_txt} and leave the file untouched. +--head Use '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/ - 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 $@ diff --git a/tools/packaging/obs-packaging/kata-containers-image/LICENSE b/tools/packaging/obs-packaging/kata-containers-image/LICENSE new file mode 100644 index 0000000000..fad5df1720 --- /dev/null +++ b/tools/packaging/obs-packaging/kata-containers-image/LICENSE @@ -0,0 +1,2079 @@ +NOTE: + This license has been obsoleted by the change to the BSD-style copyright. + You may continue to use this license if you wish, but you are under no + obligation to do so. + +(* +This document is freely plagiarised from the 'Artistic Licence', +distributed as part of the Perl v4.0 kit by Larry Wall, which is +available from most major archive sites. I stole it from CrackLib. + + $Id$ +*) + +This documents purpose is to state the conditions under which this +Package (See definition below) viz: "Shadow", the Shadow Password Suite +which is held by Julianne Frances Haugh, may be copied, such that the +copyright holder maintains some semblance of artistic control over the +development of the package, while giving the users of the package the +right to use and distribute the Package in a more-or-less customary +fashion, plus the right to make reasonable modifications. + +So there. + +*************************************************************************** + +Definitions: + + +A "Package" refers to the collection of files distributed by the +Copyright Holder, and derivatives of that collection of files created +through textual modification, or segments thereof. + +"Standard Version" refers to such a Package if it has not been modified, +or has been modified in accordance with the wishes of the Copyright +Holder. + +"Copyright Holder" is whoever is named in the copyright or copyrights +for the package. + +"You" is you, if you're thinking about copying or distributing this +Package. + +"Reasonable copying fee" is whatever you can justify on the basis of +media cost, duplication charges, time of people involved, and so on. +(You will not be required to justify it to the Copyright Holder, but +only to the computing community at large as a market that must bear the +fee.) + +"Freely Available" means that no fee is charged for the item itself, +though there may be fees involved in handling the item. It also means +that recipients of the item may redistribute it under the same +conditions they received it. + + +1. You may make and give away verbatim copies of the source form of the +Standard Version of this Package without restriction, provided that you +duplicate all of the original copyright notices and associated +disclaimers. + +2. You may apply bug fixes, portability fixes and other modifications +derived from the Public Domain or from the Copyright Holder. A Package +modified in such a way shall still be considered the Standard Version. + +3. You may otherwise modify your copy of this Package in any way, +provided that you insert a prominent notice in each changed file stating +how and when AND WHY you changed that file, and provided that you do at +least ONE of the following: + +a) place your modifications in the Public Domain or otherwise make them +Freely Available, such as by posting said modifications to Usenet or an +equivalent medium, or placing the modifications on a major archive site +such as uunet.uu.net, or by allowing the Copyright Holder to include +your modifications in the Standard Version of the Package. + +b) use the modified Package only within your corporation or organization. + +c) rename any non-standard executables so the names do not conflict with +standard executables, which must also be provided, and provide separate +documentation for each non-standard executable that clearly documents +how it differs from the Standard Version. + +d) make other distribution arrangements with the Copyright Holder. + +4. You may distribute the programs of this Package in object code or +executable form, provided that you do at least ONE of the following: + +a) distribute a Standard Version of the executables and library files, +together with instructions (in the manual page or equivalent) on where +to get the Standard Version. + +b) accompany the distribution with the machine-readable source of the +Package with your modifications. + +c) accompany any non-standard executables with their corresponding +Standard Version executables, giving the non-standard executables +non-standard names, and clearly documenting the differences in manual +pages (or equivalent), together with instructions on where to get the +Standard Version. + +d) make other distribution arrangements with the Copyright Holder. + +5. You may charge a reasonable copying fee for any distribution of this +Package. You may charge any fee you choose for support of this Package. +YOU MAY NOT CHARGE A FEE FOR THIS PACKAGE ITSELF. However, you may +distribute this Package in aggregate with other (possibly commercial) +programs as part of a larger (possibly commercial) software distribution +provided that YOU DO NOT ADVERTISE this package as a product of your +own. + +6. The name of the Copyright Holder may not be used to endorse or +promote products derived from this software without specific prior +written permission. + +7. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF +MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. + + The End + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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, either version 3 of the License, or + (at your option) any later version. + + 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, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + 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; either version 2 of the License, or + (at your option) any later version. + + 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 Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. +EXT2ED is hereby placed under the terms of the GNU General Public License. +Follows the GNU license. + +Gadi Oxman, August 1995 + +--------------------------------------------------------------------------- + + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc. + 675 Mass Ave, Cambridge, MA 02139, USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Library General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + Appendix: How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) 19yy + + 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; either version 2 of the License, or + (at your option) any later version. + + 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., 675 Mass Ave, Cambridge, MA 02139, USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) 19yy name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Library General +Public License instead of this License. +This is the Debian GNU/Linux prepackaged version of the EXT2 file +system utilities (e2fsck, mke2fs, etc.). The EXT2 utilities were +written by Theodore Ts'o and Remy Card . + +Sources were obtained from http://sourceforge.net/projects/e2fsprogs + +Packaging is Copyright (c) 2003-2007 Theodore Ts'o + Copyright (c) 1997-2003 Yann Dirson + Copyright (c) 2001 Alcove + Copyright (c) 1997 Klee Dienes + Copyright (c) 1995-1996 Michael Nonweiler + +Upstream Author: Theodore Ts'o + +Copyright notice: + +This package, the EXT2 filesystem utilities, are made available under +the GNU General Public License version 2, with the exception of the +lib/ext2fs and lib/e2p libraries, which are made available under the +GNU Library General Public License Version 2, the lib/uuid library +which is made available under a BSD-style license and the lib/et and +lib/ss libraries which are made available under an MIT-style license. + + Copyright (c) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, + 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008 by Theodore Ts'o + +On Debian GNU systems, the complete text of the GNU General Public +License can be found in `/usr/share/common-licenses/GPL-2'. The +complete text of the GNU Library General Public License can be found +in '/usr/share/common-licenses/LGPL-2'. + + +The license used for lib/et and lib/ss libraries is: + + Copyright 1987 by the Student Information Processing Board + of the Massachusetts Institute of Technology + + Permission to use, copy, modify, and distribute this software and + its documentation for any purpose is hereby granted, provided that + the names of M.I.T. and the M.I.T. S.I.P.B. not be used in + advertising or publicity pertaining to distribution of the software + without specific, written prior permission. M.I.T. and the + M.I.T. S.I.P.B. make no representations about the suitability of + this software for any purpose. It is provided "as is" without + express or implied warranty. + +The license used for lib/uuid is: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, and the entire permission notice in its entirety, + including the disclaimer of warranties. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + 3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED + WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF + WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE + LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT + OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE + USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH + DAMAGE. +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: +1. Redistributions of source code must retain the above copyright + notice, and the entire permission notice in its entirety, + including the disclaimer of warranties. +2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. +3. The name of the author may not be used to endorse or promote + products derived from this software without specific prior + written permission. + +THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED +WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ALL OF +WHICH ARE HEREBY DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT +OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR +BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF +LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE +USE OF THIS SOFTWARE, EVEN IF NOT ADVISED OF THE POSSIBILITY OF SUCH +DAMAGE. diff --git a/tools/packaging/obs-packaging/kata-containers-image/build_image.sh b/tools/packaging/obs-packaging/kata-containers-image/build_image.sh new file mode 100755 index 0000000000..fdd16f6021 --- /dev/null +++ b/tools/packaging/obs-packaging/kata-containers-image/build_image.sh @@ -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 < : 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 $* diff --git a/tools/packaging/obs-packaging/kata-containers-image/debian.compat b/tools/packaging/obs-packaging/kata-containers-image/debian.compat new file mode 100644 index 0000000000..ec635144f6 --- /dev/null +++ b/tools/packaging/obs-packaging/kata-containers-image/debian.compat @@ -0,0 +1 @@ +9 diff --git a/tools/packaging/obs-packaging/kata-containers-image/debian.control-template b/tools/packaging/obs-packaging/kata-containers-image/debian.control-template new file mode 100644 index 0000000000..fa2dd838df --- /dev/null +++ b/tools/packaging/obs-packaging/kata-containers-image/debian.control-template @@ -0,0 +1,12 @@ +Source: kata-containers-image +Section: devel +Priority: optional +Maintainer: Kata containers team +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 + diff --git a/tools/packaging/obs-packaging/kata-containers-image/debian.dirs b/tools/packaging/obs-packaging/kata-containers-image/debian.dirs new file mode 100644 index 0000000000..04732809d8 --- /dev/null +++ b/tools/packaging/obs-packaging/kata-containers-image/debian.dirs @@ -0,0 +1 @@ +usr/share/kata-containers diff --git a/tools/packaging/obs-packaging/kata-containers-image/debian.rules-template b/tools/packaging/obs-packaging/kata-containers-image/debian.rules-template new file mode 100755 index 0000000000..cb842c86c1 --- /dev/null +++ b/tools/packaging/obs-packaging/kata-containers-image/debian.rules-template @@ -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 ; diff --git a/tools/packaging/obs-packaging/kata-containers-image/kata-containers-image.dsc-template b/tools/packaging/obs-packaging/kata-containers-image/kata-containers-image.dsc-template new file mode 100644 index 0000000000..e1b6fec38a --- /dev/null +++ b/tools/packaging/obs-packaging/kata-containers-image/kata-containers-image.dsc-template @@ -0,0 +1,14 @@ +Format: 3.0 (quilt) +Source: kata-containers-image +Version: @VERSION@-@RELEASE@ +Section: devel +Priority: optional +Maintainer: Kata containers team +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 diff --git a/tools/packaging/obs-packaging/kata-containers-image/kata-containers-image.spec-template b/tools/packaging/obs-packaging/kata-containers-image/kata-containers-image.spec-template new file mode 100644 index 0000000000..16a1f83fc3 --- /dev/null +++ b/tools/packaging/obs-packaging/kata-containers-image/kata-containers-image.spec-template @@ -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 diff --git a/tools/packaging/obs-packaging/kata-containers-image/update.sh b/tools/packaging/obs-packaging/kata-containers-image/update.sh new file mode 100755 index 0000000000..3bec565986 --- /dev/null +++ b/tools/packaging/obs-packaging/kata-containers-image/update.sh @@ -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}" diff --git a/tools/packaging/obs-packaging/linux-container/Makefile.dist.install b/tools/packaging/obs-packaging/linux-container/Makefile.dist.install new file mode 100644 index 0000000000..21231c7a96 --- /dev/null +++ b/tools/packaging/obs-packaging/linux-container/Makefile.dist.install @@ -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 diff --git a/tools/packaging/obs-packaging/linux-container/_service-template b/tools/packaging/obs-packaging/linux-container/_service-template new file mode 100644 index 0000000000..8e392891dc --- /dev/null +++ b/tools/packaging/obs-packaging/linux-container/_service-template @@ -0,0 +1,13 @@ + + + + https + cdn.kernel.org + /pub/linux/kernel/v5.x/linux-@VERSION@.tar.xz + + + _service:download_url:linux-@VERSION@.tar.xz + sha256 + @KERNEL_SHA256@ + + diff --git a/tools/packaging/obs-packaging/linux-container/debian.compat b/tools/packaging/obs-packaging/linux-container/debian.compat new file mode 100644 index 0000000000..ec635144f6 --- /dev/null +++ b/tools/packaging/obs-packaging/linux-container/debian.compat @@ -0,0 +1 @@ +9 diff --git a/tools/packaging/obs-packaging/linux-container/debian.control-template b/tools/packaging/obs-packaging/linux-container/debian.control-template new file mode 100644 index 0000000000..eca9471740 --- /dev/null +++ b/tools/packaging/obs-packaging/linux-container/debian.control-template @@ -0,0 +1,18 @@ +Source: kata-linux-container +Section: devel +Priority: optional +Maintainer: Kata containers team +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. diff --git a/tools/packaging/obs-packaging/linux-container/debian.copyright b/tools/packaging/obs-packaging/linux-container/debian.copyright new file mode 100644 index 0000000000..6372a6fc96 --- /dev/null +++ b/tools/packaging/obs-packaging/linux-container/debian.copyright @@ -0,0 +1,30 @@ +This is the Kata containers prepackaged version of the Linux kernel. +Linux was written by Linus Torvalds +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 /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: diff --git a/tools/packaging/obs-packaging/linux-container/kata-linux-container.dsc-template b/tools/packaging/obs-packaging/linux-container/kata-linux-container.dsc-template new file mode 100644 index 0000000000..72ec11b312 --- /dev/null +++ b/tools/packaging/obs-packaging/linux-container/kata-linux-container.dsc-template @@ -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 +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. diff --git a/tools/packaging/obs-packaging/linux-container/kata-linux-container.spec-template b/tools/packaging/obs-packaging/linux-container/kata-linux-container.spec-template new file mode 100644 index 0000000000..0d0c062df1 --- /dev/null +++ b/tools/packaging/obs-packaging/linux-container/kata-linux-container.spec-template @@ -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} diff --git a/tools/packaging/obs-packaging/linux-container/kata-multiarch.sh b/tools/packaging/obs-packaging/linux-container/kata-multiarch.sh new file mode 100644 index 0000000000..1a81e6caf0 --- /dev/null +++ b/tools/packaging/obs-packaging/linux-container/kata-multiarch.sh @@ -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 diff --git a/tools/packaging/obs-packaging/linux-container/update.sh b/tools/packaging/obs-packaging/linux-container/update.sh new file mode 100755 index 0000000000..874a039a76 --- /dev/null +++ b/tools/packaging/obs-packaging/linux-container/update.sh @@ -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}" diff --git a/tools/packaging/obs-packaging/maintainers b/tools/packaging/obs-packaging/maintainers new file mode 100644 index 0000000000..8def7b51e8 --- /dev/null +++ b/tools/packaging/obs-packaging/maintainers @@ -0,0 +1,3 @@ +egernst +jcvenega +nitkon diff --git a/tools/packaging/obs-packaging/projectconfig b/tools/packaging/obs-packaging/projectconfig new file mode 100644 index 0000000000..0663c1b53f --- /dev/null +++ b/tools/packaging/obs-packaging/projectconfig @@ -0,0 +1 @@ +ExpandFlags: module:python36-3.6 diff --git a/tools/packaging/obs-packaging/qemu-aarch64/patches/0001-qemu-gather-and-modification-of-the-whole-Eric-Auger.patch b/tools/packaging/obs-packaging/qemu-aarch64/patches/0001-qemu-gather-and-modification-of-the-whole-Eric-Auger.patch new file mode 100644 index 0000000000..3d54eda4f6 --- /dev/null +++ b/tools/packaging/obs-packaging/qemu-aarch64/patches/0001-qemu-gather-and-modification-of-the-whole-Eric-Auger.patch @@ -0,0 +1,1145 @@ +From 555d66904a7670f673c74aff5834ef20167786fb Mon Sep 17 00:00:00 2001 +From: anonymous +Date: Wed, 28 Nov 2018 17:23:15 +0800 +Subject: [PATCH] qemu: gather and modification of the whole Eric Auger's + PCDIMMM/NVDIMM patch set + +This patch set is mainly based on Eric Auger's PCDIMMM/NVDIMM patch set,which +is located here(https://patchwork.kernel.org/cover/10647305/). In order to rebase +Eric Auger's patch set on tag/v3.1.0-rc3, we had to do some minor modification, +including KVM_CAP_ARM_VM_IPA_SIZE inconsistent with linux kernel, etc. +--- + accel/kvm/kvm-all.c | 2 +- + default-configs/aarch64-softmmu.mak | 2 + + default-configs/arm-softmmu.mak | 2 + + hw/acpi/aml-build.c | 50 +++++ + hw/acpi/nvdimm.c | 28 ++- + hw/arm/boot.c | 120 +++++++++-- + hw/arm/virt-acpi-build.c | 10 + + hw/arm/virt.c | 300 +++++++++++++++++++++++++--- + hw/i386/pc_piix.c | 8 +- + hw/i386/pc_q35.c | 8 +- + hw/ppc/mac_newworld.c | 3 +- + hw/ppc/mac_oldworld.c | 2 +- + hw/ppc/spapr.c | 2 +- + include/hw/acpi/aml-build.h | 3 + + include/hw/arm/virt.h | 5 + + include/hw/boards.h | 2 +- + include/hw/mem/nvdimm.h | 12 ++ + linux-headers/linux/kvm.h | 11 + + target/arm/kvm.c | 8 + + target/arm/kvm_arm.h | 16 ++ + vl.c | 6 +- + 21 files changed, 529 insertions(+), 71 deletions(-) + +diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c +index 4880a05399..320a3ece22 100644 +--- a/accel/kvm/kvm-all.c ++++ b/accel/kvm/kvm-all.c +@@ -1590,7 +1590,7 @@ static int kvm_init(MachineState *ms) + + kvm_type = qemu_opt_get(qemu_get_machine_opts(), "kvm-type"); + if (mc->kvm_type) { +- type = mc->kvm_type(kvm_type); ++ type = mc->kvm_type(ms, kvm_type); + } else if (kvm_type) { + ret = -EINVAL; + fprintf(stderr, "Invalid argument kvm-type=%s\n", kvm_type); +diff --git a/default-configs/aarch64-softmmu.mak b/default-configs/aarch64-softmmu.mak +index 4ea9add003..e43fe23b4b 100644 +--- a/default-configs/aarch64-softmmu.mak ++++ b/default-configs/aarch64-softmmu.mak +@@ -10,3 +10,5 @@ CONFIG_XLNX_ZYNQMP=y + CONFIG_XLNX_ZYNQMP_ARM=y + CONFIG_XLNX_VERSAL=y + CONFIG_ARM_SMMUV3=y ++CONFIG_MEM_DEVICE=y ++CONFIG_DIMM=y +diff --git a/default-configs/arm-softmmu.mak b/default-configs/arm-softmmu.mak +index 2420491aac..2f9e57ca41 100644 +--- a/default-configs/arm-softmmu.mak ++++ b/default-configs/arm-softmmu.mak +@@ -159,3 +159,5 @@ CONFIG_PCI_DESIGNWARE=y + CONFIG_STRONGARM=y + CONFIG_HIGHBANK=y + CONFIG_MUSICPAL=y ++CONFIG_NVDIMM=y ++CONFIG_ACPI_NVDIMM=y +diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c +index 1e43cd736d..62e982b76a 100644 +--- a/hw/acpi/aml-build.c ++++ b/hw/acpi/aml-build.c +@@ -22,6 +22,7 @@ + #include "qemu/osdep.h" + #include + #include "hw/acpi/aml-build.h" ++#include "hw/mem/memory-device.h" + #include "qemu/bswap.h" + #include "qemu/bitops.h" + #include "sysemu/numa.h" +@@ -1802,3 +1803,52 @@ build_hdr: + build_header(linker, tbl, (void *)(tbl->data + fadt_start), + "FACP", tbl->len - fadt_start, f->rev, oem_id, oem_table_id); + } ++ ++void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base, ++ uint64_t len, int default_node) ++{ ++ MemoryDeviceInfoList *info_list = qmp_memory_device_list(); ++ MemoryDeviceInfoList *info; ++ MemoryDeviceInfo *mi; ++ PCDIMMDeviceInfo *di; ++ uint64_t end = base + len, cur, size; ++ bool is_nvdimm; ++ AcpiSratMemoryAffinity *numamem; ++ MemoryAffinityFlags flags; ++ ++ for (cur = base, info = info_list; ++ cur < end; ++ cur += size, info = info->next) { ++ numamem = acpi_data_push(table_data, sizeof *numamem); ++ ++ if (!info) { ++ build_srat_memory(numamem, cur, end - cur, default_node, ++ MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); ++ break; ++ } ++ ++ mi = info->value; ++ is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM); ++ di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; ++ ++ if (cur < di->addr) { ++ build_srat_memory(numamem, cur, di->addr - cur, default_node, ++ MEM_AFFINITY_HOTPLUGGABLE | MEM_AFFINITY_ENABLED); ++ numamem = acpi_data_push(table_data, sizeof *numamem); ++ } ++ ++ size = di->size; ++ ++ flags = MEM_AFFINITY_ENABLED; ++ if (di->hotpluggable) { ++ flags |= MEM_AFFINITY_HOTPLUGGABLE; ++ } ++ if (is_nvdimm) { ++ flags |= MEM_AFFINITY_NON_VOLATILE; ++ } ++ ++ build_srat_memory(numamem, di->addr, size, di->node, flags); ++ } ++ ++ qapi_free_MemoryDeviceInfoList(info_list); ++} +diff --git a/hw/acpi/nvdimm.c b/hw/acpi/nvdimm.c +index e53b2cb681..da68de5535 100644 +--- a/hw/acpi/nvdimm.c ++++ b/hw/acpi/nvdimm.c +@@ -929,8 +929,8 @@ void nvdimm_init_acpi_state(AcpiNVDIMMState *state, MemoryRegion *io, + FWCfgState *fw_cfg, Object *owner) + { + memory_region_init_io(&state->io_mr, owner, &nvdimm_dsm_ops, state, +- "nvdimm-acpi-io", NVDIMM_ACPI_IO_LEN); +- memory_region_add_subregion(io, NVDIMM_ACPI_IO_BASE, &state->io_mr); ++ "nvdimm-acpi-io", state->dsm_io.len); ++ memory_region_add_subregion(io, state->dsm_io.base, &state->io_mr); + + state->dsm_mem = g_array_new(false, true /* clear */, 1); + acpi_data_push(state->dsm_mem, sizeof(NvdimmDsmIn)); +@@ -959,12 +959,14 @@ void nvdimm_init_acpi_state(AcpiNVDIMMState *state, MemoryRegion *io, + + #define NVDIMM_QEMU_RSVD_UUID "648B9CF2-CDA1-4312-8AD9-49C4AF32BD62" + +-static void nvdimm_build_common_dsm(Aml *dev) ++static void nvdimm_build_common_dsm(Aml *dev, ++ AcpiNVDIMMState *acpi_nvdimm_state) + { + Aml *method, *ifctx, *function, *handle, *uuid, *dsm_mem, *elsectx2; + Aml *elsectx, *unsupport, *unpatched, *expected_uuid, *uuid_invalid; + Aml *pckg, *pckg_index, *pckg_buf, *field, *dsm_out_buf, *dsm_out_buf_size; + uint8_t byte_list[1]; ++ AmlRegionSpace rs; + + method = aml_method(NVDIMM_COMMON_DSM, 5, AML_SERIALIZED); + uuid = aml_arg(0); +@@ -975,9 +977,16 @@ static void nvdimm_build_common_dsm(Aml *dev) + + aml_append(method, aml_store(aml_name(NVDIMM_ACPI_MEM_ADDR), dsm_mem)); + ++ if (acpi_nvdimm_state->dsm_io.type == NVDIMM_ACPI_IO_PORT) { ++ rs = AML_SYSTEM_IO; ++ } else { ++ rs = AML_SYSTEM_MEMORY; ++ } ++ + /* map DSM memory and IO into ACPI namespace. */ +- aml_append(method, aml_operation_region(NVDIMM_DSM_IOPORT, AML_SYSTEM_IO, +- aml_int(NVDIMM_ACPI_IO_BASE), NVDIMM_ACPI_IO_LEN)); ++ aml_append(method, aml_operation_region(NVDIMM_DSM_IOPORT, rs, ++ aml_int(acpi_nvdimm_state->dsm_io.base), ++ acpi_nvdimm_state->dsm_io.len)); + aml_append(method, aml_operation_region(NVDIMM_DSM_MEMORY, + AML_SYSTEM_MEMORY, dsm_mem, sizeof(NvdimmDsmIn))); + +@@ -1260,7 +1269,8 @@ static void nvdimm_build_nvdimm_devices(Aml *root_dev, uint32_t ram_slots) + } + + static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, +- BIOSLinker *linker, GArray *dsm_dma_arrea, ++ BIOSLinker *linker, ++ AcpiNVDIMMState *acpi_nvdimm_state, + uint32_t ram_slots) + { + Aml *ssdt, *sb_scope, *dev; +@@ -1288,7 +1298,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, + */ + aml_append(dev, aml_name_decl("_HID", aml_string("ACPI0012"))); + +- nvdimm_build_common_dsm(dev); ++ nvdimm_build_common_dsm(dev, acpi_nvdimm_state); + + /* 0 is reserved for root device. */ + nvdimm_build_device_dsm(dev, 0); +@@ -1307,7 +1317,7 @@ static void nvdimm_build_ssdt(GArray *table_offsets, GArray *table_data, + NVDIMM_ACPI_MEM_ADDR); + + bios_linker_loader_alloc(linker, +- NVDIMM_DSM_MEM_FILE, dsm_dma_arrea, ++ NVDIMM_DSM_MEM_FILE, acpi_nvdimm_state->dsm_mem, + sizeof(NvdimmDsmIn), false /* high memory */); + bios_linker_loader_add_pointer(linker, + ACPI_BUILD_TABLE_FILE, mem_addr_offset, sizeof(uint32_t), +@@ -1329,7 +1339,7 @@ void nvdimm_build_acpi(GArray *table_offsets, GArray *table_data, + return; + } + +- nvdimm_build_ssdt(table_offsets, table_data, linker, state->dsm_mem, ++ nvdimm_build_ssdt(table_offsets, table_data, linker, state, + ram_slots); + + device_list = nvdimm_get_device_list(); +diff --git a/hw/arm/boot.c b/hw/arm/boot.c +index 586baa9b64..78de9e16b5 100644 +--- a/hw/arm/boot.c ++++ b/hw/arm/boot.c +@@ -19,6 +19,7 @@ + #include "sysemu/numa.h" + #include "hw/boards.h" + #include "hw/loader.h" ++#include "hw/mem/memory-device.h" + #include "elf.h" + #include "sysemu/device_tree.h" + #include "qemu/config-file.h" +@@ -418,6 +419,66 @@ static void set_kernel_args_old(const struct arm_boot_info *info, + } + } + ++static int fdt_add_memory_node(void *fdt, uint32_t acells, hwaddr mem_base, ++ uint32_t scells, hwaddr mem_len, ++ int numa_node_id) ++{ ++ char *nodename = NULL; ++ int ret; ++ ++ nodename = g_strdup_printf("/memory@%" PRIx64, mem_base); ++ qemu_fdt_add_subnode(fdt, nodename); ++ qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); ++ ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, mem_base, ++ scells, mem_len); ++ if (ret < 0) { ++ fprintf(stderr, "couldn't set %s/reg\n", nodename); ++ goto out; ++ } ++ if (numa_node_id < 0) { ++ goto out; ++ } ++ ++ ret = qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", numa_node_id); ++ if (ret < 0) { ++ fprintf(stderr, "couldn't set %s/numa-node-id\n", nodename); ++ } ++ ++out: ++ g_free(nodename); ++ return ret; ++} ++ ++static int fdt_add_pmem_node(void *fdt, uint32_t acells, hwaddr mem_base, ++ uint32_t scells, hwaddr mem_len, ++ int numa_node_id) ++{ ++ char *nodename = NULL; ++ int ret; ++ ++ nodename = g_strdup_printf("/pmem@%" PRIx64, mem_base); ++ qemu_fdt_add_subnode(fdt, nodename); ++ qemu_fdt_setprop_string(fdt, nodename, "compatible", "pmem-region"); ++ ret = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", acells, mem_base, ++ scells, mem_len); ++ if (ret < 0) { ++ fprintf(stderr, "couldn't set %s/reg\n", nodename); ++ goto out; ++ } ++ if (numa_node_id < 0) { ++ goto out; ++ } ++ ++ ret = qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", numa_node_id); ++ if (ret < 0) { ++ fprintf(stderr, "couldn't set %s/numa-node-id\n", nodename); ++ } ++ ++out: ++ g_free(nodename); ++ return ret; ++} ++ + static void fdt_add_psci_node(void *fdt) + { + uint32_t cpu_suspend_fn; +@@ -491,13 +552,41 @@ static void fdt_add_psci_node(void *fdt) + qemu_fdt_setprop_cell(fdt, "/psci", "migrate", migrate_fn); + } + ++static int fdt_add_hotpluggable_memory_nodes(void *fdt, ++ uint32_t acells, uint32_t scells) { ++ MemoryDeviceInfoList *info, *info_list = qmp_memory_device_list(); ++ MemoryDeviceInfo *mi; ++ PCDIMMDeviceInfo *di; ++ bool is_nvdimm; ++ int ret = 0; ++ ++ for (info = info_list; info != NULL; info = info->next) { ++ mi = info->value; ++ is_nvdimm = (mi->type == MEMORY_DEVICE_INFO_KIND_NVDIMM); ++ di = !is_nvdimm ? mi->u.dimm.data : mi->u.nvdimm.data; ++ ++ if (is_nvdimm) { ++ ret = fdt_add_pmem_node(fdt, acells, di->addr, ++ scells, di->size, di->node); ++ } else { ++ ret = fdt_add_memory_node(fdt, acells, di->addr, ++ scells, di->size, di->node); ++ } ++ if (ret < 0) { ++ goto out; ++ } ++ } ++out: ++ qapi_free_MemoryDeviceInfoList(info_list); ++ return ret; ++} ++ + int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, + hwaddr addr_limit, AddressSpace *as) + { + void *fdt = NULL; + int size, rc, n = 0; + uint32_t acells, scells; +- char *nodename; + unsigned int i; + hwaddr mem_base, mem_len; + char **node_path; +@@ -571,35 +660,26 @@ int arm_load_dtb(hwaddr addr, const struct arm_boot_info *binfo, + mem_base = binfo->loader_start; + for (i = 0; i < nb_numa_nodes; i++) { + mem_len = numa_info[i].node_mem; +- nodename = g_strdup_printf("/memory@%" PRIx64, mem_base); +- qemu_fdt_add_subnode(fdt, nodename); +- qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); +- rc = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", +- acells, mem_base, +- scells, mem_len); ++ rc = fdt_add_memory_node(fdt, acells, mem_base, ++ scells, mem_len, i); + if (rc < 0) { +- fprintf(stderr, "couldn't set %s/reg for node %d\n", nodename, +- i); + goto fail; + } + +- qemu_fdt_setprop_cell(fdt, nodename, "numa-node-id", i); + mem_base += mem_len; +- g_free(nodename); + } + } else { +- nodename = g_strdup_printf("/memory@%" PRIx64, binfo->loader_start); +- qemu_fdt_add_subnode(fdt, nodename); +- qemu_fdt_setprop_string(fdt, nodename, "device_type", "memory"); +- +- rc = qemu_fdt_setprop_sized_cells(fdt, nodename, "reg", +- acells, binfo->loader_start, +- scells, binfo->ram_size); ++ rc = fdt_add_memory_node(fdt, acells, binfo->loader_start, ++ scells, binfo->ram_size, -1); + if (rc < 0) { +- fprintf(stderr, "couldn't set %s reg\n", nodename); + goto fail; + } +- g_free(nodename); ++ } ++ ++ rc = fdt_add_hotpluggable_memory_nodes(fdt, acells, scells); ++ if (rc < 0) { ++ fprintf(stderr, "couldn't add hotpluggable memory nodes\n"); ++ goto fail; + } + + rc = fdt_path_offset(fdt, "/chosen"); +diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c +index 5785fb697c..dc100dd4c0 100644 +--- a/hw/arm/virt-acpi-build.c ++++ b/hw/arm/virt-acpi-build.c +@@ -545,6 +545,7 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) + int i, srat_start; + uint64_t mem_base; + MachineClass *mc = MACHINE_GET_CLASS(vms); ++ MachineState *ms = MACHINE(vms); + const CPUArchIdList *cpu_list = mc->possible_cpu_arch_ids(MACHINE(vms)); + + srat_start = table_data->len; +@@ -570,6 +571,9 @@ build_srat(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) + } + } + ++ build_srat_hotpluggable_memory(table_data, ms->device_memory->base, ++ ms->device_memory->mr.size, 0); ++ + build_header(linker, table_data, (void *)(table_data->data + srat_start), + "SRAT", table_data->len - srat_start, 3, NULL, NULL); + } +@@ -804,6 +808,7 @@ static + void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) + { + VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); ++ MachineState *ms = MACHINE(vms); + GArray *table_offsets; + unsigned dsdt, xsdt; + GArray *tables_blob = tables->table_data; +@@ -844,6 +849,11 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) + } + } + ++ if (vms->acpi_nvdimm_state.is_enabled) { ++ nvdimm_build_acpi(table_offsets, tables_blob, tables->linker, ++ &vms->acpi_nvdimm_state, ms->ram_slots); ++ } ++ + if (its_class_name() && !vmc->no_its) { + acpi_add_table(table_offsets, tables_blob); + build_iort(tables_blob, tables->linker, vms); +diff --git a/hw/arm/virt.c b/hw/arm/virt.c +index a2b8d8f7c2..f83fce1089 100644 +--- a/hw/arm/virt.c ++++ b/hw/arm/virt.c +@@ -59,6 +59,9 @@ + #include "qapi/visitor.h" + #include "standard-headers/linux/input.h" + #include "hw/arm/smmuv3.h" ++#include "hw/acpi/acpi.h" ++#include "hw/mem/pc-dimm.h" ++#include "hw/mem/nvdimm.h" + + #define DEFINE_VIRT_MACHINE_LATEST(major, minor, latest) \ + static void virt_##major##_##minor##_class_init(ObjectClass *oc, \ +@@ -94,34 +97,29 @@ + + #define PLATFORM_BUS_NUM_IRQS 64 + +-/* RAM limit in GB. Since VIRT_MEM starts at the 1GB mark, this means +- * RAM can go up to the 256GB mark, leaving 256GB of the physical +- * address space unallocated and free for future use between 256G and 512G. +- * If we need to provide more RAM to VMs in the future then we need to: +- * * allocate a second bank of RAM starting at 2TB and working up +- * * fix the DT and ACPI table generation code in QEMU to correctly +- * report two split lumps of RAM to the guest +- * * fix KVM in the host kernel to allow guests with >40 bit address spaces +- * (We don't want to fill all the way up to 512GB with RAM because +- * we might want it for non-RAM purposes later. Conversely it seems +- * reasonable to assume that anybody configuring a VM with a quarter +- * of a terabyte of RAM will be doing it on a host with more than a +- * terabyte of physical address space.) +- */ +-#define RAMLIMIT_GB 255 +-#define RAMLIMIT_BYTES (RAMLIMIT_GB * 1024ULL * 1024 * 1024) ++#define SZ_1G (1024ULL * 1024 * 1024) ++#define SZ_64K 0x10000 ++ ++/* device memory starts at 2TB */ ++#define DEVICE_MEM_BASE (2048 * SZ_1G) ++#define DEVICE_MEM_SIZE (4096 * SZ_1G) + + /* Addresses and sizes of our components. +- * 0..128MB is space for a flash device so we can run bootrom code such as UEFI. +- * 128MB..256MB is used for miscellaneous device I/O. +- * 256MB..1GB is reserved for possible future PCI support (ie where the +- * PCI memory window will go if we add a PCI host controller). +- * 1GB and up is RAM (which may happily spill over into the +- * high memory region beyond 4GB). +- * This represents a compromise between how much RAM can be given to +- * a 32 bit VM and leaving space for expansion and in particular for PCI. +- * Note that devices should generally be placed at multiples of 0x10000, ++ * 0..128MB is space for a flash device so we can run bootrom code such as UEFI, ++ * 128MB..256MB is used for miscellaneous device I/O, ++ * 256MB..1GB is used for PCI host controller, ++ * 1GB..256GB is RAM (not hotpluggable), ++ * 256GB..512GB: is left for device I/O (non RAM purpose), ++ * 512GB..1TB: high mem PCI MMIO region, ++ * 2TB..6TB is used for device memory (assumes dynamic IPA setting on kernel). ++ * ++ * Note that IO devices should generally be placed at multiples of 0x10000, + * to accommodate guests using 64K pages. ++ * ++ * Conversely it seems reasonable to assume that anybody configuring a VM ++ * with a quarter of a terabyte of RAM will be doing it on a host with more ++ * than a terabyte of physical address space.) ++ * + */ + static const MemMapEntry a15memmap[] = { + /* Space up to 0x8000000 is reserved for a boot ROM */ +@@ -143,6 +141,7 @@ static const MemMapEntry a15memmap[] = { + [VIRT_GPIO] = { 0x09030000, 0x00001000 }, + [VIRT_SECURE_UART] = { 0x09040000, 0x00001000 }, + [VIRT_SMMU] = { 0x09050000, 0x00020000 }, ++ [VIRT_ACPI_IO] = { 0x09070000, 0x00010000 }, + [VIRT_MMIO] = { 0x0a000000, 0x00000200 }, + /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that size */ + [VIRT_PLATFORM_BUS] = { 0x0c000000, 0x02000000 }, +@@ -150,12 +149,14 @@ static const MemMapEntry a15memmap[] = { + [VIRT_PCIE_MMIO] = { 0x10000000, 0x2eff0000 }, + [VIRT_PCIE_PIO] = { 0x3eff0000, 0x00010000 }, + [VIRT_PCIE_ECAM] = { 0x3f000000, 0x01000000 }, +- [VIRT_MEM] = { 0x40000000, RAMLIMIT_BYTES }, ++ [VIRT_MEM] = { SZ_1G , 255 * SZ_1G }, + /* Additional 64 MB redist region (can contain up to 512 redistributors) */ + [VIRT_GIC_REDIST2] = { 0x4000000000ULL, 0x4000000 }, + [VIRT_PCIE_ECAM_HIGH] = { 0x4010000000ULL, 0x10000000 }, + /* Second PCIe window, 512GB wide at the 512GB boundary */ +- [VIRT_PCIE_MMIO_HIGH] = { 0x8000000000ULL, 0x8000000000ULL }, ++ [VIRT_PCIE_MMIO_HIGH] = { 512 * SZ_1G, 512 * SZ_1G }, ++ /* device memory beyond 2TB */ ++ [VIRT_DEVICE_MEM] = { DEVICE_MEM_BASE, DEVICE_MEM_SIZE }, + }; + + static const int a15irqmap[] = { +@@ -1261,6 +1262,51 @@ static void create_secure_ram(VirtMachineState *vms, + g_free(nodename); + } + ++static void create_device_memory(VirtMachineState *vms, MemoryRegion *sysmem) ++{ ++ VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); ++ MachineClass *mc = MACHINE_GET_CLASS(vms); ++ MachineState *ms = MACHINE(vms); ++ uint64_t device_memory_size = ms->maxram_size - ms->ram_size; ++ uint64_t align = SZ_64K; ++ ++ if (!device_memory_size) { ++ return; ++ } ++ ++ if (vmc->no_device_memory) { ++ error_report("Machine %s does not support device memory: " ++ "maxmem option not supported", mc->name); ++ exit(EXIT_FAILURE); ++ } ++ ++ if (ms->ram_slots > ACPI_MAX_RAM_SLOTS) { ++ error_report("unsupported number of memory slots: %"PRIu64, ++ ms->ram_slots); ++ exit(EXIT_FAILURE); ++ } ++ ++ if (QEMU_ALIGN_UP(ms->maxram_size, align) != ms->maxram_size) { ++ error_report("maximum memory size must be aligned to multiple of 0x%" ++ PRIx64, align); ++ exit(EXIT_FAILURE); ++ } ++ ++ if (device_memory_size > vms->memmap[VIRT_DEVICE_MEM].size) { ++ error_report("unsupported amount of maximum memory: " RAM_ADDR_FMT, ++ ms->maxram_size); ++ exit(EXIT_FAILURE); ++ } ++ ++ ms->device_memory = g_malloc0(sizeof(*ms->device_memory)); ++ ms->device_memory->base = vms->memmap[VIRT_DEVICE_MEM].base; ++ ++ memory_region_init(&ms->device_memory->mr, OBJECT(vms), ++ "device-memory", device_memory_size); ++ memory_region_add_subregion(sysmem, ms->device_memory->base, ++ &ms->device_memory->mr); ++} ++ + static void *machvirt_dtb(const struct arm_boot_info *binfo, int *fdt_size) + { + const VirtMachineState *board = container_of(binfo, VirtMachineState, +@@ -1434,7 +1480,8 @@ static void machvirt_init(MachineState *machine) + vms->smp_cpus = smp_cpus; + + if (machine->ram_size > vms->memmap[VIRT_MEM].size) { +- error_report("mach-virt: cannot model more than %dGB RAM", RAMLIMIT_GB); ++ error_report("mach-virt: cannot model more than %dGB RAM", ++ (int)(vms->memmap[VIRT_MEM].size / SZ_1G)); + exit(1); + } + +@@ -1529,6 +1576,8 @@ static void machvirt_init(MachineState *machine) + machine->ram_size); + memory_region_add_subregion(sysmem, vms->memmap[VIRT_MEM].base, ram); + ++ create_device_memory(vms, sysmem); ++ + create_flash(vms, sysmem, secure_sysmem ? secure_sysmem : sysmem); + + create_gic(vms, pic); +@@ -1561,6 +1610,18 @@ static void machvirt_init(MachineState *machine) + + create_platform_bus(vms, pic); + ++ if (vms->acpi_nvdimm_state.is_enabled) { ++ AcpiNVDIMMState *acpi_nvdimm_state = &vms->acpi_nvdimm_state; ++ ++ acpi_nvdimm_state->dsm_io.type = NVDIMM_ACPI_IO_MEMORY; ++ acpi_nvdimm_state->dsm_io.base = ++ vms->memmap[VIRT_ACPI_IO].base + NVDIMM_ACPI_IO_BASE; ++ acpi_nvdimm_state->dsm_io.len = NVDIMM_ACPI_IO_LEN; ++ ++ nvdimm_init_acpi_state(acpi_nvdimm_state, sysmem, ++ vms->fw_cfg, OBJECT(vms)); ++ } ++ + vms->bootinfo.ram_size = machine->ram_size; + vms->bootinfo.kernel_filename = machine->kernel_filename; + vms->bootinfo.kernel_cmdline = machine->kernel_cmdline; +@@ -1687,6 +1748,47 @@ static void virt_set_iommu(Object *obj, const char *value, Error **errp) + } + } + ++static bool virt_get_nvdimm(Object *obj, Error **errp) ++{ ++ VirtMachineState *vms = VIRT_MACHINE(obj); ++ ++ return vms->acpi_nvdimm_state.is_enabled; ++} ++ ++static void virt_set_nvdimm(Object *obj, bool value, Error **errp) ++{ ++ VirtMachineState *vms = VIRT_MACHINE(obj); ++ ++ vms->acpi_nvdimm_state.is_enabled = value; ++} ++ ++static char *virt_get_nvdimm_persistence(Object *obj, Error **errp) ++{ ++ VirtMachineState *vms = VIRT_MACHINE(obj); ++ ++ return g_strdup(vms->acpi_nvdimm_state.persistence_string); ++} ++ ++static void virt_set_nvdimm_persistence(Object *obj, const char *value, ++ Error **errp) ++{ ++ VirtMachineState *vms = VIRT_MACHINE(obj); ++ AcpiNVDIMMState *nvdimm_state = &vms->acpi_nvdimm_state; ++ ++ if (strcmp(value, "cpu") == 0) ++ nvdimm_state->persistence = 3; ++ else if (strcmp(value, "mem-ctrl") == 0) ++ nvdimm_state->persistence = 2; ++ else { ++ error_report("-machine nvdimm-persistence=%s: unsupported option", ++ value); ++ exit(EXIT_FAILURE); ++ } ++ ++ g_free(nvdimm_state->persistence_string); ++ nvdimm_state->persistence_string = g_strdup(value); ++} ++ + static CpuInstanceProperties + virt_cpu_index_to_props(MachineState *ms, unsigned cpu_index) + { +@@ -1725,6 +1827,59 @@ static const CPUArchIdList *virt_possible_cpu_arch_ids(MachineState *ms) + return ms->possible_cpus; + } + ++static void virt_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, ++ Error **errp) ++{ ++ const bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); ++ VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); ++ ++ if (dev->hotplugged) { ++ error_setg(errp, "memory hotplug is not supported"); ++ } ++ ++ if (is_nvdimm && !vms->acpi_nvdimm_state.is_enabled) { ++ error_setg(errp, "nvdimm is not enabled: missing 'nvdimm' in '-M'"); ++ return; ++ } ++ ++ pc_dimm_pre_plug(PC_DIMM(dev), MACHINE(hotplug_dev), NULL, errp); ++} ++ ++static void virt_memory_plug(HotplugHandler *hotplug_dev, ++ DeviceState *dev, Error **errp) ++{ ++ VirtMachineState *vms = VIRT_MACHINE(hotplug_dev); ++ bool is_nvdimm = object_dynamic_cast(OBJECT(dev), TYPE_NVDIMM); ++ Error *local_err = NULL; ++ ++ pc_dimm_plug(PC_DIMM(dev), MACHINE(vms), &local_err); ++ if (local_err) { ++ goto out; ++ } ++ ++ if (is_nvdimm) { ++ nvdimm_plug(&vms->acpi_nvdimm_state); ++ } ++ ++out: ++ error_propagate(errp, local_err); ++} ++ ++static void virt_memory_unplug(HotplugHandler *hotplug_dev, ++ DeviceState *dev, Error **errp) ++{ ++ pc_dimm_unplug(PC_DIMM(dev), MACHINE(hotplug_dev)); ++ object_unparent(OBJECT(dev)); ++} ++ ++static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev, ++ DeviceState *dev, Error **errp) ++{ ++ if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { ++ virt_memory_pre_plug(hotplug_dev, dev, errp); ++ } ++} ++ + static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, + DeviceState *dev, Error **errp) + { +@@ -1736,18 +1891,65 @@ static void virt_machine_device_plug_cb(HotplugHandler *hotplug_dev, + SYS_BUS_DEVICE(dev)); + } + } ++ if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { ++ virt_memory_plug(hotplug_dev, dev, errp); ++ } ++} ++ ++static void virt_machine_device_unplug_cb(HotplugHandler *hotplug_dev, ++ DeviceState *dev, Error **errp) ++{ ++ if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { ++ virt_memory_unplug(hotplug_dev, dev, errp); ++ } else { ++ error_setg(errp, "device unplug request for unsupported device" ++ " type: %s", object_get_typename(OBJECT(dev))); ++ } + } + + static HotplugHandler *virt_machine_get_hotplug_handler(MachineState *machine, + DeviceState *dev) + { +- if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE)) { ++ if (object_dynamic_cast(OBJECT(dev), TYPE_SYS_BUS_DEVICE) || ++ (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM))) { + return HOTPLUG_HANDLER(machine); + } + + return NULL; + } + ++/* ++ * for arm64 kvm_type [7-0] encodes the IPA size shift ++ */ ++static inline int virt_kvm_type(MachineState *ms, const char *type_str) ++{ ++ int max_vm_phys_shift = kvm_arm_get_max_vm_phys_shift(ms); ++ ram_addr_t device_mem_size = ms->maxram_size - ms->ram_size; ++ uint8_t requested_vm_phys_shift; ++ ++ if (!device_mem_size) { ++ return 0; /* default 40b IPA */ ++ } ++ ++ /* we need at least 42b IPA to fit device memory at 2TB*/ ++ if (max_vm_phys_shift < 42) { ++ error_report("This host does not support 42b IPA: " ++ "maxram/slots options not usable"); ++ exit(1); ++ } ++ ++ requested_vm_phys_shift = 64 - clz64(DEVICE_MEM_BASE + device_mem_size); ++ ++ if (requested_vm_phys_shift > max_vm_phys_shift) { ++ error_report("maxmem option value too large. Max supported value " ++ "for this host is 0x%"PRIx64, ++ (ram_addr_t)((1ULL << max_vm_phys_shift) - DEVICE_MEM_BASE)); ++ exit(1); ++ } ++ ++ return requested_vm_phys_shift; ++} ++ + static void virt_machine_class_init(ObjectClass *oc, void *data) + { + MachineClass *mc = MACHINE_CLASS(oc); +@@ -1772,9 +1974,12 @@ static void virt_machine_class_init(ObjectClass *oc, void *data) + mc->cpu_index_to_instance_props = virt_cpu_index_to_props; + mc->default_cpu_type = ARM_CPU_TYPE_NAME("cortex-a15"); + mc->get_default_cpu_node_id = virt_get_default_cpu_node_id; ++ mc->kvm_type = virt_kvm_type; + assert(!mc->get_hotplug_handler); + mc->get_hotplug_handler = virt_machine_get_hotplug_handler; ++ hc->pre_plug = virt_machine_device_pre_plug_cb; + hc->plug = virt_machine_device_plug_cb; ++ hc->unplug = virt_machine_device_unplug_cb; + } + + static const TypeInfo virt_machine_info = { +@@ -1796,7 +2001,7 @@ static void machvirt_machine_init(void) + } + type_init(machvirt_machine_init); + +-static void virt_3_1_instance_init(Object *obj) ++static void virt_3_2_instance_init(Object *obj) + { + VirtMachineState *vms = VIRT_MACHINE(obj); + VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms); +@@ -1862,14 +2067,47 @@ static void virt_3_1_instance_init(Object *obj) + "Valid values are none and smmuv3", + NULL); + ++ object_property_add_bool(obj, "nvdimm", ++ virt_get_nvdimm, virt_set_nvdimm, NULL); ++ object_property_set_description(obj, "nvdimm", ++ "Set on/off to enable/disable NVDIMM " ++ "instantiation", NULL); ++ ++ object_property_add_str(obj, "nvdimm-persistence", ++ virt_get_nvdimm_persistence, ++ virt_set_nvdimm_persistence, NULL); ++ object_property_set_description(obj, "nvdimm-persistence", ++ "Set NVDIMM persistence" ++ "Valid values are cpu and mem-ctrl", NULL); ++ + vms->memmap = a15memmap; + vms->irqmap = a15irqmap; + } + ++static void virt_machine_3_2_options(MachineClass *mc) ++{ ++} ++DEFINE_VIRT_MACHINE_AS_LATEST(3, 2) ++ ++static void virt_3_1_instance_init(Object *obj) ++{ ++ virt_3_2_instance_init(obj); ++} ++ + static void virt_machine_3_1_options(MachineClass *mc) + { ++ VirtMachineClass *vmc = VIRT_MACHINE_CLASS(OBJECT_CLASS(mc)); ++ ++ virt_machine_3_2_options(mc); ++ ++ /* ++ * Device memory and capability to set the max IPA address shift ++ * are enabled from 3.2 onwards ++ */ ++ vmc->no_device_memory = true; ++ mc->kvm_type = NULL; + } +-DEFINE_VIRT_MACHINE_AS_LATEST(3, 1) ++DEFINE_VIRT_MACHINE(3, 1) + + #define VIRT_COMPAT_3_0 \ + HW_COMPAT_3_0 +diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c +index 7092d6d13f..23fb635eeb 100644 +--- a/hw/i386/pc_piix.c ++++ b/hw/i386/pc_piix.c +@@ -297,7 +297,13 @@ static void pc_init1(MachineState *machine, + } + + if (pcms->acpi_nvdimm_state.is_enabled) { +- nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, ++ AcpiNVDIMMState *acpi_nvdimm_state = &pcms->acpi_nvdimm_state; ++ ++ acpi_nvdimm_state->dsm_io.type = NVDIMM_ACPI_IO_PORT; ++ acpi_nvdimm_state->dsm_io.base = NVDIMM_ACPI_IO_BASE; ++ acpi_nvdimm_state->dsm_io.len = NVDIMM_ACPI_IO_LEN; ++ ++ nvdimm_init_acpi_state(acpi_nvdimm_state, system_io, + pcms->fw_cfg, OBJECT(pcms)); + } + } +diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c +index 4702bb13c4..5046d4d386 100644 +--- a/hw/i386/pc_q35.c ++++ b/hw/i386/pc_q35.c +@@ -277,7 +277,13 @@ static void pc_q35_init(MachineState *machine) + pc_nic_init(pcmc, isa_bus, host_bus); + + if (pcms->acpi_nvdimm_state.is_enabled) { +- nvdimm_init_acpi_state(&pcms->acpi_nvdimm_state, system_io, ++ AcpiNVDIMMState *acpi_nvdimm_state = &pcms->acpi_nvdimm_state; ++ ++ acpi_nvdimm_state->dsm_io.type = NVDIMM_ACPI_IO_PORT; ++ acpi_nvdimm_state->dsm_io.base = NVDIMM_ACPI_IO_BASE; ++ acpi_nvdimm_state->dsm_io.len = NVDIMM_ACPI_IO_LEN; ++ ++ nvdimm_init_acpi_state(acpi_nvdimm_state, system_io, + pcms->fw_cfg, OBJECT(pcms)); + } + } +diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c +index 14273a123e..65daa94330 100644 +--- a/hw/ppc/mac_newworld.c ++++ b/hw/ppc/mac_newworld.c +@@ -570,8 +570,7 @@ static char *core99_fw_dev_path(FWPathProvider *p, BusState *bus, + + return NULL; + } +- +-static int core99_kvm_type(const char *arg) ++static int core99_kvm_type(MachineState *ms, const char *arg) + { + /* Always force PR KVM */ + return 2; +diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c +index 9891c325a9..67cbd06b0f 100644 +--- a/hw/ppc/mac_oldworld.c ++++ b/hw/ppc/mac_oldworld.c +@@ -422,7 +422,7 @@ static char *heathrow_fw_dev_path(FWPathProvider *p, BusState *bus, + return NULL; + } + +-static int heathrow_kvm_type(const char *arg) ++static int heathrow_kvm_type(MachineState *ms, const char *arg) + { + /* Always force PR KVM */ + return 2; +diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c +index 7afd1a175b..e78959f233 100644 +--- a/hw/ppc/spapr.c ++++ b/hw/ppc/spapr.c +@@ -2845,7 +2845,7 @@ static void spapr_machine_init(MachineState *machine) + } + } + +-static int spapr_kvm_type(const char *vm_type) ++static int spapr_kvm_type(MachineState *ms, const char *vm_type) + { + if (!vm_type) { + return 0; +diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h +index 6c36903c0a..4c2ca134ee 100644 +--- a/include/hw/acpi/aml-build.h ++++ b/include/hw/acpi/aml-build.h +@@ -416,4 +416,7 @@ void build_slit(GArray *table_data, BIOSLinker *linker); + + void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f, + const char *oem_id, const char *oem_table_id); ++ ++void build_srat_hotpluggable_memory(GArray *table_data, uint64_t base, ++ uint64_t len, int default_node); + #endif +diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h +index 4cc57a7ef6..974a110a38 100644 +--- a/include/hw/arm/virt.h ++++ b/include/hw/arm/virt.h +@@ -37,6 +37,7 @@ + #include "hw/arm/arm.h" + #include "sysemu/kvm.h" + #include "hw/intc/arm_gicv3_common.h" ++#include "hw/mem/nvdimm.h" + + #define NUM_GICV2M_SPIS 64 + #define NUM_VIRTIO_TRANSPORTS 32 +@@ -80,6 +81,8 @@ enum { + VIRT_GPIO, + VIRT_SECURE_UART, + VIRT_SECURE_MEM, ++ VIRT_DEVICE_MEM, ++ VIRT_ACPI_IO, + }; + + typedef enum VirtIOMMUType { +@@ -101,6 +104,7 @@ typedef struct { + bool claim_edge_triggered_timers; + bool smbios_old_sys_ver; + bool no_highmem_ecam; ++ bool no_device_memory; + } VirtMachineClass; + + typedef struct { +@@ -126,6 +130,7 @@ typedef struct { + uint32_t msi_phandle; + uint32_t iommu_phandle; + int psci_conduit; ++ AcpiNVDIMMState acpi_nvdimm_state; + } VirtMachineState; + + #define VIRT_ECAM_ID(high) (high ? VIRT_PCIE_ECAM_HIGH : VIRT_PCIE_ECAM) +diff --git a/include/hw/boards.h b/include/hw/boards.h +index f82f28468b..8bc015fb7c 100644 +--- a/include/hw/boards.h ++++ b/include/hw/boards.h +@@ -172,7 +172,7 @@ struct MachineClass { + void (*init)(MachineState *state); + void (*reset)(void); + void (*hot_add_cpu)(const int64_t id, Error **errp); +- int (*kvm_type)(const char *arg); ++ int (*kvm_type)(MachineState *ms, const char *arg); + + BlockInterfaceType block_default_type; + int units_per_default_bus; +diff --git a/include/hw/mem/nvdimm.h b/include/hw/mem/nvdimm.h +index c5c9b3c7f8..af8a5fd034 100644 +--- a/include/hw/mem/nvdimm.h ++++ b/include/hw/mem/nvdimm.h +@@ -123,6 +123,17 @@ struct NvdimmFitBuffer { + }; + typedef struct NvdimmFitBuffer NvdimmFitBuffer; + ++typedef enum { ++ NVDIMM_ACPI_IO_PORT, ++ NVDIMM_ACPI_IO_MEMORY, ++} AcpiNVDIMMIOType; ++ ++typedef struct AcpiNVDIMMIOEntry { ++ AcpiNVDIMMIOType type; ++ hwaddr base; ++ hwaddr len; ++} AcpiNVDIMMIOEntry; ++ + struct AcpiNVDIMMState { + /* detect if NVDIMM support is enabled. */ + bool is_enabled; +@@ -140,6 +151,7 @@ struct AcpiNVDIMMState { + */ + int32_t persistence; + char *persistence_string; ++ AcpiNVDIMMIOEntry dsm_io; + }; + typedef struct AcpiNVDIMMState AcpiNVDIMMState; + +diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h +index f11a7eb49c..f9ad70c296 100644 +--- a/linux-headers/linux/kvm.h ++++ b/linux-headers/linux/kvm.h +@@ -757,6 +757,16 @@ struct kvm_ppc_resize_hpt { + + #define KVM_S390_SIE_PAGE_OFFSET 1 + ++/* ++ * On arm64, machine type can be used to request the physical ++ * address size for the VM. Bits[7-0] are reserved for the guest ++ * PA size shift (i.e, log2(PA_Size)). For backward compatibility, ++ * value 0 implies the default IPA size, 40bits. ++ */ ++#define KVM_VM_TYPE_ARM_IPA_SIZE_MASK 0xffULL ++#define KVM_VM_TYPE_ARM_IPA_SIZE(x) \ ++ ((x) & KVM_VM_TYPE_ARM_IPA_SIZE_MASK) ++ + /* + * ioctls for /dev/kvm fds: + */ +@@ -965,6 +975,7 @@ struct kvm_ppc_resize_hpt { + #define KVM_CAP_COALESCED_PIO 162 + #define KVM_CAP_HYPERV_ENLIGHTENED_VMCS 163 + #define KVM_CAP_EXCEPTION_PAYLOAD 164 ++#define KVM_CAP_ARM_VM_IPA_SIZE 165 /* returns maximum IPA bits for a VM */ + + #ifdef KVM_CAP_IRQ_ROUTING + +diff --git a/target/arm/kvm.c b/target/arm/kvm.c +index 44dd0ce6ce..1efa5c96bc 100644 +--- a/target/arm/kvm.c ++++ b/target/arm/kvm.c +@@ -18,6 +18,7 @@ + #include "qemu/error-report.h" + #include "sysemu/sysemu.h" + #include "sysemu/kvm.h" ++#include "sysemu/kvm_int.h" + #include "kvm_arm.h" + #include "cpu.h" + #include "trace.h" +@@ -162,6 +163,13 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) + env->features = arm_host_cpu_features.features; + } + ++int kvm_arm_get_max_vm_phys_shift(MachineState *ms) ++{ ++ KVMState *s = KVM_STATE(ms->accelerator); ++ ++ return kvm_check_extension(s, KVM_CAP_ARM_VM_IPA_SIZE); ++} ++ + int kvm_arch_init(MachineState *ms, KVMState *s) + { + /* For ARM interrupt delivery is always asynchronous, +diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h +index 6393455b1d..5969c41f83 100644 +--- a/target/arm/kvm_arm.h ++++ b/target/arm/kvm_arm.h +@@ -207,6 +207,17 @@ bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf); + */ + void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); + ++/** ++ * kvm_arm_get_max_vm_phys_shift - Returns log2 of the max IPA size ++ * supported by KVM ++ * ++ * @ms: Machine state handle ++ * ++ * Return the max number of IPA bits or a negative value if ++ * the host kernel does not expose this value. ++ */ ++int kvm_arm_get_max_vm_phys_shift(MachineState *ms); ++ + /** + * kvm_arm_sync_mpstate_to_kvm + * @cpu: ARMCPU +@@ -239,6 +250,11 @@ static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) + cpu->host_cpu_probe_failed = true; + } + ++static inline int kvm_arm_get_max_vm_phys_shift(MachineState *ms) ++{ ++ return -ENOENT; ++} ++ + static inline int kvm_arm_vgic_probe(void) + { + return 0; +diff --git a/vl.c b/vl.c +index fa25d1ae2d..b52192318f 100644 +--- a/vl.c ++++ b/vl.c +@@ -4303,6 +4303,9 @@ int main(int argc, char **argv, char **envp) + qemu_opt_foreach(machine_opts, machine_set_property, current_machine, + &error_fatal); + ++ current_machine->ram_size = ram_size; ++ current_machine->maxram_size = maxram_size; ++ current_machine->ram_slots = ram_slots; + configure_accelerator(current_machine); + + if (!qtest_enabled() && machine_class->deprecation_reason) { +@@ -4499,9 +4502,6 @@ int main(int argc, char **argv, char **envp) + replay_checkpoint(CHECKPOINT_INIT); + qdev_machine_init(); + +- current_machine->ram_size = ram_size; +- current_machine->maxram_size = maxram_size; +- current_machine->ram_slots = ram_slots; + current_machine->boot_order = boot_order; + + /* parse features once if machine provides default cpu_type */ +-- +2.17.1 + diff --git a/tools/packaging/obs-packaging/qemu-vanilla/_service-template b/tools/packaging/obs-packaging/qemu-vanilla/_service-template new file mode 100644 index 0000000000..d2547c0a47 --- /dev/null +++ b/tools/packaging/obs-packaging/qemu-vanilla/_service-template @@ -0,0 +1,16 @@ + + + + git + https://github.com/qemu/qemu.git + .git + qemu-vanilla + + @VERSION@+git.%h + @QEMU_VANILLA_HASH@ + + + *.tar* + gz + + diff --git a/tools/packaging/obs-packaging/qemu-vanilla/debian.compat b/tools/packaging/obs-packaging/qemu-vanilla/debian.compat new file mode 100644 index 0000000000..ec635144f6 --- /dev/null +++ b/tools/packaging/obs-packaging/qemu-vanilla/debian.compat @@ -0,0 +1 @@ +9 diff --git a/tools/packaging/obs-packaging/qemu-vanilla/debian.control-template b/tools/packaging/obs-packaging/qemu-vanilla/debian.control-template new file mode 100644 index 0000000000..5a4d30d0fb --- /dev/null +++ b/tools/packaging/obs-packaging/qemu-vanilla/debian.control-template @@ -0,0 +1,13 @@ +Source: qemu-vanilla +Section: devel +Priority: optional +Maintainer: Kata containers team +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 diff --git a/tools/packaging/obs-packaging/qemu-vanilla/debian.rules-template b/tools/packaging/obs-packaging/qemu-vanilla/debian.rules-template new file mode 100644 index 0000000000..ed162ba222 --- /dev/null +++ b/tools/packaging/obs-packaging/qemu-vanilla/debian.rules-template @@ -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" diff --git a/tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla-rpmlintrc b/tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla-rpmlintrc new file mode 100644 index 0000000000..9c3c26fb58 --- /dev/null +++ b/tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla-rpmlintrc @@ -0,0 +1 @@ +setBadness('arch-dependent-file-in-usr-share', 0) \ No newline at end of file diff --git a/tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla.dsc-template b/tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla.dsc-template new file mode 100644 index 0000000000..b5261bb2e2 --- /dev/null +++ b/tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla.dsc-template @@ -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 +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. diff --git a/tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla.spec-template b/tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla.spec-template new file mode 100644 index 0000000000..84fa6f33ed --- /dev/null +++ b/tools/packaging/obs-packaging/qemu-vanilla/qemu-vanilla.spec-template @@ -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/* diff --git a/tools/packaging/obs-packaging/qemu-vanilla/update.sh b/tools/packaging/obs-packaging/qemu-vanilla/update.sh new file mode 100755 index 0000000000..542f1503df --- /dev/null +++ b/tools/packaging/obs-packaging/qemu-vanilla/update.sh @@ -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}" diff --git a/tools/packaging/obs-packaging/runtime/_service-template b/tools/packaging/obs-packaging/runtime/_service-template new file mode 100644 index 0000000000..c4bbd5af4c --- /dev/null +++ b/tools/packaging/obs-packaging/runtime/_service-template @@ -0,0 +1,26 @@ + + + + + git + https://github.com/kata-containers/kata-containers.git + kata-runtime + + @VERSION@ + @HASH@ + + + *.tar* + gz + + + https + storage.googleapis.com + golang/go@GO_VERSION@.linux-@GO_ARCH@.tar.gz + + + _service:download_url:go@GO_VERSION@.linux-@GO_ARCH@.tar.gz + sha256 + @GO_CHECKSUM@ + + diff --git a/tools/packaging/obs-packaging/runtime/debian.compat b/tools/packaging/obs-packaging/runtime/debian.compat new file mode 100644 index 0000000000..ec635144f6 --- /dev/null +++ b/tools/packaging/obs-packaging/runtime/debian.compat @@ -0,0 +1 @@ +9 diff --git a/tools/packaging/obs-packaging/runtime/debian.control-template b/tools/packaging/obs-packaging/runtime/debian.control-template new file mode 100644 index 0000000000..8a7024577b --- /dev/null +++ b/tools/packaging/obs-packaging/runtime/debian.control-template @@ -0,0 +1,17 @@ +Source: kata-runtime +Section: devel +Priority: optional +Maintainer: Kata containers team +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. diff --git a/tools/packaging/obs-packaging/runtime/debian.rules-template b/tools/packaging/obs-packaging/runtime/debian.rules-template new file mode 100644 index 0000000000..df49ff6e3d --- /dev/null +++ b/tools/packaging/obs-packaging/runtime/debian.rules-template @@ -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 diff --git a/tools/packaging/obs-packaging/runtime/kata-runtime.dsc-template b/tools/packaging/obs-packaging/runtime/kata-runtime.dsc-template new file mode 100644 index 0000000000..cf749ee84b --- /dev/null +++ b/tools/packaging/obs-packaging/runtime/kata-runtime.dsc-template @@ -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 +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. diff --git a/tools/packaging/obs-packaging/runtime/kata-runtime.spec-template b/tools/packaging/obs-packaging/runtime/kata-runtime.spec-template new file mode 100644 index 0000000000..7600b6ffde --- /dev/null +++ b/tools/packaging/obs-packaging/runtime/kata-runtime.spec-template @@ -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 diff --git a/tools/packaging/obs-packaging/runtime/update.sh b/tools/packaging/obs-packaging/runtime/update.sh new file mode 100755 index 0000000000..08718993f6 --- /dev/null +++ b/tools/packaging/obs-packaging/runtime/update.sh @@ -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}" diff --git a/tools/packaging/obs-packaging/scripts/obs-docker.sh b/tools/packaging/obs-packaging/scripts/obs-docker.sh new file mode 100755 index 0000000000..0ad2b30f0e --- /dev/null +++ b/tools/packaging/obs-packaging/scripts/obs-docker.sh @@ -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 <"${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}" +} diff --git a/tools/packaging/obs-packaging/scripts/obs-pkgs.sh b/tools/packaging/obs-packaging/scripts/obs-pkgs.sh new file mode 100755 index 0000000000..cb6d52d6d4 --- /dev/null +++ b/tools/packaging/obs-packaging/scripts/obs-pkgs.sh @@ -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 +) diff --git a/tools/packaging/obs-packaging/scripts/pkglib.sh b/tools/packaging/obs-packaging/scripts/pkglib.sh new file mode 100644 index 0000000000..2d72c0622f --- /dev/null +++ b/tools/packaging/obs-packaging/scripts/pkglib.sh @@ -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: patch.file +# RPM_APPLY_PATCHES fomat: +# %Patch -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) +} diff --git a/tools/packaging/obs-packaging/wait-obs.sh b/tools/packaging/obs-packaging/wait-obs.sh new file mode 100755 index 0000000000..fe55e82649 --- /dev/null +++ b/tools/packaging/obs-packaging/wait-obs.sh @@ -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/^$//')" + 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 <