Merge pull request #138 from jcvenegas/shfmt

format: use shfmt to format sh files.
This commit is contained in:
Julio Montes
2018-08-17 10:53:18 -05:00
committed by GitHub
31 changed files with 447 additions and 449 deletions

View File

@@ -5,7 +5,7 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# If we fail for any reason a message will be displayed # If we fail for any reason a message will be displayed
die(){ die() {
msg="$*" msg="$*"
echo "ERROR: $msg" >&2 echo "ERROR: $msg" >&2
exit 1 exit 1
@@ -14,12 +14,10 @@ die(){
export tests_repo="${tests_repo:-github.com/kata-containers/tests}" export tests_repo="${tests_repo:-github.com/kata-containers/tests}"
export tests_repo_dir="$GOPATH/src/$tests_repo" export tests_repo_dir="$GOPATH/src/$tests_repo"
clone_tests_repo() clone_tests_repo() {
{
# KATA_CI_NO_NETWORK is (has to be) ignored if there is # KATA_CI_NO_NETWORK is (has to be) ignored if there is
# no existing clone. # no existing clone.
if [ -d "${tests_repo_dir}" ] && [ -n "${KATA_CI_NO_NETWORK:-}" ] if [ -d "${tests_repo_dir}" ] && [ -n "${KATA_CI_NO_NETWORK:-}" ]; then
then
return return
fi fi
@@ -30,7 +28,7 @@ install_yq() {
path=$1 path=$1
local yq_path=${path}/yq local yq_path=${path}/yq
local yq_pkg="github.com/mikefarah/yq" local yq_pkg="github.com/mikefarah/yq"
[ -x "${yq_path}" ] && return [ -x "${yq_path}" ] && return
case "$(arch)" in case "$(arch)" in
"aarch64") "aarch64")
@@ -60,7 +58,6 @@ install_yq() {
# https://github.com/mikefarah/yq/releases/tag/<VERSION-HERE> # https://github.com/mikefarah/yq/releases/tag/<VERSION-HERE>
yq_version=$(basename "${yq_latest_url}") yq_version=$(basename "${yq_latest_url}")
local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_linux_${goarch}" local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_linux_${goarch}"
curl -o "${yq_path}" -L ${yq_url} curl -o "${yq_path}" -L ${yq_url}
chmod +x ${yq_path} chmod +x ${yq_path}

View File

@@ -15,7 +15,7 @@ source /etc/os-release
# This script will execute packaging tests suite # This script will execute packaging tests suite
if [ "$ID" == ubuntu ];then if [ "$ID" == ubuntu ]; then
echo "Building snap image" echo "Building snap image"
make snap make snap
fi fi

View File

@@ -11,9 +11,9 @@ set -o pipefail
source /etc/os-release source /etc/os-release
echo "Setup script for packaging" echo "Setup script for packaging"
if [ "$ID" == ubuntu ];then if [ "$ID" == ubuntu ]; then
echo "Install snap dependencies" echo "Install snap dependencies"
sudo apt-get install -y snapd snapcraft sudo apt-get install -y snapd snapcraft

View File

@@ -17,10 +17,10 @@ echo "create containerd configuration for Kata"
mkdir -p /etc/containerd/ mkdir -p /etc/containerd/
if [ -f /etc/containerd/config.toml ]; then if [ -f /etc/containerd/config.toml ]; then
cp /etc/containerd/config.toml /etc/containerd/config.toml.bak cp /etc/containerd/config.toml /etc/containerd/config.toml.bak
fi fi
cat << EOT | tee /etc/containerd/config.toml cat <<EOT | tee /etc/containerd/config.toml
[plugins] [plugins]
[plugins.cri.containerd] [plugins.cri.containerd]
[plugins.cri.containerd.untrusted_workload_runtime] [plugins.cri.containerd.untrusted_workload_runtime]

View File

@@ -5,6 +5,5 @@ rm -rf /usr/share/defaults/kata-containers
rm -f /etc/containerd/config.toml rm -f /etc/containerd/config.toml
if [ -f /etc/containerd/config.toml.bak ]; then if [ -f /etc/containerd/config.toml.bak ]; then
mv /etc/containerd/config.toml.bak /etc/containerd/config.toml mv /etc/containerd/config.toml.bak /etc/containerd/config.toml
fi fi

View File

@@ -165,7 +165,7 @@ setup_kernel() {
download_kernel="true" download_kernel="true"
[ -n "$kernel_version" ] || die "failed to get kernel version: Kernel version is emtpy" [ -n "$kernel_version" ] || die "failed to get kernel version: Kernel version is emtpy"
if [[ "${download_kernel}" == "true" ]]; then if [[ ${download_kernel} == "true" ]]; then
get_kernel "${kernel_version}" "${kernel_path}" get_kernel "${kernel_version}" "${kernel_path}"
fi fi
@@ -273,7 +273,7 @@ main() {
esac esac
done done
shift $(($OPTIND - 1)) shift $((OPTIND - 1))
subcmd="${1:-}" subcmd="${1:-}"

View File

@@ -1 +1 @@
8 9

View File

@@ -10,11 +10,11 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail 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]}")" 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)
#where results will be stored #where results will be stored
host_datadir="${PWD}/pkgs" host_datadir="${PWD}/pkgs"
obs_image="obs-kata" obs_image="obs-kata"
@@ -27,7 +27,7 @@ PUSH=${PUSH:-}
GO_ARCH=$(go env GOARCH) GO_ARCH=$(go env GOARCH)
export GO_ARCH export GO_ARCH
docker_run(){ docker_run() {
local cmd="$@" local cmd="$@"
sudo docker run \ sudo docker run \
--rm \ --rm \
@@ -39,7 +39,7 @@ docker_run(){
--env no_proxy="${no_proxy}" \ --env no_proxy="${no_proxy}" \
--env PUSH="${PUSH}" \ --env PUSH="${PUSH}" \
--env DEBUG="${DEBUG:-}" \ --env DEBUG="${DEBUG:-}" \
--env OBS_SUBPROJECT="${OBS_SUBPROJECT:-}"\ --env OBS_SUBPROJECT="${OBS_SUBPROJECT:-}" \
-v "${HOME}/.bashrc":/root/.bashrc \ -v "${HOME}/.bashrc":/root/.bashrc \
-v "$cache_dir":/var/tmp/osbuild-packagecache/ \ -v "$cache_dir":/var/tmp/osbuild-packagecache/ \
-v "$packaging_repo_dir":${packaging_repo_dir} \ -v "$packaging_repo_dir":${packaging_repo_dir} \
@@ -47,10 +47,10 @@ docker_run(){
-v "$HOME/.oscrc":/root/.oscrc \ -v "$HOME/.oscrc":/root/.oscrc \
-ti "$obs_image" bash -c "${cmd}" -ti "$obs_image" bash -c "${cmd}"
} }
usage(){ usage() {
msg="${1:-}" msg="${1:-}"
exit_code=$"${2:-0}" exit_code=$"${2:-0}"
cat << EOT cat <<EOT
${msg} ${msg}
Usage: Usage:
${script_name} <kata-branch> ${script_name} <kata-branch>
@@ -58,16 +58,16 @@ EOT
exit "${exit_code}" exit "${exit_code}"
} }
main(){ main() {
local branch="${1:-}" local branch="${1:-}"
[ -n "${branch}" ] || usage "missing branch" "1" [ -n "${branch}" ] || usage "missing branch" "1"
pushd "${script_dir}/kata-containers-image/" >> /dev/null pushd "${script_dir}/kata-containers-image/" >>/dev/null
echo "Building image" echo "Building image"
image_tarball=$(find . -name 'kata-containers-'"${branch}"'-*.tar.gz') image_tarball=$(find . -name 'kata-containers-'"${branch}"'-*.tar.gz')
[ -f "${image_tarball}" ] || "${script_dir}/../obs-packaging/kata-containers-image/build_image.sh" -v "${branch}" [ -f "${image_tarball}" ] || "${script_dir}/../obs-packaging/kata-containers-image/build_image.sh" -v "${branch}"
image_tarball=$(find . -name 'kata-containers-'"${branch}"'-*.tar.gz') image_tarball=$(find . -name 'kata-containers-'"${branch}"'-*.tar.gz')
[ -f "${image_tarball}" ] || die "image not found" [ -f "${image_tarball}" ] || die "image not found"
popd >> /dev/null popd >>/dev/null
sudo docker build \ sudo docker build \
--build-arg http_proxy="${http_proxy}" \ --build-arg http_proxy="${http_proxy}" \
--build-arg https_proxy="${https_proxy}" \ --build-arg https_proxy="${https_proxy}" \

View File

@@ -15,23 +15,22 @@ project="kata-containers"
source "${script_dir}/../scripts/lib.sh" source "${script_dir}/../scripts/lib.sh"
get_kata_hash_from_tag(){ get_kata_hash_from_tag() {
repo=$1 repo=$1
git ls-remote --tags "https://github.com/${project}/${repo}.git" | grep "refs/tags/${kata_version}^{}" | awk '{print $1}' git ls-remote --tags "https://github.com/${project}/${repo}.git" | grep "refs/tags/${kata_version}^{}" | awk '{print $1}'
} }
gen_version_file(){ gen_version_file() {
local branch="$1" local branch="$1"
[ -n "${branch}" ] || exit 1 [ -n "${branch}" ] || exit 1
local kata_version=$(curl --silent -L "https://raw.githubusercontent.com/${project}/runtime/${branch}/VERSION") 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_runtime_hash=$(get_kata_hash_from_tag "runtime" "${kata_version}")
kata_proxy_hash=$(get_kata_hash_from_tag "proxy" "${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_shim_hash=$(get_kata_hash_from_tag "shim" "${kata_version}")
kata_agent_hash=$(get_kata_hash_from_tag "agent" "${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}") 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_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_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_lite_hash=$(git ls-remote https://github.com/${project}/qemu.git | grep "refs/heads/${qemu_lite_branch}" | awk '{print $1}')
@@ -48,7 +47,7 @@ gen_version_file(){
golang_version="1.10.2" 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") golang_x84_64_sha256=$(curl -s -L "https://storage.googleapis.com/golang/go${golang_version}.linux-amd64.tar.gz.sha256")
cat > versions.txt << EOT cat >versions.txt <<EOT
# This is a generated file from ${script_name} # This is a generated file from ${script_name}
@@ -84,10 +83,10 @@ go_checksum=${golang_x84_64_sha256}
EOT EOT
} }
usage(){ usage() {
msg="${1:-}" msg="${1:-}"
exit_code=$"${2:-0}" exit_code=$"${2:-0}"
cat << EOT cat <<EOT
${msg} ${msg}
Usage: Usage:
${script_name} <kata-branch> ${script_name} <kata-branch>
@@ -95,7 +94,7 @@ EOT
exit "${exit_code}" exit "${exit_code}"
} }
main(){ main() {
local branch="${1:-}" local branch="${1:-}"
[ -n "${branch}" ] || usage "missing branch" "1" [ -n "${branch}" ] || usage "missing branch" "1"
gen_version_file "${branch}" gen_version_file "${branch}"

View File

@@ -5,7 +5,7 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
[ -z "${DEBUG}" ] || set -x [ -z "${DEBUG}" ] || set -x
set -o errexit set -o errexit
set -o nounset set -o nounset
@@ -17,11 +17,9 @@ readonly project="kata-containers"
readonly tmp_dir=$(mktemp -d -t build-image-tmp.XXXXXXXXXX) readonly tmp_dir=$(mktemp -d -t build-image-tmp.XXXXXXXXXX)
readonly osbuilder_url=https://github.com/${project}/osbuilder.git readonly osbuilder_url=https://github.com/${project}/osbuilder.git
export GOPATH=${GOPATH:-${HOME}/go} export GOPATH=${GOPATH:-${HOME}/go}
source "${script_dir}/../../scripts/lib.sh" source "${script_dir}/../../scripts/lib.sh"
arch_target="$(uname -m)" arch_target="$(uname -m)"
kata_version="master" kata_version="master"
@@ -31,31 +29,30 @@ kata_osbuilder_version="${KATA_OSBUILDER_VERSION:-}"
# Agent version # Agent version
agent_version="${AGENT_VERSION:-}" agent_version="${AGENT_VERSION:-}"
readonly destdir="${PWD}" 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:-}" \ 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" \
USE_DOCKER=1 \ USE_DOCKER=1 \
AGENT_INIT="yes" AGENT_INIT="yes"
} }
build_image(){ build_image() {
sudo -E PATH="${PATH}" make image \ sudo -E PATH="${PATH}" make image \
DISTRO="${img_distro}" \ DISTRO="${img_distro}" \
DEBUG="${DEBUG:-}" \ 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"
} }
create_tarball(){ create_tarball() {
agent_sha=$(get_repo_hash "${GOPATH}/src/github.com/kata-containers/agent") agent_sha=$(get_repo_hash "${GOPATH}/src/github.com/kata-containers/agent")
#reduce sha size for short names #reduce sha size for short names
agent_sha=${agent_sha:0:11} agent_sha=${agent_sha:0:11}
@@ -68,9 +65,9 @@ create_tarball(){
sudo tar cfzv "${tarball_name}" "${initrd_name}" "${image_name}" sudo tar cfzv "${tarball_name}" "${initrd_name}" "${image_name}"
} }
usage(){ usage() {
return_code=${1:-0} return_code=${1:-0}
cat << EOT cat <<EOT
Create image and initrd in a tarball for kata containers. Create image and initrd in a tarball for kata containers.
Use it to build an image to distribute kata. Use it to build an image to distribute kata.
@@ -83,16 +80,18 @@ Options:
EOT EOT
exit "${return_code}" exit "${return_code}"
} }
main(){ main() {
while getopts "v:h" opt while getopts "v:h" opt; do
do
case "$opt" in case "$opt" in
h) usage 0 ;; h) usage 0 ;;
v) kata_version="${OPTARG}" ;; v) kata_version="${OPTARG}" ;;
*) echo "Invalid option $opt"; usage 1;; *)
echo "Invalid option $opt"
usage 1
;;
esac esac
done done
# osbuilder info # osbuilder info
@@ -108,7 +107,7 @@ main(){
initrd_distro=$(get_from_kata_deps "assets.image.architecture.${arch_target}.name" "${kata_version}") 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}") 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"
git checkout "${kata_osbuilder_version}" git checkout "${kata_osbuilder_version}"

View File

@@ -38,12 +38,12 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
((RELEASE++)) ((RELEASE++))
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"
} }
replace_list=( replace_list=(
"VERSION=$VERSION" "VERSION=$VERSION"
"RELEASE=$RELEASE" "RELEASE=$RELEASE"
) )
verify verify

View File

@@ -51,10 +51,10 @@ KERNEL_ARCH=$(go get github.com/kata-containers/tests && $GOPATH/src/github.com/
cp "${SCRIPT_DIR}/../../kernel/configs/${KERNEL_ARCH}_kata_kvm_${KR_LTS}.x" config cp "${SCRIPT_DIR}/../../kernel/configs/${KERNEL_ARCH}_kata_kvm_${KR_LTS}.x" config
replace_list=( replace_list=(
"VERSION=${VERSION}" "VERSION=${VERSION}"
"CONFIG_VERSION=${KATA_CONFIG_VERSION}" "CONFIG_VERSION=${KATA_CONFIG_VERSION}"
"RELEASE=$RELEASE" "RELEASE=$RELEASE"
"KERNEL_SHA256=$kernel_sha256" "KERNEL_SHA256=$kernel_sha256"
) )
verify verify

View File

@@ -40,12 +40,12 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
set_versions "$kata_ksm_throttler_hash" set_versions "$kata_ksm_throttler_hash"
replace_list=( replace_list=(
"GO_CHECKSUM=$go_checksum" "GO_CHECKSUM=$go_checksum"
"GO_VERSION=$go_version" "GO_VERSION=$go_version"
"GO_ARCH=$GO_ARCH" "GO_ARCH=$GO_ARCH"
"HASH=${short_hashtag}" "HASH=${short_hashtag}"
"RELEASE=$RELEASE" "RELEASE=$RELEASE"
"VERSION=$VERSION" "VERSION=$VERSION"
) )
verify verify

View File

@@ -36,12 +36,12 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
set_versions $kata_proxy_hash set_versions $kata_proxy_hash
replace_list=( replace_list=(
"GO_CHECKSUM=$go_checksum" "GO_CHECKSUM=$go_checksum"
"GO_VERSION=$go_version" "GO_VERSION=$go_version"
"GO_ARCH=$GO_ARCH" "GO_ARCH=$GO_ARCH"
"HASH=$short_hashtag" "HASH=$short_hashtag"
"RELEASE=$RELEASE" "RELEASE=$RELEASE"
"VERSION=$VERSION" "VERSION=$VERSION"
) )
verify verify

View File

@@ -36,9 +36,9 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
set_versions "${qemu_lite_hash}" set_versions "${qemu_lite_hash}"
replace_list=( replace_list=(
"VERSION=$VERSION" "VERSION=$VERSION"
"RELEASE=$RELEASE" "RELEASE=$RELEASE"
"QEMU_LITE_HASH=${qemu_lite_hash:0:10}" "QEMU_LITE_HASH=${qemu_lite_hash:0:10}"
) )
verify verify
echo "Verify succeed." echo "Verify succeed."

View File

@@ -23,7 +23,7 @@ SCRIPT_DIR=$(dirname $0)
PKG_NAME="qemu-vanilla" PKG_NAME="qemu-vanilla"
VERSION=$qemu_vanilla_version VERSION=$qemu_vanilla_version
GENERATED_FILES=(qemu-vanilla.dsc qemu-vanilla.spec debian.rules _service debian.control ) 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) STATIC_FILES=(debian.compat "${SCRIPT_DIR}/../../scripts/configure-hypervisor.sh" qemu-vanilla-rpmlintrc)
# Parse arguments # Parse arguments
@@ -37,9 +37,9 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
set_versions "${qemu_vanilla_hash}" set_versions "${qemu_vanilla_hash}"
replace_list=( replace_list=(
"VERSION=$VERSION" "VERSION=$VERSION"
"RELEASE=$RELEASE" "RELEASE=$RELEASE"
"QEMU_VANILLA_HASH=${qemu_vanilla_hash:0:10}" "QEMU_VANILLA_HASH=${qemu_vanilla_hash:0:10}"
) )
verify verify

View File

@@ -81,19 +81,19 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
set_versions "$kata_runtime_hash" set_versions "$kata_runtime_hash"
replace_list=( replace_list=(
"GO_CHECKSUM=$go_checksum" "GO_CHECKSUM=$go_checksum"
"GO_VERSION=$go_version" "GO_VERSION=$go_version"
"GO_ARCH=$GO_ARCH" "GO_ARCH=$GO_ARCH"
"HASH=$short_hashtag" "HASH=$short_hashtag"
"RELEASE=$RELEASE" "RELEASE=$RELEASE"
"VERSION=$VERSION" "VERSION=$VERSION"
"kata_osbuilder_version=${KATA_IMAGE_REQUIRED_VERSION}" "kata_osbuilder_version=${KATA_IMAGE_REQUIRED_VERSION}"
"kata_proxy_version=${PROXY_REQUIRED_VERESION}" "kata_proxy_version=${PROXY_REQUIRED_VERESION}"
"kata_shim_version=${SHIM_REQUIRED_VERSION}" "kata_shim_version=${SHIM_REQUIRED_VERSION}"
"ksm_throttler_version=${KSM_THROTTLER_REQUIRED_VERSION}" "ksm_throttler_version=${KSM_THROTTLER_REQUIRED_VERSION}"
"linux_container_version=${KERNEL_REQUIRED_VERSION}" "linux_container_version=${KERNEL_REQUIRED_VERSION}"
"qemu_lite_version=${KATA_QEMU_LITE_REQUIRED_VERSION}" "qemu_lite_version=${KATA_QEMU_LITE_REQUIRED_VERSION}"
"qemu_vanilla_version=${KATA_QEMU_VANILLA_REQUIRED_VERSION}" "qemu_vanilla_version=${KATA_QEMU_VANILLA_REQUIRED_VERSION}"
) )
verify verify
@@ -102,4 +102,3 @@ get_git_info
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

@@ -33,180 +33,197 @@ else
echo "Go not installed using $GO_ARCH to install go in dockerfile" echo "Go not installed using $GO_ARCH to install go in dockerfile"
fi fi
function display_help() function display_help() {
{
cat <<-EOL cat <<-EOL
$SCRIPT_NAME $SCRIPT_NAME
This script is intended to create Kata Containers packages for the OBS This script is intended to create Kata Containers packages for the OBS
(Open Build Service) platform. (Open Build Service) platform.
Usage: Usage:
$SCRIPT_NAME [options] $SCRIPT_NAME [options]
Options: Options:
-l --local-build Build the runtime locally -l --local-build Build the runtime locally
-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)
-r --obs-repository An OBS repository to push the changes. -r --obs-repository An OBS repository to push the changes.
-w --workdir Directory of a working copy of the OBS runtime repo -w --workdir Directory of a working copy of the OBS runtime repo
-v --verbose Set the -x flag for verbosity -v --verbose Set the -x flag for verbosity
-C --clean Clean the repository -C --clean Clean the repository
-V --verify Verify the environment -V --verify Verify the environment
-h --help Display this help message -h --help Display this help message
Usage examples: Usage examples:
$SCRIPT_NAME --local-build --branch staging $SCRIPT_NAME --local-build --branch staging
$SCRIPT_NAME --push --api-url http://127.0.0.1 $SCRIPT_NAME --push --api-url http://127.0.0.1
$SCRIPT_NAME --push --obs-repository home:userx/repository $SCRIPT_NAME --push --obs-repository home:userx/repository
$SCRIPT_NAME --push $SCRIPT_NAME --push
EOL EOL
exit 1 exit 1
} }
die() die() {
{
msg="$*" msg="$*"
echo >&2 "ERROR: $msg" echo >&2 "ERROR: $msg"
exit 1 exit 1
} }
info() info() {
{
msg="$*" msg="$*"
echo "INFO: $msg" echo "INFO: $msg"
} }
function verify() function verify() {
{ # This function perform some checks in order to make sure
# This function perform some checks in order to make sure # the script will run flawlessly.
# the script will run flawlessly.
# Make sure this script is called from ./ # Make sure this script is called from ./
[ "$SCRIPT_DIR" != "." ] && die "The script must be called from its base dir." [ "$SCRIPT_DIR" != "." ] && die "The script must be called from its base dir."
# Verify if osc is installed, exit otherwise. # Verify if osc is installed, exit otherwise.
[ ! -x "$(command -v osc)" ] && die "osc is not installed." [ ! -x "$(command -v osc)" ] && die "osc is not installed."
info "OK" info "OK"
} }
function clean() function clean() {
{ # This function clean generated files
# This function clean generated files for file in "$@"; do
for file in "$@" [ -e $file ] && rm -v $file
do done
[ -e $file ] && rm -v $file [ -e ./debian.changelog ] && git checkout ./debian.changelog
done [ -e ./release ] && git checkout ./release
[ -e ./debian.changelog ] && git checkout ./debian.changelog echo "Clean done."
[ -e ./release ] && git checkout ./release
echo "Clean done."
} }
function get_git_info() function get_git_info() {
{ AUTHOR=${AUTHOR:-$(git config user.name)}
AUTHOR=${AUTHOR:-$(git config user.name)} AUTHOR_EMAIL=${AUTHOR_EMAIL:-$(git config user.email)}
AUTHOR_EMAIL=${AUTHOR_EMAIL:-$(git config user.email)}
} }
function set_versions() function set_versions() {
{ local commit_hash="$1"
local commit_hash="$1" hash_tag="$commit_hash"
hash_tag="$commit_hash" short_hashtag="${hash_tag:0:7}"
short_hashtag="${hash_tag:0:7}"
} }
function changelog_update { function changelog_update() {
d=$(date -R) d=$(date -R)
cat <<< "$PKG_NAME ($VERSION) stable; urgency=medium cat <<<"$PKG_NAME ($VERSION) stable; urgency=medium
* Update $PKG_NAME $VERSION ${hash_tag:0:7} * Update $PKG_NAME $VERSION ${hash_tag:0:7}
-- $AUTHOR <$AUTHOR_EMAIL> $d -- $AUTHOR <$AUTHOR_EMAIL> $d
" > debian.changelog " >debian.changelog
# Append, so it can be copied to the OBS repository # Append, so it can be copied to the OBS repository
GENERATED_FILES+=('debian.changelog') GENERATED_FILES+=('debian.changelog')
} }
function local_build() function local_build() {
{ [ ! -e $PACKAGING_DIR ] && mkdir $PACKAGING_DIR
[ ! -e $PACKAGING_DIR ] && mkdir $PACKAGING_DIR [ ! -e $LOG_DIR ] && mkdir $LOG_DIR
[ ! -e $LOG_DIR ] && mkdir $LOG_DIR
pushd $OBS_WORKDIR pushd $OBS_WORKDIR
BUILD_ARGS=('--local-package' '--no-verify' '--noservice' '--trust-all-projects' '--keep-pkgs=/var/packaging/results') BUILD_ARGS=('--local-package' '--no-verify' '--noservice' '--trust-all-projects' '--keep-pkgs=/var/packaging/results')
[ "$OFFLINE" == "true" ] && BUILD_ARGS+=('--offline') [ "$OFFLINE" == "true" ] && BUILD_ARGS+=('--offline')
osc service run osc service run
for distro in ${BUILD_DISTROS[@]} for distro in ${BUILD_DISTROS[@]}; do
do # If more distros are supported, add here the relevant validations.
# If more distros are supported, add here the relevant validations. if [[ $distro =~ ^Fedora.* ]] || [[ $distro =~ ^CentOS.* ]]; then
if [[ "$distro" =~ ^Fedora.* ]] || [[ "$distro" =~ ^CentOS.* ]] echo "Perform a local build for ${distro}"
then osc build ${BUILD_ARGS[@]} \
echo "Perform a local build for ${distro}" ${distro} $BUILD_ARCH *.spec | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log
osc build ${BUILD_ARGS[@]} \
${distro} $BUILD_ARCH *.spec | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log
elif [[ "$distro" =~ ^xUbuntu.* ]] elif [[ $distro =~ ^xUbuntu.* ]]; then
then echo "Perform a local build for ${distro}"
echo "Perform a local build for ${distro}" osc build ${BUILD_ARGS[@]} \
osc build ${BUILD_ARGS[@]} \ ${distro} $BUILD_ARCH *.dsc | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log
${distro} $BUILD_ARCH *.dsc | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log fi
fi done
done
} }
function checkout_repo() function checkout_repo() {
{ local REPO="${1}"
local REPO="${1}" if [ -z "${OBS_WORKDIR:-}" ]; then
if [ -z "${OBS_WORKDIR:-}" ] OBS_WORKDIR=$(mktemp -d -u -t obs-repo.XXXXXXXXXXX) || exit 1
then osc co "${REPO}" -o "${OBS_WORKDIR}"
OBS_WORKDIR=$(mktemp -d -u -t obs-repo.XXXXXXXXXXX) || exit 1 fi
osc co "${REPO}" -o "${OBS_WORKDIR}" find "${OBS_WORKDIR}" -maxdepth 1 -mindepth 1 ! -name '.osc' -prune -exec echo remove {} \; -exec rm -rf {} \;
fi
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 addremove
osc addremove osc commit -m "Update ${PKG_NAME} $VERSION: ${hash_tag:0:7}"
osc commit -m "Update ${PKG_NAME} $VERSION: ${hash_tag:0:7}" popd
popd
} }
function cli() 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
-b | --branch ) BRANCH="true"; OBS_REVISION="$2"; shift 2;; -b | --branch)
-l | --local-build ) LOCAL_BUILD="true"; shift;; BRANCH="true"
-p | --push ) OBS_PUSH="true"; shift;; OBS_REVISION="$2"
-r | --obs-repository ) PROJECT_REPO="$2"; shift 2;; shift 2
-w | --workdir ) OBS_WORKDIR="$2"; shift 2;; ;;
-v | --verbose ) VERBOSE="true"; shift;; -l | --local-build)
-o | --offline ) OFFLINE="true"; shift;; LOCAL_BUILD="true"
-C | --clean ) clean ${GENERATED_FILES[@]}; exit $?;; shift
-V | --verify ) verify; exit $?;; ;;
-h | --help ) display_help; exit $?;; -p | --push)
-- ) shift; break ;; OBS_PUSH="true"
* ) break ;; shift
;;
-r | --obs-repository)
PROJECT_REPO="$2"
shift 2
;;
-w | --workdir)
OBS_WORKDIR="$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 esac
done done
} }
function build_pkg() function build_pkg() {
{
obs_repository="${1}" obs_repository="${1}"
@@ -226,7 +243,7 @@ function build_pkg()
} }
function generate_files () { function generate_files() {
directory=$1 directory=$1
replace_list=$2 replace_list=$2
@@ -242,8 +259,8 @@ function generate_files () {
# check replace list # check replace list
# key=val # key=val
for replace in "${replace_list[@]}" ; do for replace in "${replace_list[@]}"; do
[[ "$replace" = *"="* ]] || die "invalid replace $replace" [[ $replace == *"="* ]] || die "invalid replace $replace"
local key="${replace%%=*}" local key="${replace%%=*}"
local value="${replace##*=}" local value="${replace##*=}"
[ -n "$key" ] || die "${replace} key is empty" [ -n "$key" ] || die "${replace} key is empty"
@@ -255,13 +272,13 @@ function generate_files () {
genfile="${f%-template}" genfile="${f%-template}"
cp "$f" "${genfile}" cp "$f" "${genfile}"
info "Generate file ${genfile}" info "Generate file ${genfile}"
for replace in "${replace_list[@]}" ; do for replace in "${replace_list[@]}"; do
[[ "$replace" = *"="* ]] || die "invalid replace $replace" [[ $replace == *"="* ]] || die "invalid replace $replace"
local key="${replace%%=*}" local key="${replace%%=*}"
local value="${replace##*=}" local value="${replace##*=}"
export k="@${key}@" export k="@${key}@"
export v="$value" export v="$value"
perl -p -e 's/$ENV{k}/$ENV{v}/g' "${genfile}" > "${genfile}.out" perl -p -e 's/$ENV{k}/$ENV{v}/g' "${genfile}" >"${genfile}.out"
mv "${genfile}.out" ${genfile} mv "${genfile}.out" ${genfile}
done done
done done
@@ -299,11 +316,11 @@ function get_obs_pkg_release() {
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. # 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" # 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') release_file=$(find "${repo_dir}" -maxdepth 1 -type f -name 'pkg-release')
@@ -335,11 +352,11 @@ function find_patches() {
patches=$(find patches/ -type f -name '*.patch' -exec basename {} \;) patches=$(find patches/ -type f -name '*.patch' -exec basename {} \;)
n="1" n="1"
rm -f debian.series rm -f debian.series
for p in ${patches} ; do for p in ${patches}; do
STATIC_FILES+=("patches/$p") STATIC_FILES+=("patches/$p")
RPM_PATCH_LIST+="Patch00${n}: $p"$'\n' RPM_PATCH_LIST+="Patch00${n}: $p"$'\n'
RPM_APPLY_PATCHES+="%patch00${n} -p1"$'\n' RPM_APPLY_PATCHES+="%patch00${n} -p1"$'\n'
echo "$p" >> debian.series echo "$p" >>debian.series
((n++)) ((n++))
done done
GENERATED_FILES+=(debian.series) GENERATED_FILES+=(debian.series)

View File

@@ -36,12 +36,12 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
set_versions $kata_shim_hash set_versions $kata_shim_hash
replace_list=( replace_list=(
"GO_CHECKSUM=$go_checksum" "GO_CHECKSUM=$go_checksum"
"GO_VERSION=$go_version" "GO_VERSION=$go_version"
"GO_ARCH=$GO_ARCH" "GO_ARCH=$GO_ARCH"
"HASH=$short_hashtag" "HASH=$short_hashtag"
"RELEASE=$RELEASE" "RELEASE=$RELEASE"
"VERSION=$VERSION" "VERSION=$VERSION"
) )
verify verify

View File

@@ -91,7 +91,7 @@ install_image() {
install_kernel() { install_kernel() {
go get "github.com/${project}/packaging" || true go get "github.com/${project}/packaging" || true
pushd ${GOPATH}/src/github.com/${project}/packaging >>/dev/null pushd ${GOPATH}/src/github.com/${project}/packaging >>/dev/null
git checkout "${kata_version}-kernel-config" git checkout "${kata_version}-kernel-config"
popd >>/dev/null popd >>/dev/null
pushd "${script_dir}/../kernel" >>/dev/null pushd "${script_dir}/../kernel" >>/dev/null

View File

@@ -88,7 +88,7 @@ tag_repos() {
info "Creating tag ${kata_version} in all repos" info "Creating tag ${kata_version} in all repos"
for repo in "${repos[@]}"; do for repo in "${repos[@]}"; do
git clone --quiet "https://github.com/${OWNER}/${repo}.git" git clone --quiet "https://github.com/${OWNER}/${repo}.git"
pushd "${repo}" >> /dev/null pushd "${repo}" >>/dev/null
git remote set-url --push origin "git@github.com:${OWNER}/${repo}.git" git remote set-url --push origin "git@github.com:${OWNER}/${repo}.git"
git fetch origin --tags git fetch origin --tags
tag="$kata_version" tag="$kata_version"
@@ -99,7 +99,7 @@ tag_repos() {
info "Creating tag ${tag} for ${repo}" info "Creating tag ${tag} for ${repo}"
git tag -a "${tag}" -s -m "${PROJECT} release ${tag}" git tag -a "${tag}" -s -m "${PROJECT} release ${tag}"
fi fi
popd >> /dev/null popd >>/dev/null
done done
} }
@@ -107,21 +107,21 @@ push_tags() {
info "Pushing tags to repos" info "Pushing tags to repos"
build_hub build_hub
for repo in "${repos[@]}"; do for repo in "${repos[@]}"; do
pushd "${repo}" >> /dev/null pushd "${repo}" >>/dev/null
tag="$kata_version" tag="$kata_version"
[[ "packaging" == "${repo}" ]] && tag="${tag}-kernel-config" [[ "packaging" == "${repo}" ]] && tag="${tag}-kernel-config"
info "Push tag ${tag} for ${repo}" info "Push tag ${tag} for ${repo}"
git push origin "${tag}" git push origin "${tag}"
create_github_release "${PWD}" "${tag}" create_github_release "${PWD}" "${tag}"
popd >> /dev/null popd >>/dev/null
done done
} }
create_github_release(){ create_github_release() {
repo_dir=${1:-} repo_dir=${1:-}
tag=${2:-} tag=${2:-}
[ -d "${repo_dir}" ] || die "No repository directory" [ -d "${repo_dir}" ] || die "No repository directory"
[ -n "${tag}" ] || die "No repository directory" [ -n "${tag}" ] || die "No repository directory"
if ! "${hub_bin}" release | grep "${tag}"; then if ! "${hub_bin}" release | grep "${tag}"; then
info "Creating Github release" info "Creating Github release"
"${hub_bin}" -C "${repo_dir}" release create -m "${PROJECT} ${tag}" "${tag}" "${hub_bin}" -C "${repo_dir}" release create -m "${PROJECT} ${tag}" "${tag}"
@@ -136,13 +136,13 @@ while getopts "hp" opt; do
p) PUSH="true" ;; p) PUSH="true" ;;
esac esac
done done
shift $(($OPTIND - 1)) shift $((OPTIND - 1))
subcmd=${1:-""} subcmd=${1:-""}
[ -z "${subcmd}" ] && usage && exit 0 [ -z "${subcmd}" ] && usage && exit 0
pushd "${tmp_dir}" >> /dev/null pushd "${tmp_dir}" >>/dev/null
case "${subcmd}" in case "${subcmd}" in
status) status)
@@ -167,4 +167,4 @@ tag)
esac esac
popd >> /dev/null popd >>/dev/null

View File

@@ -10,10 +10,10 @@ set -o nounset
set -o pipefail set -o pipefail
echo "Check tag_repos.sh show help" echo "Check tag_repos.sh show help"
./release/tag_repos.sh | grep Usage ./release/tag_repos.sh | grep Usage
echo "Check tag_repos.sh -h option" echo "Check tag_repos.sh -h option"
./release/tag_repos.sh -h | grep Usage ./release/tag_repos.sh -h | grep Usage
echo "Check tag_repos.sh status" echo "Check tag_repos.sh status"
./release/tag_repos.sh status | grep runtime ./release/tag_repos.sh status | grep runtime

View File

@@ -9,7 +9,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
readonly script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
readonly script_name="$(basename "${BASH_SOURCE[0]}")" readonly script_name="$(basename "${BASH_SOURCE[0]}")"
readonly tmp_dir=$(mktemp -t -d pr-bump.XXXX) readonly tmp_dir=$(mktemp -t -d pr-bump.XXXX)
@@ -19,7 +19,7 @@ GOPATH=${GOPATH:-${HOME}/go}
source "${script_dir}/../scripts/lib.sh" source "${script_dir}/../scripts/lib.sh"
cleanup (){ cleanup() {
[ -d "${tmp_dir}" ] && rm -rf "${tmp_dir}" [ -d "${tmp_dir}" ] && rm -rf "${tmp_dir}"
} }
@@ -36,8 +36,7 @@ get_changes() {
fi fi
# list all PRs merged from $current_version to HEAD # list all PRs merged from $current_version to HEAD
git log --merges "${current_version}..HEAD" | awk '/Merge pull/{getline; getline;print }' | while read pr git log --merges "${current_version}..HEAD" | awk '/Merge pull/{getline; getline;print }' | while read pr; do
do
echo "- ${pr}" echo "- ${pr}"
done done
@@ -71,7 +70,7 @@ bump_repo() {
git clone --quiet "${remote_github}" git clone --quiet "${remote_github}"
pushd "${repo}" >> /dev/null pushd "${repo}" >>/dev/null
# All repos we build should have a VERSION file # All repos we build should have a VERSION file
[ -f "VERSION" ] || die "VERSION file not found " [ -f "VERSION" ] || die "VERSION file not found "
@@ -79,7 +78,7 @@ bump_repo() {
info "Creating PR message" info "Creating PR message"
notes_file=notes.md notes_file=notes.md
cat << EOT > "${notes_file}" cat <<EOT >"${notes_file}"
# Kata Containers ${new_version} # Kata Containers ${new_version}
$(get_changes "$current_version") $(get_changes "$current_version")
@@ -87,15 +86,15 @@ $(get_changes "$current_version")
EOT EOT
info "Updating VERSION file" info "Updating VERSION file"
echo "${new_version}" > VERSION echo "${new_version}" >VERSION
branch="${new_version}-branch-bump" branch="${new_version}-branch-bump"
git checkout -b "${branch}" master git checkout -b "${branch}" master
git add -u git add -u
info "Creating commit with new changes" info "Creating commit with new changes"
commit_msg="$(generate_commit $new_version $current_version)" commit_msg="$(generate_commit $new_version $current_version)"
git commit -s -m "${commit_msg}" git commit -s -m "${commit_msg}"
if [[ "${PUSH}" == "true" ]]; then if [[ ${PUSH} == "true" ]]; then
build_hub build_hub
info "Forking remote" info "Forking remote"
${hub_bin} fork --remote-name=fork ${hub_bin} fork --remote-name=fork
@@ -103,12 +102,12 @@ EOT
${hub_bin} push fork -f "${branch}" ${hub_bin} push fork -f "${branch}"
info "Create PR" info "Create PR"
out="" out=""
out=$("${hub_bin}" pull-request -F "${notes_file}" 2>&1) || echo "$out" | grep "A pull request already exists" out=$("${hub_bin}" pull-request -F "${notes_file}" 2>&1) || echo "$out" | grep "A pull request already exists"
fi fi
popd >> /dev/null popd >>/dev/null
} }
usage(){ usage() {
exit_code="$1" exit_code="$1"
cat <<EOT cat <<EOT
Usage: Usage:
@@ -125,21 +124,20 @@ EOT
exit "$exit_code" exit "$exit_code"
} }
while getopts "hp" opt while getopts "hp" opt; do
do
case $opt in case $opt in
h) usage 0 ;; h) usage 0 ;;
p) PUSH="true" ;; p) PUSH="true" ;;
esac esac
done done
shift $(( $OPTIND - 1 )) shift $((OPTIND - 1))
repo=${1:-} repo=${1:-}
new_version=${2:-} new_version=${2:-}
[ -n "${repo}" ] || (echo "ERROR: repository not provided" && usage 1) [ -n "${repo}" ] || (echo "ERROR: repository not provided" && usage 1)
[ -n "$new_version" ] || (echo "ERROR: no new version" && usage 1 ) [ -n "$new_version" ] || (echo "ERROR: no new version" && usage 1)
pushd "$tmp_dir" >> /dev/null pushd "$tmp_dir" >>/dev/null
bump_repo "${repo}" "${new_version}" bump_repo "${repo}" "${new_version}"
popd >> /dev/null popd >>/dev/null

View File

@@ -9,37 +9,37 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
readonly script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
out="" out=""
handle_error(){ handle_error() {
echo "not ok" echo "not ok"
echo "output: ${out}" echo "output: ${out}"
} }
OK(){ OK() {
echo "ok" echo "ok"
} }
output_should_contain(){ output_should_contain() {
local output="$1" local output="$1"
local text_to_find="$2" local text_to_find="$2"
[ -n "$output" ] [ -n "$output" ]
[ -n "$text_to_find" ] [ -n "$text_to_find" ]
echo "${output}" | grep "${text_to_find}" echo "${output}" | grep "${text_to_find}"
} }
trap handle_error ERR trap handle_error ERR
echo "Missing args show help" echo "Missing args show help"
out=$("${script_dir}/update-repository-version.sh" 2>&1) || (($?!=0)) out=$("${script_dir}/update-repository-version.sh" 2>&1) || (($? != 0))
echo "${out}" | grep Usage >> /dev/null echo "${out}" | grep Usage >>/dev/null
output_should_contain "${out}" "Usage" output_should_contain "${out}" "Usage"
OK OK
echo "Missing version show help" echo "Missing version show help"
out=$("${script_dir}/update-repository-version.sh" runtime 2>&1) || (($?!=0)) out=$("${script_dir}/update-repository-version.sh" runtime 2>&1) || (($? != 0))
echo "${out}" | grep Usage >> /dev/null echo "${out}" | grep Usage >>/dev/null
echo "${out}" | grep "no new version">> /dev/null echo "${out}" | grep "no new version" >>/dev/null
OK OK
echo "help option" echo "help option"

View File

@@ -48,17 +48,15 @@ recognised_tags=(
) )
# Display message to stderr and exit indicating script failed. # Display message to stderr and exit indicating script failed.
die() die() {
{
local msg="$*" local msg="$*"
echo >&2 "$script_name: ERROR: $msg" echo >&2 "$script_name: ERROR: $msg"
exit 1 exit 1
} }
# Display usage to stdout. # Display usage to stdout.
usage() usage() {
{ cat <<EOT
cat <<EOT
Overview: Overview:
Display configure options required to build the specified Display configure options required to build the specified
@@ -83,8 +81,7 @@ Example:
EOT EOT
} }
show_tags_header() show_tags_header() {
{
local keys local keys
local key local key
local value local value
@@ -96,10 +93,9 @@ EOT
# sort the tags # sort the tags
keys=${!recognised_tags[@]} keys=${!recognised_tags[@]}
keys=$(echo "$keys"|tr ' ' '\n'|sort -u) keys=$(echo "$keys" | tr ' ' '\n' | sort -u)
for key in $keys for key in $keys; do
do
value="${recognised_tags[$key]}" value="${recognised_tags[$key]}"
printf "# %s\t%s.\n" "$key" "$value" printf "# %s\t%s.\n" "$key" "$value"
done done
@@ -107,8 +103,7 @@ EOT
printf "#\n\n" printf "#\n\n"
} }
check_tag() check_tag() {
{
local tag="$1" local tag="$1"
local entry="$2" local entry="$2"
@@ -123,18 +118,16 @@ check_tag()
die "invalid tag '$tag' found for entry '$entry'" die "invalid tag '$tag' found for entry '$entry'"
} }
check_tags() check_tags() {
{
local tags="$1" local tags="$1"
local entry="$2" local entry="$2"
[ -z "$tags" ] && die "entry '$entry' doesn't have any tags" [ -z "$tags" ] && die "entry '$entry' doesn't have any tags"
[ -z "$entry" ] && die "no entry for tags '$tags'" [ -z "$entry" ] && die "no entry for tags '$tags'"
tags=$(echo "$tags"|tr ',' '\n') tags=$(echo "$tags" | tr ',' '\n')
for tag in $tags for tag in $tags; do
do
check_tag "$tag" "$entry" check_tag "$tag" "$entry"
done done
} }
@@ -151,8 +144,7 @@ check_tags()
# $2: (optional) "multi" - show values across multiple lines, # $2: (optional) "multi" - show values across multiple lines,
# "dump" - show full hash values. Any other value results in the # "dump" - show full hash values. Any other value results in the
# options being displayed on a single line. # options being displayed on a single line.
show_array() show_array() {
{
local action="$1" local action="$1"
local _array=("$@") local _array=("$@")
_array=("${_array[@]:1}") _array=("${_array[@]:1}")
@@ -167,27 +159,23 @@ show_array()
[ "$action" = "dump" ] && show_tags_header [ "$action" = "dump" ] && show_tags_header
for entry in "${_array[@]}" for entry in "${_array[@]}"; do
do
[ -z "$entry" ] && die "found empty entry" [ -z "$entry" ] && die "found empty entry"
tags=$(echo "$entry"|cut -s -d: -f1) tags=$(echo "$entry" | cut -s -d: -f1)
elem=$(echo "$entry"|cut -s -d: -f2-) elem=$(echo "$entry" | cut -s -d: -f2-)
[ -z "$elem" ] && die "no option for entry '$entry'" [ -z "$elem" ] && die "no option for entry '$entry'"
check_tags "$tags" "$entry" check_tags "$tags" "$entry"
if [ "$action" = "dump" ] if [ "$action" = "dump" ]; then
then
printf "%s\t\t%s\n" "$tags" "$elem" printf "%s\t\t%s\n" "$tags" "$elem"
elif [ "$action" = "multi" ] elif [ "$action" = "multi" ]; then
then if [ $i -eq $size ]; then
if [ $i -eq $size ]
then
suffix="" suffix=""
else else
suffix=" \\" suffix=' \'
fi fi
printf '%s%s\n' "$elem" "$suffix" printf '%s%s\n' "$elem" "$suffix"
@@ -202,8 +190,7 @@ show_array()
[ "$one_line" = yes ] && echo [ "$one_line" = yes ] && echo
} }
generate_qemu_options() generate_qemu_options() {
{
#--------------------------------------------------------------------- #---------------------------------------------------------------------
# Disabled options # Disabled options
@@ -255,10 +242,10 @@ generate_qemu_options()
# Disable TCG support # Disable TCG support
case "$arch" in case "$arch" in
aarch64) ;; aarch64) ;;
x86_64) qemu_options+=(size:--disable-tcg);; x86_64) qemu_options+=(size:--disable-tcg) ;;
ppc64le) ;; ppc64le) ;;
esac esac
# SECURITY: Don't build a static binary (lowers security) # SECURITY: Don't build a static binary (lowers security)
# needed if qemu version is less than 2.7 # needed if qemu version is less than 2.7
@@ -272,18 +259,19 @@ generate_qemu_options()
# Disable debug and "-uuid ..." is always passed to the qemu binary so not required. # Disable debug and "-uuid ..." is always passed to the qemu binary so not required.
case "$arch" in case "$arch" in
aarch64) qemu_options+=(size:--disable-uuid) aarch64)
;; qemu_options+=(size:--disable-uuid)
x86_64) ;;
qemu_options+=(size:--disable-uuid) x86_64)
qemu_options+=(size:--disable-debug-tcg) qemu_options+=(size:--disable-uuid)
qemu_options+=(size:--disable-tcg-interpreter) qemu_options+=(size:--disable-debug-tcg)
;; qemu_options+=(size:--disable-tcg-interpreter)
ppc64le) ;;
qemu_options+=(size:--disable-debug-tcg) ppc64le)
qemu_options+=(size:--disable-tcg-interpreter) qemu_options+=(size:--disable-debug-tcg)
;; qemu_options+=(size:--disable-tcg-interpreter)
esac ;;
esac
qemu_options+=(size:--disable-qom-cast-debug) qemu_options+=(size:--disable-qom-cast-debug)
qemu_options+=(size:--disable-tcmalloc) qemu_options+=(size:--disable-tcmalloc)
@@ -299,10 +287,10 @@ generate_qemu_options()
# Disable XEN driver # Disable XEN driver
case "$arch" in case "$arch" in
aarch64) ;; aarch64) ;;
x86_64) qemu_options+=(size:--disable-xen);; x86_64) qemu_options+=(size:--disable-xen) ;;
ppc64le) qemu_options+=(size:--disable-xen);; ppc64le) qemu_options+=(size:--disable-xen) ;;
esac esac
# FIXME: why is this disabled? # FIXME: why is this disabled?
# (for reference, it's explicitly enabled in Ubuntu 17.10 and # (for reference, it's explicitly enabled in Ubuntu 17.10 and
@@ -369,9 +357,9 @@ generate_qemu_options()
# and take advantage of ASLR, making ROP attacks much harder to perform. # and take advantage of ASLR, making ROP attacks much harder to perform.
# (https://wiki.debian.org/Hardening) # (https://wiki.debian.org/Hardening)
case "$arch" in case "$arch" in
aarch64) _qemu_cflags+=" -fPIC";; aarch64) _qemu_cflags+=" -fPIC" ;;
x86_64) _qemu_cflags+=" -fPIE";; x86_64) _qemu_cflags+=" -fPIE" ;;
ppc64le) _qemu_cflags+=" -fPIE";; ppc64le) _qemu_cflags+=" -fPIE" ;;
esac esac
# Set compile options # Set compile options
@@ -385,9 +373,9 @@ generate_qemu_options()
# and take advantage of ASLR, making ROP attacks much harder to perform. # and take advantage of ASLR, making ROP attacks much harder to perform.
# (https://wiki.debian.org/Hardening) # (https://wiki.debian.org/Hardening)
case "$arch" in case "$arch" in
aarch64) ;; aarch64) ;;
x86_64) [ -z "${static}" ] && _qemu_ldflags+=" -pie";; x86_64) [ -z "${static}" ] && _qemu_ldflags+=" -pie" ;;
ppc64le) [ -z "${static}" ] && _qemu_ldflags+=" -pie";; ppc64le) [ -z "${static}" ] && _qemu_ldflags+=" -pie" ;;
esac esac
# SECURITY: Disallow executing code on the stack. # SECURITY: Disallow executing code on the stack.
@@ -420,32 +408,30 @@ generate_qemu_options()
} }
# Entry point # Entry point
main() main() {
{
action="" action=""
while getopts "dhms" opt while getopts "dhms" opt; do
do
case "$opt" in case "$opt" in
d) d)
action="dump" action="dump"
;; ;;
h) h)
usage usage
exit 0 exit 0
;; ;;
m) m)
action="multi" action="multi"
;; ;;
s) s)
static="true" static="true"
;; ;;
esac esac
done done
shift $[$OPTIND-1] shift $((OPTIND - 1))
[ -z "$1" ] && die "need hypervisor name" [ -z "$1" ] && die "need hypervisor name"
hypervisor="$1" hypervisor="$1"
@@ -456,23 +442,23 @@ main()
local qemu_version_major=$(cut -d. -f1 "${qemu_version_file}") local qemu_version_major=$(cut -d. -f1 "${qemu_version_file}")
local qemu_version_minor=$(cut -d. -f2 "${qemu_version_file}") local qemu_version_minor=$(cut -d. -f2 "${qemu_version_file}")
[ -n "${qemu_version_major}" ] \ [ -n "${qemu_version_major}" ] ||
|| die "cannot determine qemu major version from file $qemu_version_file" die "cannot determine qemu major version from file $qemu_version_file"
[ -n "${qemu_version_minor}" ] \ [ -n "${qemu_version_minor}" ] ||
|| die "cannot determine qemu minor version from file $qemu_version_file" die "cannot determine qemu minor version from file $qemu_version_file"
local gcc_version_major=$(gcc -dumpversion | cut -f1 -d.) local gcc_version_major=$(gcc -dumpversion | cut -f1 -d.)
local gcc_version_minor=$(gcc -dumpversion | cut -f2 -d.) local gcc_version_minor=$(gcc -dumpversion | cut -f2 -d.)
[ -n "${gcc_version_major}" ] \ [ -n "${gcc_version_major}" ] ||
|| die "cannot determine gcc major version, please ensure it is installed" die "cannot determine gcc major version, please ensure it is installed"
[ -n "${gcc_version_minor}" ] \ [ -n "${gcc_version_minor}" ] ||
|| die "cannot determine gcc minor version, please ensure it is installed" die "cannot determine gcc minor version, please ensure it is installed"
# Generate qemu options # Generate qemu options
generate_qemu_options generate_qemu_options
show_array "$action" "${qemu_options[@]}" show_array "$action" "${qemu_options[@]}"
exit 0 exit 0
} }

View File

@@ -2,7 +2,7 @@ export GOPATH=${GOPATH:-${HOME}/go}
readonly kata_arch_sh="${GOPATH}/src/github.com/kata-containers/tests/.ci/kata-arch.sh" readonly kata_arch_sh="${GOPATH}/src/github.com/kata-containers/tests/.ci/kata-arch.sh"
hub_bin="hub-bin" hub_bin="hub-bin"
get_kata_arch(){ get_kata_arch() {
go get -u github.com/kata-containers/tests || true go get -u github.com/kata-containers/tests || true
[ -f "${kata_arch_sh}" ] || die "Not found $kata_arch_sh" [ -f "${kata_arch_sh}" ] || die "Not found $kata_arch_sh"
} }
@@ -11,7 +11,7 @@ install_yq() {
GOPATH=${GOPATH:-${HOME}/go} GOPATH=${GOPATH:-${HOME}/go}
local yq_path="${GOPATH}/bin/yq" local yq_path="${GOPATH}/bin/yq"
local yq_pkg="github.com/mikefarah/yq" local yq_pkg="github.com/mikefarah/yq"
[ -x "${GOPATH}/bin/yq" ] && return [ -x "${GOPATH}/bin/yq" ] && return
get_kata_arch get_kata_arch
goarch=$("${kata_arch_sh}" -g) goarch=$("${kata_arch_sh}" -g)
@@ -30,7 +30,7 @@ install_yq() {
chmod +x "${yq_path}" chmod +x "${yq_path}"
} }
get_from_kata_deps(){ get_from_kata_deps() {
local dependency="$1" local dependency="$1"
local branch="${2:-master}" local branch="${2:-master}"
local runtime_repo="github.com/kata-containers/runtime" local runtime_repo="github.com/kata-containers/runtime"
@@ -47,20 +47,20 @@ get_from_kata_deps(){
} }
die() { die() {
echo >&2 "ERROR: $*" echo >&2 "ERROR: $*"
exit 1 exit 1
} }
info() { info() {
echo >&2 "INFO: $*" echo >&2 "INFO: $*"
} }
get_repo_hash(){ get_repo_hash() {
local repo_dir=${1:-} local repo_dir=${1:-}
[ -d "${repo_dir}" ] || die "${repo_dir} is not a directory" [ -d "${repo_dir}" ] || die "${repo_dir} is not a directory"
pushd "${repo_dir}" >> /dev/null pushd "${repo_dir}" >>/dev/null
git rev-parse --verify HEAD git rev-parse --verify HEAD
popd >> /dev/null popd >>/dev/null
} }
build_hub() { build_hub() {
@@ -68,18 +68,17 @@ build_hub() {
if cmd=$(command -v hub); then if cmd=$(command -v hub); then
hub_bin="${cmd}" hub_bin="${cmd}"
return return
else else
hub_bin="${tmp_dir:-/tmp}/hub-bin" hub_bin="${tmp_dir:-/tmp}/hub-bin"
fi fi
local hub_repo="github.com/github/hub" local hub_repo="github.com/github/hub"
local hub_repo_dir="${GOPATH}/src/${hub_repo}" local hub_repo_dir="${GOPATH}/src/${hub_repo}"
[ -d "${hub_repo_dir}" ]|| git clone --quiet --depth 1 "https://${hub_repo}.git" "${hub_repo_dir}" [ -d "${hub_repo_dir}" ] || git clone --quiet --depth 1 "https://${hub_repo}.git" "${hub_repo_dir}"
pushd "${hub_repo_dir}" >> /dev/null pushd "${hub_repo_dir}" >>/dev/null
git checkout master git checkout master
git pull git pull
./script/build -o "${hub_bin}" ./script/build -o "${hub_bin}"
popd >> /dev/null popd >>/dev/null
} }

View File

@@ -13,7 +13,7 @@ local arch_bios_url=""
local arch_qemu_cpu="qemu64" local arch_qemu_cpu="qemu64"
local arch_qemu_machine="pc" local arch_qemu_machine="pc"
local arch_qemu_extra_opts="" local arch_qemu_extra_opts=""
if [ "$(arch)" == "x86_64" ];then if [ "$(arch)" == "x86_64" ]; then
arch_qemu_cpu="host" arch_qemu_cpu="host"
arch_qemu_machine="pc,accel=kvm" arch_qemu_machine="pc,accel=kvm"
arch_qemu_extra_opts="-enable-kvm" arch_qemu_extra_opts="-enable-kvm"

View File

@@ -5,12 +5,12 @@
# SPDX-License-Identifier: Apache-2.0 # SPDX-License-Identifier: Apache-2.0
# #
error(){ error() {
msg="$*" msg="$*"
echo "ERROR: $msg" >&2 echo "ERROR: $msg" >&2
} }
die(){ die() {
error "$*" error "$*"
exit 1 exit 1
} }
@@ -46,7 +46,10 @@ setup_image() {
img_url=$1 img_url=$1
img=$2 img=$2
[ -f "${img}" ] && return [ -f "${img}" ] && return
{ download "${img_url}" "$(dirname ${img})"; ret=$?; } || true {
download "${img_url}" "$(dirname ${img})"
ret=$?
} || true
[ ${ret} != 0 ] && rm -f "${img}" && return [ ${ret} != 0 ] && rm -f "${img}" && return
qemu-img resize "${img}" +5G qemu-img resize "${img}" +5G
} }
@@ -63,7 +66,7 @@ ping_vm() {
timeout=$4 timeout=$4
minute=60 minute=60
sleeptime=10 sleeptime=10
timeoutsec=$((timeout*minute)) timeoutsec=$((timeout * minute))
tries=$((timeoutsec/sleeptime)) tries=$((timeoutsec/sleeptime))
for i in $(seq 1 ${tries}); do for i in $(seq 1 ${tries}); do
@@ -102,9 +105,9 @@ run_qemu() {
fi fi
qemu-system-${arch} -cpu "${cpu}" -machine "${machine}" -smp cpus=4 -m 2048M \ qemu-system-${arch} -cpu "${cpu}" -machine "${machine}" -smp cpus=4 -m 2048M \
-net nic,model=virtio -device virtio-rng-pci -net user,hostfwd=tcp:${ip}:${port}-:22,dnssearch="$(get_dnssearch)" \ -net nic,model=virtio -device virtio-rng-pci -net user,hostfwd=tcp:${ip}:${port}-:22,dnssearch="$(get_dnssearch)" \
${img_opts} ${seed_opts} \ ${img_opts} ${seed_opts} \
-display none -vga none -daemonize ${extra_opts} -display none -vga none -daemonize ${extra_opts}
[ $? != 0 ] && return 1 [ $? != 0 ] && return 1
# depending of the host's hw, it takes for around ~15 minutes # depending of the host's hw, it takes for around ~15 minutes

View File

@@ -12,28 +12,28 @@ set -x -e
sudo apt-get update -y sudo apt-get update -y
sudo apt-get install -y \ sudo apt-get install -y \
build-essential \ build-essential \
cpio \ cpio \
docker.io \ docker.io \
golang-go \ golang-go \
libattr1-dev \ libattr1-dev \
libcap-dev \ libcap-dev \
libcap-ng-dev \ libcap-ng-dev \
libdw-dev \ libdw-dev \
libelf-dev \ libelf-dev \
libfdt-dev \ libfdt-dev \
libglib2.0-dev \ libglib2.0-dev \
libiberty-dev \ libiberty-dev \
libnewt-dev \ libnewt-dev \
libpci-dev \ libpci-dev \
libpixman-1-dev \ libpixman-1-dev \
librbd-dev \ librbd-dev \
libssl-dev \ libssl-dev \
libz-dev \ libz-dev \
openssl \ openssl \
python \ python \
snapcraft \ snapcraft \
snapd snapd
# start docker # start docker
sudo systemctl start docker sudo systemctl start docker

View File

@@ -23,7 +23,7 @@ scp="scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o Identiti
gen_seed() { gen_seed() {
rm -f "${seed_img}" rm -f "${seed_img}"
truncate --size 2M "${seed_img}" truncate --size 2M "${seed_img}"
mkfs.vfat -n cidata "${seed_img}" &> /dev/null mkfs.vfat -n cidata "${seed_img}" &>/dev/null
if [ -n "${http_proxy}" ]; then if [ -n "${http_proxy}" ]; then
apt_proxy="apt:\n https_proxy: ${https_proxy}\n proxy: ${http_proxy}" apt_proxy="apt:\n https_proxy: ${https_proxy}\n proxy: ${http_proxy}"
@@ -38,7 +38,7 @@ gen_seed() {
docker_dns="$(get_dns)" docker_dns="$(get_dns)"
[ ! -f "${id_rsa_file}" ] && ssh-keygen -t rsa -f ${id_rsa_file} -P '' &> /dev/null [ ! -f "${id_rsa_file}" ] && ssh-keygen -t rsa -f ${id_rsa_file} -P '' &>/dev/null
ssh_key="$(cat ${id_rsa_pub_file})" ssh_key="$(cat ${id_rsa_pub_file})"
sed \ sed \
@@ -48,9 +48,9 @@ gen_seed() {
-e "s|@DOCKER_ENV@|""${docker_env}""|g" \ -e "s|@DOCKER_ENV@|""${docker_env}""|g" \
-e "s|@DOCKER_DNS@|""${docker_dns}""|g" \ -e "s|@DOCKER_DNS@|""${docker_dns}""|g" \
-e "s|@ENV@|""${env}""|g" \ -e "s|@ENV@|""${env}""|g" \
${seed_dir}/user-data.in > ${seed_dir}/user-data ${seed_dir}/user-data.in >${seed_dir}/user-data
mcopy -oi "${seed_img}" ${seed_dir}/user-data ${seed_dir}/meta-data :: mcopy -oi "${seed_img}" ${seed_dir}/user-data ${seed_dir}/meta-data ::
} }
poweroff_and_die() { poweroff_and_die() {
@@ -77,13 +77,13 @@ build_arch() {
# run QEMU # run QEMU
run_qemu "${arch_qemu}" \ run_qemu "${arch_qemu}" \
"${arch_qemu_cpu}" \ "${arch_qemu_cpu}" \
"${arch_qemu_machine}" \ "${arch_qemu_machine}" \
"${ip}" \ "${ip}" \
"${port}" \ "${port}" \
"${arch_image}" \ "${arch_image}" \
"${seed_img}" \ "${seed_img}" \
"${arch_qemu_extra_opts}" "${arch_qemu_extra_opts}"
# copy snap script to VM # copy snap script to VM
${scp} -P "${port}" "${snap_sh}" "${ip}:~/" || poweroff_and_die "${ip}" "${port}" "Could not copy snap script" ${scp} -P "${port}" "${snap_sh}" "${ip}:~/" || poweroff_and_die "${ip}" "${port}" "Could not copy snap script"
@@ -92,15 +92,15 @@ build_arch() {
${ssh} "${ip}" -p "${port}" "~/snap.sh" || poweroff_and_die "${ip}" "${port}" "Failed to run build script" ${ssh} "${ip}" -p "${port}" "~/snap.sh" || poweroff_and_die "${ip}" "${port}" "Failed to run build script"
# copy snap image from VM # copy snap image from VM
${scp} -P "${port}" "${ip}:~/packaging/*.snap" . || poweroff_and_die "${ip}" "${port}" "Failed to get snap image" ${scp} -P "${port}" "${ip}:~/packaging/*.snap" . || poweroff_and_die "${ip}" "${port}" "Failed to get snap image"
# poweroff VM # poweroff VM
${ssh} "${ip}" -p "${port}" sudo poweroff ${ssh} "${ip}" -p "${port}" sudo poweroff
} }
help() help() {
{ usage=$(
usage=$(cat << EOF cat <<EOF
Usage: $0 [-h] [options] Usage: $0 [-h] [options]
Description: Description:
Build snap images. Build snap images.
@@ -109,9 +109,12 @@ Usage: $0 [-h] [options]
-h, Show this help text and exit. -h, Show this help text and exit.
Supported architectures: Supported architectures:
$(IFS=$'\t'; echo -e "${supported_archs[*]}") $(
IFS=$'\t'
echo -e "${supported_archs[*]}"
)
EOF EOF
) )
echo "$usage" echo "$usage"
} }
@@ -121,20 +124,20 @@ main() {
while getopts "a:h" opt; do while getopts "a:h" opt; do
case ${opt} in case ${opt} in
a) a)
arch="${OPTARG}" arch="${OPTARG}"
;; ;;
h) h)
help help
exit 0; exit 0
;; ;;
?) ?)
# parse failure # parse failure
help help
die "Failed to parse arguments" die "Failed to parse arguments"
;; ;;
esac esac
done done
shift $((OPTIND-1)) shift $((OPTIND - 1))
[ -z "${arch}" ] && help && die "Mandatory architecture not supplied" [ -z "${arch}" ] && help && die "Mandatory architecture not supplied"
if ! [[ " ${supported_archs[@]} " =~ " ${arch} " ]]; then if ! [[ " ${supported_archs[@]} " =~ " ${arch} " ]]; then
@@ -145,10 +148,10 @@ main() {
gen_seed gen_seed
if [ "${arch}" != "all" ]; then if [ "${arch}" != "all" ]; then
build_arch "${arch}" &> "${arch}.log" build_arch "${arch}" &>"${arch}.log"
else else
for a in ${supported_archs[@]}; do for a in ${supported_archs[@]}; do
(build_arch "${a}" &> "${a}.log") & (build_arch "${a}" &>"${a}.log") &
done done
wait wait
fi fi

View File

@@ -8,7 +8,7 @@ set -o errexit
set -o nounset set -o nounset
set -o pipefail set -o pipefail
script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "${script_dir}/../../scripts/lib.sh" source "${script_dir}/../../scripts/lib.sh"
@@ -23,11 +23,10 @@ if [ -z "$qemu_repo" ]; then
[ -n "$qemu_url" ] || die "failed to get qemu url" [ -n "$qemu_url" ] || die "failed to get qemu url"
qemu_repo="${qemu_url}.git" qemu_repo="${qemu_url}.git"
fi fi
[ -n "$qemu_repo" ] || die "failed to get qemu repo" [ -n "$qemu_repo" ] || die "failed to get qemu repo"
[ -n "$qemu_version" ] || qemu_version=$(get_from_kata_deps "assets.hypervisor.qemu.version") [ -n "$qemu_version" ] || qemu_version=$(get_from_kata_deps "assets.hypervisor.qemu.version")
[ -n "$qemu_version" ] || die "failed to get qemu version" [ -n "$qemu_version" ] || die "failed to get qemu version"
info "Build ${qemu_repo} version: ${qemu_version}" info "Build ${qemu_repo} version: ${qemu_version}"