Merge pull request #126 from jcvenegas/static-builds

Kata 1.2.0 packaging
This commit is contained in:
Eric Ernst 2018-08-16 13:55:15 -07:00 committed by GitHub
commit fa711da0eb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
26 changed files with 612 additions and 183 deletions

19
.gitignore vendored
View File

@ -1,16 +1,19 @@
typescript
debian.series
*.img *.img
*.initrd *.initrd
*.tar.gz *.sha256
*.snap *.snap
*.tar.gz
*.tar.xz
debian.series
parts/ parts/
prime/ prime/
stage/ sha256sums.asc
snap/.snapcraft/
snap/snapcraft.yaml
snap-build/*.log
snap-build/*.img
snap-build/*.fd snap-build/*.fd
snap-build/*.img
snap-build/*.log
snap-build/id_rsa* snap-build/id_rsa*
snap-build/seed/user-data snap-build/seed/user-data
snap/.snapcraft/
snap/snapcraft.yaml
stage/
typescript

View File

@ -149,7 +149,7 @@ get_config_version() {
if [ -f "${config_version_file}" ]; then if [ -f "${config_version_file}" ]; then
cat "${config_version_file}" cat "${config_version_file}"
else else
echo "unknown" die "failed to find ${config_version_file}"
fi fi
} }

View File

@ -1 +1 @@
7 8

View File

@ -4,24 +4,31 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
set -e [ -z "${DEBUG}" ] || set -o xtrace
script_dir=$(dirname "$0") 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)"
#Note:Lets update qemu and the kernel first, they take longer to build. #Note:Lets update qemu and the kernel first, they take longer to build.
#Note: runtime is build at the end to get the version from all its dependencies. #Note: runtime is build at the end to get the version from all its dependencies.
projects=( projects=(
qemu-lite qemu-lite
qemu-vanilla qemu-vanilla
kernel kernel
kata-containers-image kata-containers-image
proxy proxy
shim shim
ksm-throttler ksm-throttler
runtime runtime
) )
OSCRC="${HOME}/.oscrc" OSCRC="${HOME}/.oscrc"
PUSH=${PUSH:-""} PUSH=${PUSH:-""}
LOCAL=${LOCAL:-""}
PUSH_TO_OBS=""
export BUILD_DISTROS=${BUILD_DISTROS:-xUbuntu_16.04} export BUILD_DISTROS=${BUILD_DISTROS:-xUbuntu_16.04}
# Packaging use this variable instead of use git user value # Packaging use this variable instead of use git user value
@ -29,32 +36,50 @@ export BUILD_DISTROS=${BUILD_DISTROS:-xUbuntu_16.04}
export AUTHOR="${AUTHOR:-user}" export AUTHOR="${AUTHOR:-user}"
export AUTHOR_EMAIL="${AUTHOR_EMAIL:-user@example.com}" export AUTHOR_EMAIL="${AUTHOR_EMAIL:-user@example.com}"
cd "$script_dir"
OBS_API="https://api.opensuse.org" OBS_API="https://api.opensuse.org"
if [ -n "${OBS_USER}" ] && [ -n "${OBS_PASS}" ] && [ ! -e "${OSCRC}" ]; then usage() {
echo "Creating ${OSCRC} with user $OBS_USER" msg="${1:-}"
cat << eom > "${OSCRC}" exit_code=$"${2:-0}"
cat <<EOT
${msg}
Usage:
${script_name} <kata-branch>
EOT
exit "${exit_code}"
}
main() {
local branch="${1:-}"
[ -n "${branch}" ] || usage "missing branch" "1"
if [ -n "${OBS_USER:-}" ] && [ -n "${OBS_PASS:-}" ] && [ ! -e "${OSCRC:-}" ]; then
echo "Creating ${OSCRC} with user $OBS_USER"
cat <<eom >"${OSCRC}"
[general] [general]
apiurl = ${OBS_API} apiurl = ${OBS_API}
[${OBS_API}] [${OBS_API}]
user = ${OBS_USER} user = ${OBS_USER}
pass = ${OBS_PASS} pass = ${OBS_PASS}
eom eom
fi fi
if [ -n "${PUSH}" ]; then pushd "${script_dir}"
# push to obs for p in "${projects[@]}"; do
PUSH_TO_OBS="-p" pushd "$p" >>/dev/null
elif [ -n "${LOCAL}" ]; then update_cmd="./update.sh"
# local build if [ -n "${PUSH}" ]; then
PUSH_TO_OBS="-l" # push to obs
fi update_cmd+=" -p"
elif [ -n "${LOCAL}" ]; then
# local build
update_cmd+=" -l"
fi
for p in "${projects[@]}"; do echo "update ${p}"
pushd "$p" >> /dev/null bash -c "${update_cmd} ${branch}"
echo "update ${p}" popd >>/dev/null
bash ./update.sh "${PUSH_TO_OBS}" -v done
popd >> /dev/null popd
done }
main $@

View File

@ -4,11 +4,14 @@
# #
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
[ -z "${DEBUG}" ] || set -o xtrace
set -x set -o errexit
set -e set -o nounset
set -o pipefail
script_dir=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd ) script_dir=$( cd $( dirname "${BASH_SOURCE[0]}" ) && pwd )
script_name="$(basename "${BASH_SOURCE[0]}")"
cache_dir=${PWD}/obs-cache cache_dir=${PWD}/obs-cache
#where packaing repo lives #where packaing repo lives
packaging_repo_dir=$(cd "${script_dir}/.." && pwd ) packaging_repo_dir=$(cd "${script_dir}/.." && pwd )
@ -16,38 +19,64 @@ packaging_repo_dir=$(cd "${script_dir}/.." && pwd )
host_datadir="${PWD}/pkgs" host_datadir="${PWD}/pkgs"
obs_image="obs-kata" obs_image="obs-kata"
export USE_DOCKER=1 export USE_DOCKER=1
http_proxy=${http_proxy:-}
https_proxy=${https_proxy:-}
no_proxy=${no_proxy:-}
PUSH=${PUSH:-}
if command -v go; then GO_ARCH=$(go env GOARCH)
export GO_ARCH=$(go env GOARCH) export GO_ARCH
else
export GO_ARCH=amd64
echo "Go not installed using $GO_ARCH to install go in dockerfile"
fi
export GO_ARCH=$(go env GOARCH) docker_run(){
sudo docker build \ local cmd="$@"
--build-arg http_proxy="${http_proxy}" \ sudo docker run \
--build-arg https_proxy="${https_proxy}" \ --rm \
-t $obs_image ${script_dir} -v "${HOME}/.ssh":/root/.ssh \
-v "${HOME}/.gitconfig":/root/.gitconfig \
-v /etc/profile:/etc/profile \
--env http_proxy="${http_proxy}" \
--env https_proxy="${https_proxy}" \
--env no_proxy="${no_proxy}" \
--env PUSH="${PUSH}" \
--env DEBUG="${DEBUG:-}" \
--env OBS_SUBPROJECT="${OBS_SUBPROJECT:-}"\
-v "${HOME}/.bashrc":/root/.bashrc \
-v "$cache_dir":/var/tmp/osbuild-packagecache/ \
-v "$packaging_repo_dir":${packaging_repo_dir} \
-v "$host_datadir":/var/packaging \
-v "$HOME/.oscrc":/root/.oscrc \
-ti "$obs_image" bash -c "${cmd}"
}
usage(){
msg="${1:-}"
exit_code=$"${2:-0}"
cat << EOT
${msg}
Usage:
${script_name} <kata-branch>
EOT
exit "${exit_code}"
}
pushd "${script_dir}/kata-containers-image/" >> /dev/null main(){
./build_image.sh local branch="${1:-}"
popd >> /dev/null [ -n "${branch}" ] || usage "missing branch" "1"
pushd "${script_dir}/kata-containers-image/" >> /dev/null
echo "Building image"
image_tarball=$(find . -name 'kata-containers-'"${branch}"'-*.tar.gz')
[ -f "${image_tarball}" ] || "${script_dir}/../obs-packaging/kata-containers-image/build_image.sh" -v "${branch}"
image_tarball=$(find . -name 'kata-containers-'"${branch}"'-*.tar.gz')
[ -f "${image_tarball}" ] || die "image not found"
popd >> /dev/null
sudo docker build \
--build-arg http_proxy="${http_proxy}" \
--build-arg https_proxy="${https_proxy}" \
-t $obs_image "${script_dir}"
function faketty { script -qfc "$(printf "%q " "$@")"; } #Create/update OBS repository for branch
#docker_run "${packaging_repo_dir}/obs-packaging/create-pkg-branch.sh ${branch}"
#Build all kata packages
docker_run "${packaging_repo_dir}/obs-packaging/build_all.sh ${branch}"
}
faketty sudo docker run \ main $@
--rm \
-v "${HOME}/.ssh":/root/.ssh \
-v "${HOME}/.gitconfig":/root/.gitconfig \
-v /etc/profile:/etc/profile \
--env http_proxy="${http_proxy}" \
--env https_proxy="${https_proxy}" \
--env no_proxy="${no_proxy}" \
--env PUSH="${PUSH}" \
-v "${HOME}/.bashrc":/root/.bashrc \
-v "$cache_dir":/var/tmp/osbuild-packagecache/ \
-v "$packaging_repo_dir":${packaging_repo_dir} \
-v "$host_datadir":/var/packaging \
-v "$HOME/.oscrc":/root/.oscrc \
-ti "$obs_image" bash -c "${packaging_repo_dir}/obs-packaging/build_all.sh"

104
obs-packaging/gen_versions_txt.sh Executable file
View File

@ -0,0 +1,104 @@
#!/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)"
project="kata-containers"
source "${script_dir}/../scripts/lib.sh"
get_kata_hash_from_tag(){
repo=$1
git ls-remote --tags "https://github.com/${project}/${repo}.git" | grep "refs/tags/${kata_version}^{}" | awk '{print $1}'
}
gen_version_file(){
local branch="$1"
[ -n "${branch}" ] || exit 1
local kata_version=$(curl --silent -L "https://raw.githubusercontent.com/${project}/runtime/${branch}/VERSION")
kata_runtime_hash=$(get_kata_hash_from_tag "runtime" "${kata_version}")
kata_proxy_hash=$(get_kata_hash_from_tag "proxy" "${kata_version}")
kata_shim_hash=$(get_kata_hash_from_tag "shim" "${kata_version}")
kata_agent_hash=$(get_kata_hash_from_tag "agent" "${kata_version}")
kata_ksm_throttler_hash=$(get_kata_hash_from_tag "ksm-throttler" "${kata_version}")
qemu_lite_branch=$(get_from_kata_deps "assets.hypervisor.qemu-lite.branch" "${kata_version}")
qemu_lite_version=$(curl -s -L "https://raw.githubusercontent.com/${project}/qemu/${qemu_lite_branch}/VERSION")
qemu_lite_hash=$(git ls-remote https://github.com/${project}/qemu.git | grep "refs/heads/${qemu_lite_branch}" | awk '{print $1}')
qemu_vanilla_branch=$(get_from_kata_deps "assets.hypervisor.qemu.version" "${kata_version}")
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 "refs/heads/${qemu_vanilla_branch}" | 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}")
golang_version="1.10.2"
golang_x84_64_sha256=$(curl -s -L "https://storage.googleapis.com/golang/go${golang_version}.linux-amd64.tar.gz.sha256")
cat > versions.txt << EOT
# This is a generated file from ${script_name}
kata_runtime_version=${kata_version}
kata_runtime_hash=${kata_runtime_hash}
kata_proxy_version=${kata_version}
kata_proxy_hash=${kata_proxy_hash}
kata_shim_version=${kata_version}
kata_shim_hash=${kata_shim_hash}
kata_agent_version=${kata_version}
kata_agent_hash=${kata_agent_hash}
kata_ksm_throttler_version=${kata_version}
kata_ksm_throttler_hash=${kata_ksm_throttler_hash}
# Dependencies
kata_osbuilder_version=${kata_version}
qemu_lite_version=${qemu_lite_version}
qemu_lite_hash=${qemu_lite_hash}
qemu_vanilla_version=${qemu_vanilla_version}
qemu_vanilla_hash=${qemu_lite_hash}
kernel_version=${kernel_version}
# Golang
go_version=${golang_version}
go_checksum=${golang_x84_64_sha256}
EOT
}
usage(){
msg="${1:-}"
exit_code=$"${2:-0}"
cat << EOT
${msg}
Usage:
${script_name} <kata-branch>
EOT
exit "${exit_code}"
}
main(){
local branch="${1:-}"
[ -n "${branch}" ] || usage "missing branch" "1"
gen_version_file "${branch}"
}
main $@

View File

@ -11,8 +11,6 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
[ -z "${DEBUG:-}" ] || set -x
readonly script_name="$(basename "${BASH_SOURCE[0]}")" readonly script_name="$(basename "${BASH_SOURCE[0]}")"
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly project="kata-containers" readonly project="kata-containers"
@ -25,13 +23,6 @@ source "${script_dir}/../../scripts/lib.sh"
arch_target="$(uname -m)" arch_target="$(uname -m)"
#image information
img_distro=$(get_from_kata_deps "assets.image.architecture.${arch_target}.name")
img_os_version=$(get_from_kata_deps "assets.image.architecture.${arch_target}.version")
#initrd information
initrd_distro=$(get_from_kata_deps "assets.image.architecture.${arch_target}.name")
initrd_os_version=$(get_from_kata_deps "assets.image.architecture.${arch_target}.version")
kata_version="master" kata_version="master"
@ -41,11 +32,12 @@ kata_osbuilder_version="${KATA_OSBUILDER_VERSION:-}"
agent_version="${AGENT_VERSION:-}" agent_version="${AGENT_VERSION:-}"
readonly destdir="${script_dir}" readonly destdir="${PWD}"
build_initrd(){ build_initrd(){
sudo -E PATH="$PATH" make initrd\ sudo -E PATH="$PATH" make initrd\
DISTRO="$initrd_distro" \ DISTRO="$initrd_distro" \
DEBUG="${DEBUG:-}" \
AGENT_VERSION="${agent_version}" \ AGENT_VERSION="${agent_version}" \
OS_VERSION="${initrd_os_version}" \ OS_VERSION="${initrd_os_version}" \
DISTRO_ROOTFS="${tmp_dir}/initrd-image" \ DISTRO_ROOTFS="${tmp_dir}/initrd-image" \
@ -57,6 +49,7 @@ build_initrd(){
build_image(){ build_image(){
sudo -E PATH="${PATH}" make image \ sudo -E PATH="${PATH}" make image \
DISTRO="${img_distro}" \ DISTRO="${img_distro}" \
DEBUG="${DEBUG:-}" \
AGENT_VERSION="${agent_version}" \ AGENT_VERSION="${agent_version}" \
IMG_OS_VERSION="${img_os_version}" \ IMG_OS_VERSION="${img_os_version}" \
DISTRO_ROOTFS="${tmp_dir}/rootfs-image" DISTRO_ROOTFS="${tmp_dir}/rootfs-image"
@ -107,6 +100,14 @@ main(){
# Agent version # Agent version
[ -n "${agent_version}" ] || agent_version="${kata_version}" [ -n "${agent_version}" ] || agent_version="${kata_version}"
#image information
img_distro=$(get_from_kata_deps "assets.image.architecture.${arch_target}.name" "${kata_version}")
img_os_version=$(get_from_kata_deps "assets.image.architecture.${arch_target}.version" "${kata_version}")
#initrd information
initrd_distro=$(get_from_kata_deps "assets.image.architecture.${arch_target}.name" "${kata_version}")
initrd_os_version=$(get_from_kata_deps "assets.image.architecture.${arch_target}.version" "${kata_version}")
shift "$(( $OPTIND - 1 ))" shift "$(( $OPTIND - 1 ))"
git clone "$osbuilder_url" "${tmp_dir}/osbuilder" git clone "$osbuilder_url" "${tmp_dir}/osbuilder"
pushd "${tmp_dir}/osbuilder" pushd "${tmp_dir}/osbuilder"

View File

@ -1,7 +1,5 @@
%define version @VERSION@ %define version @VERSION@
%define release @RELEASE@ %define release @RELEASE@
%define agent_sha @AGENT_SHA@
%define rootfs_os @ROOTFS_OS@
Name: kata-containers-image Name: kata-containers-image
Version: %{version} Version: %{version}

View File

@ -11,7 +11,12 @@
# Automation script to create specs to build kata-containers-image # Automation script to create specs to build kata-containers-image
# Default image to build is the one specified in file versions.txt # Default image to build is the one specified in file versions.txt
# located at the root of the repository. # located at the root of the repository.
set -e
[ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt source ../versions.txt
source ../scripts/pkglib.sh source ../scripts/pkglib.sh
@ -31,7 +36,6 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/kata-containers-image} PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/kata-containers-image}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}") RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++)) ((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
function check_image() { 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" [ ! -f "${SCRIPT_DIR}/kata-containers.tar.gz" ] && die "No kata-containers.tar.gz found!\nUse the build_image.sh script" || echo "Image: OK"
@ -40,14 +44,19 @@ function check_image() {
replace_list=( replace_list=(
"VERSION=$VERSION" "VERSION=$VERSION"
"RELEASE=$RELEASE" "RELEASE=$RELEASE"
"AGENT_SHA=${kata_agent_hash:0:7}"
"ROOTFS_OS=$osbuilder_default_os"
) )
verify verify
rm -rf kata-containers.tar.gz
image_tarball=$(find . -name 'kata-containers-'"${VERSION}"'-*.tar.gz')
[ -f "${image_tarball}" ] || die "image not found"
cp "${image_tarball}" kata-containers.tar.gz
check_image check_image
echo "Verify succeed." echo "Verify succeed."
get_git_info get_git_info
#TODO delete me: used by changelog_update
hash_tag="nocommit"
changelog_update $VERSION changelog_update $VERSION
generate_files "$SCRIPT_DIR" "${replace_list[@]}" generate_files "$SCRIPT_DIR" "${replace_list[@]}"
build_pkg "${PROJECT_REPO}" build_pkg "${PROJECT_REPO}"

View File

@ -9,7 +9,11 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
# Automation script to create specs to build Kata containers kernel # Automation script to create specs to build Kata containers kernel
set -e [ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt source ../versions.txt
source ../scripts/pkglib.sh source ../scripts/pkglib.sh
@ -56,6 +60,8 @@ replace_list=(
verify verify
echo "Verify succeed." echo "Verify succeed."
get_git_info get_git_info
#TODO delete me: used by changelog_update
hash_tag="nocommit"
changelog_update "${VERSION}-${KATA_CONFIG_VERSION}" changelog_update "${VERSION}-${KATA_CONFIG_VERSION}"
ln -sfT "${SCRIPT_DIR}/../../kernel/patches" "${SCRIPT_DIR}/patches" ln -sfT "${SCRIPT_DIR}/../../kernel/patches" "${SCRIPT_DIR}/patches"
generate_files "$SCRIPT_DIR" "${replace_list[@]}" generate_files "$SCRIPT_DIR" "${replace_list[@]}"

View File

@ -11,7 +11,11 @@
# Automation script to create specs to build ksm-throttler. # Automation script to create specs to build ksm-throttler.
# Default: Build is the one specified in file configure.ac # Default: Build is the one specified in file configure.ac
# located at the root of the repository. # located at the root of the repository.
set -e [ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt source ../versions.txt
source ../scripts/pkglib.sh source ../scripts/pkglib.sh
@ -32,7 +36,6 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/ksm-throttler} PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/ksm-throttler}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}") RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++)) ((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
set_versions "$kata_ksm_throttler_hash" set_versions "$kata_ksm_throttler_hash"

View File

@ -6,11 +6,7 @@
%global IMPORTNAME %{DOMAIN}/%{ORG}/%{PROJECT} %global IMPORTNAME %{DOMAIN}/%{ORG}/%{PROJECT}
%global GO_VERSION @GO_VERSION@ %global GO_VERSION @GO_VERSION@
%if 0%{?suse_version} %define LIBEXECDIR /usr/libexec
%define LIBEXECDIR %{_libdir}
%else
%define LIBEXECDIR %{_libexecdir}
%endif
%undefine _missing_build_ids_terminate_build %undefine _missing_build_ids_terminate_build
Name: kata-proxy Name: kata-proxy

View File

@ -8,7 +8,11 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
# #
# Automation script to create specs to build kata-proxy # Automation script to create specs to build kata-proxy
set -e [ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt source ../versions.txt
source ../scripts/pkglib.sh source ../scripts/pkglib.sh
@ -28,7 +32,6 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/proxy} PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/proxy}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}") RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++)) ((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
set_versions $kata_proxy_hash set_versions $kata_proxy_hash

View File

@ -8,7 +8,11 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
# Automation script to create specs to build kata containers kernel # Automation script to create specs to build kata containers kernel
set -e [ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt source ../versions.txt
source ../scripts/pkglib.sh source ../scripts/pkglib.sh
@ -28,8 +32,8 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-lite} PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-lite}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}") RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++)) ((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
set_versions "${qemu_lite_hash}"
replace_list=( replace_list=(
"VERSION=$VERSION" "VERSION=$VERSION"

View File

@ -7,7 +7,7 @@
<param name="filename">qemu-vanilla</param> <param name="filename">qemu-vanilla</param>
<!--- %h in the version format is a hash from a given revision --> <!--- %h in the version format is a hash from a given revision -->
<param name="versionformat">@VERSION@+git.%h</param> <param name="versionformat">@VERSION@+git.%h</param>
<param name="revision">stable-@VERSION@</param> <param name="revision">@QEMU_VANILLA_HASH@</param>
</service> </service>
<service name="recompress"> <service name="recompress">
<param name="file">*.tar*</param> <param name="file">*.tar*</param>

View File

@ -9,7 +9,11 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
# Automation script to create specs to build kata containers kernel # Automation script to create specs to build kata containers kernel
set -e [ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt source ../versions.txt
source ../scripts/pkglib.sh source ../scripts/pkglib.sh
@ -29,7 +33,8 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-vanilla} PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-vanilla}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}") RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++)) ((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
set_versions "${qemu_vanilla_hash}"
replace_list=( replace_list=(
"VERSION=$VERSION" "VERSION=$VERSION"

View File

@ -11,7 +11,11 @@
# Automation script to create specs to build kata-runtime # Automation script to create specs to build kata-runtime
# Default: Build is the one specified in file configure.ac # Default: Build is the one specified in file configure.ac
# located at the root of the repository. # located at the root of the repository.
set -e [ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt source ../versions.txt
source ../scripts/pkglib.sh source ../scripts/pkglib.sh
@ -51,7 +55,7 @@ info "shim ${SHIM_REQUIRED_VERSION}"
KERNEL_RELEASE=$(get_obs_pkg_release "home:${OBS_PROJECT}:${OBS_SUBPROJECT}/linux-container") KERNEL_RELEASE=$(get_obs_pkg_release "home:${OBS_PROJECT}:${OBS_SUBPROJECT}/linux-container")
KERNEL_CONFIG_VERSION=$(cat "${SCRIPT_DIR}/../../kernel/kata_config_version") KERNEL_CONFIG_VERSION=$(cat "${SCRIPT_DIR}/../../kernel/kata_config_version")
KERNEL_REQUIRED_VERSION=$(pkg_version "${kernel_version}.${KERNEL_CONFIG_VERSION}" "${KERNEL_RELEASE}") KERNEL_REQUIRED_VERSION=$(pkg_version "${kernel_version}.${KERNEL_CONFIG_VERSION}" "${KERNEL_RELEASE}" "")
info "kata-linux-container ${KERNEL_REQUIRED_VERSION}" info "kata-linux-container ${KERNEL_REQUIRED_VERSION}"
KSM_THROTTLER_RELEASE=$(get_obs_pkg_release "home:${OBS_PROJECT}:${OBS_SUBPROJECT}/ksm-throttler") KSM_THROTTLER_RELEASE=$(get_obs_pkg_release "home:${OBS_PROJECT}:${OBS_SUBPROJECT}/ksm-throttler")
@ -59,23 +63,21 @@ KSM_THROTTLER_REQUIRED_VERSION=$(pkg_version "${kata_ksm_throttler_version}" "${
info "ksm-throttler ${KSM_THROTTLER_REQUIRED_VERSION}" info "ksm-throttler ${KSM_THROTTLER_REQUIRED_VERSION}"
KATA_CONTAINERS_IMAGE_RELEASE=$(get_obs_pkg_release "home:${OBS_PROJECT}:${OBS_SUBPROJECT}/kata-containers-image") KATA_CONTAINERS_IMAGE_RELEASE=$(get_obs_pkg_release "home:${OBS_PROJECT}:${OBS_SUBPROJECT}/kata-containers-image")
KATA_IMAGE_REQUIRED_VERSION=$(pkg_version "${kata_osbuilder_version}" "${KATA_CONTAINERS_IMAGE_RELEASE}") KATA_IMAGE_REQUIRED_VERSION=$(pkg_version "${kata_osbuilder_version}" "${KATA_CONTAINERS_IMAGE_RELEASE}" "")
info "image ${KATA_IMAGE_REQUIRED_VERSION}" info "image ${KATA_IMAGE_REQUIRED_VERSION}"
KATA_CONTAINERS_QEMU_LITE_RELEASE=$(get_obs_pkg_release "home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-lite") KATA_CONTAINERS_QEMU_LITE_RELEASE=$(get_obs_pkg_release "home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-lite")
KATA_QEMU_LITE_REQUIRED_VERSION=$(pkg_version "${qemu_lite_version}" "${KATA_CONTAINERS_QEMU_LITE_RELEASE}") KATA_QEMU_LITE_REQUIRED_VERSION=$(pkg_version "${qemu_lite_version}" "${KATA_CONTAINERS_QEMU_LITE_RELEASE}" "")
info "image ${KATA_QEMU_LITE_REQUIRED_VERSION}" info "image ${KATA_QEMU_LITE_REQUIRED_VERSION}"
KATA_CONTAINERS_QEMU_VANILLA_RELEASE=$(get_obs_pkg_release "home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-vanilla") KATA_CONTAINERS_QEMU_VANILLA_RELEASE=$(get_obs_pkg_release "home:${OBS_PROJECT}:${OBS_SUBPROJECT}/qemu-vanilla")
KATA_QEMU_VANILLA_REQUIRED_VERSION=$(pkg_version "${qemu_vanilla_version}" "${KATA_CONTAINERS_QEMU_VANILLA_RELEASE}") KATA_QEMU_VANILLA_REQUIRED_VERSION=$(pkg_version "${qemu_vanilla_version}" "${KATA_CONTAINERS_QEMU_VANILLA_RELEASE}" "")
info "image ${KATA_QEMU_VANILLA_REQUIRED_VERSION}" info "image ${KATA_QEMU_VANILLA_REQUIRED_VERSION}"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/runtime} PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/runtime}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}") RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++)) ((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
set_versions "$kata_runtime_hash" set_versions "$kata_runtime_hash"
replace_list=( replace_list=(

View File

@ -47,7 +47,6 @@ function display_help()
Options: Options:
-l --local-build Build the runtime locally -l --local-build Build the runtime locally
-c --commit-id Build with a given commit ID
-b --branch Build with a given branch name -b --branch Build with a given branch name
-p --push Push changes to OBS -p --push Push changes to OBS
-a --api-url Especify an OBS API (e.g. custom private OBS) -a --api-url Especify an OBS API (e.g. custom private OBS)
@ -61,9 +60,9 @@ function display_help()
Usage examples: Usage examples:
$SCRIPT_NAME --local-build --branch staging $SCRIPT_NAME --local-build --branch staging
$SCRIPT_NAME --commit-id a76f45c --push --api-url http://127.0.0.1 $SCRIPT_NAME --push --api-url http://127.0.0.1
$SCRIPT_NAME --commit-id a76f45c --push --obs-repository home:userx/repository $SCRIPT_NAME --push --obs-repository home:userx/repository
$SCRIPT_NAME --commit-id a76f45c --push $SCRIPT_NAME --push
EOL EOL
exit 1 exit 1
@ -117,20 +116,7 @@ function get_git_info()
function set_versions() function set_versions()
{ {
local commit_hash="$1" local commit_hash="$1"
hash_tag="$commit_hash"
if [ -n "$OBS_REVISION" ]
then
# Validate input is alphanumeric, commit ID
# If a commit ID is provided, override versions.txt one
if [ -n "$COMMIT" ] && [[ "$OBS_REVISION" =~ ^[a-zA-Z0-9][-a-zA-Z0-9]{0,40}[a-zA-Z0-9]$ ]]; then
hash_tag=$OBS_REVISION
elif [ -n "$BRANCH" ]
then
hash_tag=$commit_hash
fi
else
hash_tag=$commit_hash
fi
short_hashtag="${hash_tag:0:7}" short_hashtag="${hash_tag:0:7}"
} }
@ -177,25 +163,23 @@ function local_build()
function checkout_repo() function checkout_repo()
{ {
local REPO="$1" local REPO="${1}"
if [ -z "$OBS_WORKDIR" ] if [ -z "${OBS_WORKDIR:-}" ]
then then
# If no workdir is provided, use a temporary directory. OBS_WORKDIR=$(mktemp -d -u -t obs-repo.XXXXXXXXXXX) || exit 1
temp=$(basename $0) osc co "${REPO}" -o "${OBS_WORKDIR}"
OBS_WORKDIR=$(mktemp -d -u -t ${temp}.XXXXXXXXXXX) || exit 1
osc $APIURL co $REPO -o $OBS_WORKDIR
fi fi
find ${OBS_WORKDIR} -maxdepth 1 -mindepth 1 ! -name '.osc' -prune -exec echo remove {} \; -exec rm -rf {} \; find "${OBS_WORKDIR}" -maxdepth 1 -mindepth 1 ! -name '.osc' -prune -exec echo remove {} \; -exec rm -rf {} \;
mv ${GENERATED_FILES[@]} "$OBS_WORKDIR" mv "${GENERATED_FILES[@]}" "${OBS_WORKDIR}"
cp ${STATIC_FILES[@]} "$OBS_WORKDIR" cp "${STATIC_FILES[@]}" "$OBS_WORKDIR"
} }
function obs_push() function obs_push()
{ {
pushd $OBS_WORKDIR pushd $OBS_WORKDIR
osc $APIURL addremove osc addremove
osc $APIURL commit -m "Update ${PKG_NAME} $VERSION: ${hash_tag:0:7}" osc commit -m "Update ${PKG_NAME} $VERSION: ${hash_tag:0:7}"
popd popd
} }
@ -204,9 +188,7 @@ function cli()
OPTS=$(getopt -o abclprwvCVh: --long api-url,branch,commit-id,local-build,push,obs-repository,workdir,verbose,clean,verify,help -- "$@") OPTS=$(getopt -o abclprwvCVh: --long api-url,branch,commit-id,local-build,push,obs-repository,workdir,verbose,clean,verify,help -- "$@")
while true; do while true; do
case "${1}" in case "${1}" in
-a | --api-url ) APIURL="$2"; shift 2;;
-b | --branch ) BRANCH="true"; OBS_REVISION="$2"; shift 2;; -b | --branch ) BRANCH="true"; OBS_REVISION="$2"; shift 2;;
-c | --commit-id ) COMMIT="true"; OBS_REVISION="$2"; shift 2;;
-l | --local-build ) LOCAL_BUILD="true"; shift;; -l | --local-build ) LOCAL_BUILD="true"; shift;;
-p | --push ) OBS_PUSH="true"; shift;; -p | --push ) OBS_PUSH="true"; shift;;
-r | --obs-repository ) PROJECT_REPO="$2"; shift 2;; -r | --obs-repository ) PROJECT_REPO="$2"; shift 2;;
@ -313,15 +295,27 @@ function get_obs_pkg_release() {
pkg=$(basename "${obs_pkg_name}") pkg=$(basename "${obs_pkg_name}")
repo_dir=$(mktemp -d -u -t "${pkg}.XXXXXXXXXXX") repo_dir=$(mktemp -d -u -t "${pkg}.XXXXXXXXXXX")
out=$(osc ${APIURL} -q co "${obs_pkg_name}" -o "${repo_dir}") || die "failed to checkout:$out" out=$(osc -q 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) spec_file=$(find "${repo_dir}" -maxdepth 1 -type f -name '*.spec' | head -1)
# Find in specfile in Release: XX field.
release=$(grep -oP 'Release:\s+[0-9]+' "${spec_file}" | grep -oP '[0-9]+') release=$(grep -oP 'Release:\s+[0-9]+' "${spec_file}" | grep -oP '[0-9]+')
if [ -z "${release}" ]; then if [ -z "${release}" ]; 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]+') release=$(grep -oP '%define\s+release\s+[0-9]+' "${spec_file}" | grep -oP '[0-9]+')
fi 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}" rm -r "${repo_dir}"
echo "${release}" echo "${release}"
} }

View File

@ -4,11 +4,7 @@
%global IMPORTNAME %{DOMAIN}/%{ORG}/%{PROJECT} %global IMPORTNAME %{DOMAIN}/%{ORG}/%{PROJECT}
%global GO_VERSION @GO_VERSION@ %global GO_VERSION @GO_VERSION@
%if 0%{?suse_version} %define LIBEXECDIR /usr/libexec
%define LIBEXECDIR %{_libdir}
%else
%define LIBEXECDIR %{_libexecdir}
%endif
%undefine _missing_build_ids_terminate_build %undefine _missing_build_ids_terminate_build
Name: kata-shim Name: kata-shim
@ -77,5 +73,6 @@ make install LIBEXECDIR=%{buildroot}%{LIBEXECDIR} COMMIT=@HASH@
%files bin %files bin
%defattr(-,root,root,-) %defattr(-,root,root,-)
%{LIBEXECDIR}/kata-containers %dir %{LIBEXECDIR}
%dir %{LIBEXECDIR}/kata-containers
%{LIBEXECDIR}/kata-containers/kata-shim %{LIBEXECDIR}/kata-containers/kata-shim

View File

@ -9,7 +9,11 @@
# ex: ts=8 sw=4 sts=4 et filetype=sh # ex: ts=8 sw=4 sts=4 et filetype=sh
# #
# Automation script to create specs to build kata-shim # Automation script to create specs to build kata-shim
set -e [ -z "${DEBUG}" ] || set -o xtrace
set -o errexit
set -o nounset
set -o pipefail
source ../versions.txt source ../versions.txt
source ../scripts/pkglib.sh source ../scripts/pkglib.sh
@ -29,7 +33,6 @@ cli "$@"
PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/shim} PROJECT_REPO=${PROJECT_REPO:-home:${OBS_PROJECT}:${OBS_SUBPROJECT}/shim}
RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}") RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++)) ((RELEASE++))
[ -n "$APIURL" ] && APIURL="-A ${APIURL}"
set_versions $kata_shim_hash set_versions $kata_shim_hash
replace_list=( replace_list=(

View File

@ -1,32 +1,32 @@
kata_agent_hash=7b458b18ffcbb90a1aed1644d109ea438f39c9a0
kata_ksm_throttler_hash=1fecaffc98386fdb080979d38d5688566eec54a1 # This is a generated file from gen_versions_txt.sh
kata_proxy_hash=8a305e5a61856c7510350b0ade5a5dc5e9255dbf
kata_runtime_hash=bf1cf684f5d48d3142665f98daf719faf94039e2 kata_runtime_version=1.2.0
kata_shim_hash=de2d2a67659cab7928b81f836a8f64450c998453 kata_runtime_hash=0bcb32f7042625ea0ecee8f37b99b4459ebd5af8
kata_proxy_version=1.2.0
kata_proxy_hash=17962180fc61c66066905546bfd5d8933bf73df1
kata_shim_version=1.2.0
kata_shim_hash=0a37760c0224167143cb3cc920c78f5147f52e70
kata_agent_version=1.2.0
kata_agent_hash=fcfa054a757e7c17afba47b0b4d7e91cbb8688ed
kata_ksm_throttler_version=1.2.0
kata_ksm_throttler_hash=f232434f36b1b2c916eb6211118cf26671bd04ef
# Dependencies # Dependencies
qemu_lite_hash=6ba2bfbee9a80bfd03605c5eb2ca743c8b68389e kata_osbuilder_version=1.2.0
qemu_vanilla_hash=e3050471ff1daa7fefe88388dfa4e1d97ba1f0bc
kata_runtime_version=1.1.0
kata_proxy_version=1.1.0
kata_shim_version=1.1.0
kata_agent_version=1.1.0
kata_ksm_throttler_version=1.1.0
kata_osbuilder_version=1.1.0
qemu_lite_version=2.11.0 qemu_lite_version=2.11.0
qemu_vanilla_version=2.11 qemu_lite_hash=a39e0b3e828ff6fb4457865ef7a021f1e7320c27
qemu_vanilla_version=2.11.2
qemu_vanilla_hash=a39e0b3e828ff6fb4457865ef7a021f1e7320c27
kernel_version=4.14.51 kernel_version=4.14.51
# Default osbuilder image options
osbuilder_default_os=clearlinux
clearlinux_version=20640
# Default osbuilder initrd options
osbuilder_default_initrd_os=alpine
alpine_version=3.7
# Golang # Golang
go_version=1.10.2 go_version=1.10.2
# sha256 checksum for the go_version binary distribution ("go${go_version}.linux-amd64.tar.gz")
go_checksum=4b677d698c65370afa33757b6954ade60347aaca310ea92a63ed717d7cb0c2ff go_checksum=4b677d698c65370afa33757b6954ade60347aaca310ea92a63ed717d7cb0c2ff

169
release/kata-deploy-binaries.sh Executable file
View File

@ -0,0 +1,169 @@
#!/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 project="kata-containers"
readonly prefix="/opt/kata"
readonly project_to_attach="github.com/${project}/runtime"
readonly tmp_dir=$(mktemp -d -t static-build-tmp.XXXXXXXXXX)
readonly GOPATH="${tmp_dir}/go"
# flag to decide if push tarball to github
push=false
export GOPATH
workdir="${WORKDIR:-$PWD}"
exit_handler() {
[ -d "${tmp_dir}" ] || sudo rm -rf "${tmp_dir}"
}
trap exit_handler EXIT
projects=(
proxy
runtime
shim
)
die() {
msg="$*"
echo "ERROR: ${msg}" >&2
exit 1
}
info() {
echo "INFO: $*"
}
usage() {
return_code=${1:-0}
cat <<EOT
This script is used as part of the ${project} release process.
It is used to create a tarball with static binaries.
Usage:
${script_name} <options> [version]
Args:
version: The kata version that will be use to create the tarball
options:
-h : Show this help
-p : push tarball to ${project_to_attach}
-w <dir>: directory where tarball will be created
EOT
exit "${return_code}"
}
#Install guest image/initrd asset
install_image() {
image_destdir="${destdir}/${prefix}/share/kata-containers/"
info "Create image"
image_tarball=$(find . -name 'kata-containers-'"${kata_version}"'-*.tar.gz')
[ -f "${image_tarball}" ] || "${script_dir}/../obs-packaging/kata-containers-image/build_image.sh" -v "${kata_version}"
image_tarball=$(find . -name 'kata-containers-'"${kata_version}"'-*.tar.gz')
[ -f "${image_tarball}" ] || die "image not found"
info "Install image in destdir ${image_tarball}"
mkdir -p "${image_destdir}"
tar xf "${image_tarball}" -C "${image_destdir}"
pushd "${destdir}/${prefix}/share/kata-containers/" >>/dev/null
info "Create image default symlinks"
image=$(find . -name 'kata-containers-image*.img')
initrd=$(find . -name 'kata-containers-initrd*.initrd')
ln -sf "${image}" kata-containers.img
ln -sf "${initrd}" kata-containers-initrd.img
popd >>/dev/null
}
#Install kernel asset
install_kernel() {
go get "github.com/${project}/packaging" || true
pushd ${GOPATH}/src/github.com/${project}/packaging >>/dev/null
git checkout "${kata_version}-kernel-config"
popd >>/dev/null
pushd "${script_dir}/../kernel" >>/dev/null
info "build kernel"
./build-kernel.sh setup
./build-kernel.sh build
info "install kernel"
DESTDIR="${destdir}" PREFIX="${prefix}" ./build-kernel.sh install
popd >>/dev/null
}
# Install static qemu asset
install_qemu() {
info "build static qemu"
"${script_dir}/../static-build/qemu/build-static-qemu.sh"
info "Install static qemu"
tar xf kata-qemu-static.tar.gz -C "${destdir}"
}
#Install all components that are not assets
install_kata_components() {
for p in "${projects[@]}"; do
echo "Download ${p}"
go get "github.com/${project}/$p" || true
pushd "${GOPATH}/src/github.com/${project}/$p" >>/dev/null
echo "Checkout to version ${kata_version}"
git checkout "${kata_version}"
echo "Build"
make \
PREFIX="${prefix}" \
QEMUCMD="qemu-system-x86_64"
#TODO Remove libexecdir
echo "Install"
make PREFIX="${prefix}" \
DESTDIR="${destdir}" \
LIBEXECDIR="/${destdir}/${prefix}/libexec/" \
install
popd >>/dev/null
done
sed -i -e '/^initrd =/d' "${destdir}/${prefix}/share/defaults/${project}/configuration.toml"
}
main() {
while getopts "hpw:" opt; do
case $opt in
h) usage 0 ;;
p) push="true" ;;
w) workdir="${OPTARG}" ;;
esac
done
shift $((OPTIND - 1))
kata_version=${1:-}
[ -n "${kata_version}" ] || usage 1
info "Requested version: ${kata_version}"
destdir="${workdir}/kata-static-${kata_version}-$(arch)"
info "DESTDIR ${destdir}"
mkdir -p "${destdir}"
install_image
install_kata_components
install_kernel
install_qemu
tarball_name="${destdir}.tar.xz"
pushd "${destdir}" >>/dev/null
tar cfJ "${tarball_name}" "./opt"
popd >>/dev/null
if [ "${push}" == "true" ]; then
hub -C "${GOPATH}/src/github.com/${project}/runtime" release edit -a "${tarball_name}" "${kata_version}"
else
echo "Wont push the tarball to github use -p option to do it."
fi
}
main $@

70
release/publish-kata-image.sh Executable file
View File

@ -0,0 +1,70 @@
#!/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
workdir="${PWD}"
readonly script_name="$(basename "${BASH_SOURCE[0]}")"
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly project="kata-containers"
GOPATH=${GOPATH:-${HOME}/go}
die() {
msg="$*"
echo "ERROR: ${FUNCNAME[1]} ${msg}" >&2
exit 1
}
usage() {
return_code=${1:-0}
cat <<EOT
Usage:
${script_name} [options] <version>
version: Kata version to create the image.
Create image for a kata version.
options:
-h : show this help
-p : push image to github
EOT
exit "${return_code}"
}
main() {
push="false"
while getopts "d:hp" opt; do
case $opt in
h) usage 0 ;;
p) push="true" ;;
esac
done
shift $((OPTIND - 1))
kata_version=${1:-}
[ -n "${kata_version}" ] || usage "1"
image_tarball=$(find -name 'kata-containers-*.tar.gz' | grep "${kata_version}") ||
"${script_dir}/../obs-packaging/kata-containers-image/build_image.sh" -v "${kata_version}"
image_tarball=$(find -name 'kata-containers-*.tar.gz' | grep "${kata_version}") || die "file not found ${image_tarball}"
if [ ${push} == "true" ]; then
hub -C "${GOPATH}/src/github.com/${project}/agent" release edit -a "${image_tarball}" "${kata_version}"
else
echo "Wont push image to github use -p option to do it."
fi
}
main $@

View File

@ -34,6 +34,9 @@ typeset -a qemu_options
typeset -A recognised_tags typeset -A recognised_tags
# Prefix were kata will be installed
prefix=${PREFIX:-/usr}
recognised_tags=( recognised_tags=(
[arch]="architecture-specific" [arch]="architecture-specific"
[functionality]="required functionality" [functionality]="required functionality"
@ -402,14 +405,17 @@ generate_qemu_options()
unset _qemu_ldflags unset _qemu_ldflags
# Where to install qemu helper binaries
qemu_options+=(misc:--prefix=${prefix})
# Where to install qemu libraries # Where to install qemu libraries
qemu_options+=(arch:--libdir=/usr/lib64/${hypervisor}) qemu_options+=(arch:--libdir=${prefix}/lib/${hypervisor})
# Where to install qemu helper binaries # Where to install qemu helper binaries
qemu_options+=(misc:--libexecdir=/usr/libexec/${hypervisor}) qemu_options+=(misc:--libexecdir=${prefix}/libexec/${hypervisor})
# Where to install data files # Where to install data files
qemu_options+=(misc:--datadir=/usr/share/${hypervisor}) qemu_options+=(misc:--datadir=${prefix}/share/${hypervisor})
} }

View File

@ -31,16 +31,16 @@ install_yq() {
} }
get_from_kata_deps(){ get_from_kata_deps(){
dependency="$1" local dependency="$1"
local branch="${2:-master}"
local runtime_repo="github.com/kata-containers/runtime"
GOPATH=${GOPATH:-${HOME}/go} GOPATH=${GOPATH:-${HOME}/go}
# This is needed in order to retrieve the version for qemu-lite # This is needed in order to retrieve the version for qemu-lite
install_yq >&2 install_yq >&2
runtime_repo="github.com/kata-containers/runtime" yaml_url="https://raw.githubusercontent.com/kata-containers/runtime/${branch}/versions.yaml"
runtime_repo_dir="$GOPATH/src/${runtime_repo}" versions_file="versions_${branch}.yaml"
versions_file="${runtime_repo_dir}/versions.yaml" [ ! -e "${versions_file}" ] || download_on_new_flag="-z ${versions_file}"
mkdir -p $(dirname "${runtime_repo_dir}") curl --silent -o "${versions_file}" ${download_on_new_flag:-} "$yaml_url"
[ -d "${runtime_repo_dir}" ] || git clone --quiet https://${runtime_repo}.git "${runtime_repo_dir}"
[ ! -f "$versions_file" ] && { echo >&2 "ERROR: cannot find $versions_file"; exit 1; }
result=$("${GOPATH}/bin/yq" read "$versions_file" "$dependency") result=$("${GOPATH}/bin/yq" read "$versions_file" "$dependency")
[ "$result" = "null" ] && result="" [ "$result" = "null" ] && result=""
echo "$result" echo "$result"

View File

@ -39,7 +39,9 @@ RUN git clone https://github.com/qemu/keycodemapdb.git ui/keycodemapdb
ADD configure-hypervisor.sh /root/configure-hypervisor.sh ADD configure-hypervisor.sh /root/configure-hypervisor.sh
RUN /root/configure-hypervisor.sh -s kata-qemu | xargs ./configure --prefix=/opt/kata --with-pkgversion=kata-static RUN PREFIX=/opt/kata /root/configure-hypervisor.sh -s kata-qemu | xargs ./configure \
--with-pkgversion=kata-static
RUN make clean RUN make clean
RUN make -j$(nproc) RUN make -j$(nproc)
RUN make install DESTDIR=/tmp/qemu-static RUN make install DESTDIR=/tmp/qemu-static