mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-31 16:36:38 +00:00
Merge pull request #138 from jcvenegas/shfmt
format: use shfmt to format sh files.
This commit is contained in:
11
.ci/lib.sh
11
.ci/lib.sh
@@ -5,7 +5,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
# If we fail for any reason a message will be displayed
|
||||
die(){
|
||||
die() {
|
||||
msg="$*"
|
||||
echo "ERROR: $msg" >&2
|
||||
exit 1
|
||||
@@ -14,12 +14,10 @@ die(){
|
||||
export tests_repo="${tests_repo:-github.com/kata-containers/tests}"
|
||||
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
|
||||
# no existing clone.
|
||||
if [ -d "${tests_repo_dir}" ] && [ -n "${KATA_CI_NO_NETWORK:-}" ]
|
||||
then
|
||||
if [ -d "${tests_repo_dir}" ] && [ -n "${KATA_CI_NO_NETWORK:-}" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
@@ -30,7 +28,7 @@ install_yq() {
|
||||
path=$1
|
||||
local yq_path=${path}/yq
|
||||
local yq_pkg="github.com/mikefarah/yq"
|
||||
[ -x "${yq_path}" ] && return
|
||||
[ -x "${yq_path}" ] && return
|
||||
|
||||
case "$(arch)" in
|
||||
"aarch64")
|
||||
@@ -60,7 +58,6 @@ install_yq() {
|
||||
# https://github.com/mikefarah/yq/releases/tag/<VERSION-HERE>
|
||||
yq_version=$(basename "${yq_latest_url}")
|
||||
|
||||
|
||||
local yq_url="https://${yq_pkg}/releases/download/${yq_version}/yq_linux_${goarch}"
|
||||
curl -o "${yq_path}" -L ${yq_url}
|
||||
chmod +x ${yq_path}
|
||||
|
@@ -15,7 +15,7 @@ source /etc/os-release
|
||||
|
||||
# This script will execute packaging tests suite
|
||||
|
||||
if [ "$ID" == ubuntu ];then
|
||||
echo "Building snap image"
|
||||
if [ "$ID" == ubuntu ]; then
|
||||
echo "Building snap image"
|
||||
make snap
|
||||
fi
|
||||
|
@@ -11,9 +11,9 @@ set -o pipefail
|
||||
|
||||
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"
|
||||
sudo apt-get install -y snapd snapcraft
|
||||
|
||||
|
@@ -17,10 +17,10 @@ echo "create containerd configuration for Kata"
|
||||
mkdir -p /etc/containerd/
|
||||
|
||||
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
|
||||
|
||||
cat << EOT | tee /etc/containerd/config.toml
|
||||
cat <<EOT | tee /etc/containerd/config.toml
|
||||
[plugins]
|
||||
[plugins.cri.containerd]
|
||||
[plugins.cri.containerd.untrusted_workload_runtime]
|
||||
|
@@ -5,6 +5,5 @@ rm -rf /usr/share/defaults/kata-containers
|
||||
rm -f /etc/containerd/config.toml
|
||||
|
||||
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
|
||||
|
||||
|
@@ -165,7 +165,7 @@ setup_kernel() {
|
||||
download_kernel="true"
|
||||
[ -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}"
|
||||
fi
|
||||
|
||||
@@ -273,7 +273,7 @@ main() {
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(($OPTIND - 1))
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
subcmd="${1:-}"
|
||||
|
||||
|
@@ -1 +1 @@
|
||||
8
|
||||
9
|
||||
|
@@ -10,11 +10,11 @@ set -o errexit
|
||||
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
|
||||
#where packaing repo lives
|
||||
packaging_repo_dir=$(cd "${script_dir}/.." && pwd )
|
||||
packaging_repo_dir=$(cd "${script_dir}/.." && pwd)
|
||||
#where results will be stored
|
||||
host_datadir="${PWD}/pkgs"
|
||||
obs_image="obs-kata"
|
||||
@@ -27,7 +27,7 @@ PUSH=${PUSH:-}
|
||||
GO_ARCH=$(go env GOARCH)
|
||||
export GO_ARCH
|
||||
|
||||
docker_run(){
|
||||
docker_run() {
|
||||
local cmd="$@"
|
||||
sudo docker run \
|
||||
--rm \
|
||||
@@ -39,7 +39,7 @@ docker_run(){
|
||||
--env no_proxy="${no_proxy}" \
|
||||
--env PUSH="${PUSH}" \
|
||||
--env DEBUG="${DEBUG:-}" \
|
||||
--env OBS_SUBPROJECT="${OBS_SUBPROJECT:-}"\
|
||||
--env OBS_SUBPROJECT="${OBS_SUBPROJECT:-}" \
|
||||
-v "${HOME}/.bashrc":/root/.bashrc \
|
||||
-v "$cache_dir":/var/tmp/osbuild-packagecache/ \
|
||||
-v "$packaging_repo_dir":${packaging_repo_dir} \
|
||||
@@ -47,10 +47,10 @@ docker_run(){
|
||||
-v "$HOME/.oscrc":/root/.oscrc \
|
||||
-ti "$obs_image" bash -c "${cmd}"
|
||||
}
|
||||
usage(){
|
||||
usage() {
|
||||
msg="${1:-}"
|
||||
exit_code=$"${2:-0}"
|
||||
cat << EOT
|
||||
cat <<EOT
|
||||
${msg}
|
||||
Usage:
|
||||
${script_name} <kata-branch>
|
||||
@@ -58,16 +58,16 @@ EOT
|
||||
exit "${exit_code}"
|
||||
}
|
||||
|
||||
main(){
|
||||
main() {
|
||||
local 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"
|
||||
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
|
||||
popd >>/dev/null
|
||||
sudo docker build \
|
||||
--build-arg http_proxy="${http_proxy}" \
|
||||
--build-arg https_proxy="${https_proxy}" \
|
||||
|
@@ -15,23 +15,22 @@ project="kata-containers"
|
||||
|
||||
source "${script_dir}/../scripts/lib.sh"
|
||||
|
||||
get_kata_hash_from_tag(){
|
||||
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(){
|
||||
gen_version_file() {
|
||||
local branch="$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_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}')
|
||||
@@ -48,7 +47,7 @@ gen_version_file(){
|
||||
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
|
||||
cat >versions.txt <<EOT
|
||||
|
||||
# This is a generated file from ${script_name}
|
||||
|
||||
@@ -84,10 +83,10 @@ go_checksum=${golang_x84_64_sha256}
|
||||
EOT
|
||||
}
|
||||
|
||||
usage(){
|
||||
usage() {
|
||||
msg="${1:-}"
|
||||
exit_code=$"${2:-0}"
|
||||
cat << EOT
|
||||
cat <<EOT
|
||||
${msg}
|
||||
Usage:
|
||||
${script_name} <kata-branch>
|
||||
@@ -95,7 +94,7 @@ EOT
|
||||
exit "${exit_code}"
|
||||
}
|
||||
|
||||
main(){
|
||||
main() {
|
||||
local branch="${1:-}"
|
||||
[ -n "${branch}" ] || usage "missing branch" "1"
|
||||
gen_version_file "${branch}"
|
||||
|
@@ -5,7 +5,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
[ -z "${DEBUG}" ] || set -x
|
||||
[ -z "${DEBUG}" ] || set -x
|
||||
|
||||
set -o errexit
|
||||
set -o nounset
|
||||
@@ -17,11 +17,9 @@ readonly project="kata-containers"
|
||||
readonly tmp_dir=$(mktemp -d -t build-image-tmp.XXXXXXXXXX)
|
||||
readonly osbuilder_url=https://github.com/${project}/osbuilder.git
|
||||
|
||||
|
||||
export GOPATH=${GOPATH:-${HOME}/go}
|
||||
source "${script_dir}/../../scripts/lib.sh"
|
||||
|
||||
|
||||
arch_target="$(uname -m)"
|
||||
|
||||
kata_version="master"
|
||||
@@ -31,31 +29,30 @@ kata_osbuilder_version="${KATA_OSBUILDER_VERSION:-}"
|
||||
# Agent version
|
||||
agent_version="${AGENT_VERSION:-}"
|
||||
|
||||
|
||||
readonly destdir="${PWD}"
|
||||
|
||||
build_initrd(){
|
||||
sudo -E PATH="$PATH" make initrd\
|
||||
DISTRO="$initrd_distro" \
|
||||
DEBUG="${DEBUG:-}" \
|
||||
AGENT_VERSION="${agent_version}" \
|
||||
OS_VERSION="${initrd_os_version}" \
|
||||
DISTRO_ROOTFS="${tmp_dir}/initrd-image" \
|
||||
USE_DOCKER=1 \
|
||||
AGENT_INIT="yes"
|
||||
build_initrd() {
|
||||
sudo -E PATH="$PATH" make initrd \
|
||||
DISTRO="$initrd_distro" \
|
||||
DEBUG="${DEBUG:-}" \
|
||||
AGENT_VERSION="${agent_version}" \
|
||||
OS_VERSION="${initrd_os_version}" \
|
||||
DISTRO_ROOTFS="${tmp_dir}/initrd-image" \
|
||||
USE_DOCKER=1 \
|
||||
AGENT_INIT="yes"
|
||||
|
||||
}
|
||||
|
||||
build_image(){
|
||||
build_image() {
|
||||
sudo -E PATH="${PATH}" make image \
|
||||
DISTRO="${img_distro}" \
|
||||
DEBUG="${DEBUG:-}" \
|
||||
AGENT_VERSION="${agent_version}" \
|
||||
IMG_OS_VERSION="${img_os_version}" \
|
||||
DISTRO_ROOTFS="${tmp_dir}/rootfs-image"
|
||||
DISTRO="${img_distro}" \
|
||||
DEBUG="${DEBUG:-}" \
|
||||
AGENT_VERSION="${agent_version}" \
|
||||
IMG_OS_VERSION="${img_os_version}" \
|
||||
DISTRO_ROOTFS="${tmp_dir}/rootfs-image"
|
||||
}
|
||||
|
||||
create_tarball(){
|
||||
create_tarball() {
|
||||
agent_sha=$(get_repo_hash "${GOPATH}/src/github.com/kata-containers/agent")
|
||||
#reduce sha size for short names
|
||||
agent_sha=${agent_sha:0:11}
|
||||
@@ -68,9 +65,9 @@ create_tarball(){
|
||||
sudo tar cfzv "${tarball_name}" "${initrd_name}" "${image_name}"
|
||||
}
|
||||
|
||||
usage(){
|
||||
usage() {
|
||||
return_code=${1:-0}
|
||||
cat << EOT
|
||||
cat <<EOT
|
||||
Create image and initrd in a tarball for kata containers.
|
||||
Use it to build an image to distribute kata.
|
||||
|
||||
@@ -83,16 +80,18 @@ Options:
|
||||
|
||||
EOT
|
||||
|
||||
exit "${return_code}"
|
||||
exit "${return_code}"
|
||||
}
|
||||
|
||||
main(){
|
||||
while getopts "v:h" opt
|
||||
do
|
||||
main() {
|
||||
while getopts "v:h" opt; do
|
||||
case "$opt" in
|
||||
h) usage 0 ;;
|
||||
v) kata_version="${OPTARG}" ;;
|
||||
*) echo "Invalid option $opt"; usage 1;;
|
||||
h) usage 0 ;;
|
||||
v) kata_version="${OPTARG}" ;;
|
||||
*)
|
||||
echo "Invalid option $opt"
|
||||
usage 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
# osbuilder info
|
||||
@@ -108,7 +107,7 @@ main(){
|
||||
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"
|
||||
pushd "${tmp_dir}/osbuilder"
|
||||
git checkout "${kata_osbuilder_version}"
|
||||
|
@@ -38,12 +38,12 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
|
||||
((RELEASE++))
|
||||
|
||||
function check_image() {
|
||||
[ ! -f "${SCRIPT_DIR}/kata-containers.tar.gz" ] && die "No kata-containers.tar.gz found!\nUse the build_image.sh script" || echo "Image: OK"
|
||||
[ ! -f "${SCRIPT_DIR}/kata-containers.tar.gz" ] && die "No kata-containers.tar.gz found!\nUse the build_image.sh script" || echo "Image: OK"
|
||||
}
|
||||
|
||||
replace_list=(
|
||||
"VERSION=$VERSION"
|
||||
"RELEASE=$RELEASE"
|
||||
"VERSION=$VERSION"
|
||||
"RELEASE=$RELEASE"
|
||||
)
|
||||
|
||||
verify
|
||||
|
@@ -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
|
||||
|
||||
replace_list=(
|
||||
"VERSION=${VERSION}"
|
||||
"CONFIG_VERSION=${KATA_CONFIG_VERSION}"
|
||||
"RELEASE=$RELEASE"
|
||||
"KERNEL_SHA256=$kernel_sha256"
|
||||
"VERSION=${VERSION}"
|
||||
"CONFIG_VERSION=${KATA_CONFIG_VERSION}"
|
||||
"RELEASE=$RELEASE"
|
||||
"KERNEL_SHA256=$kernel_sha256"
|
||||
)
|
||||
|
||||
verify
|
||||
|
@@ -40,12 +40,12 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
|
||||
set_versions "$kata_ksm_throttler_hash"
|
||||
|
||||
replace_list=(
|
||||
"GO_CHECKSUM=$go_checksum"
|
||||
"GO_VERSION=$go_version"
|
||||
"GO_ARCH=$GO_ARCH"
|
||||
"HASH=${short_hashtag}"
|
||||
"RELEASE=$RELEASE"
|
||||
"VERSION=$VERSION"
|
||||
"GO_CHECKSUM=$go_checksum"
|
||||
"GO_VERSION=$go_version"
|
||||
"GO_ARCH=$GO_ARCH"
|
||||
"HASH=${short_hashtag}"
|
||||
"RELEASE=$RELEASE"
|
||||
"VERSION=$VERSION"
|
||||
)
|
||||
|
||||
verify
|
||||
|
@@ -36,12 +36,12 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
|
||||
set_versions $kata_proxy_hash
|
||||
|
||||
replace_list=(
|
||||
"GO_CHECKSUM=$go_checksum"
|
||||
"GO_VERSION=$go_version"
|
||||
"GO_ARCH=$GO_ARCH"
|
||||
"HASH=$short_hashtag"
|
||||
"RELEASE=$RELEASE"
|
||||
"VERSION=$VERSION"
|
||||
"GO_CHECKSUM=$go_checksum"
|
||||
"GO_VERSION=$go_version"
|
||||
"GO_ARCH=$GO_ARCH"
|
||||
"HASH=$short_hashtag"
|
||||
"RELEASE=$RELEASE"
|
||||
"VERSION=$VERSION"
|
||||
)
|
||||
|
||||
verify
|
||||
|
@@ -36,9 +36,9 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
|
||||
set_versions "${qemu_lite_hash}"
|
||||
|
||||
replace_list=(
|
||||
"VERSION=$VERSION"
|
||||
"RELEASE=$RELEASE"
|
||||
"QEMU_LITE_HASH=${qemu_lite_hash:0:10}"
|
||||
"VERSION=$VERSION"
|
||||
"RELEASE=$RELEASE"
|
||||
"QEMU_LITE_HASH=${qemu_lite_hash:0:10}"
|
||||
)
|
||||
verify
|
||||
echo "Verify succeed."
|
||||
|
@@ -23,7 +23,7 @@ SCRIPT_DIR=$(dirname $0)
|
||||
PKG_NAME="qemu-vanilla"
|
||||
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)
|
||||
|
||||
# Parse arguments
|
||||
@@ -37,9 +37,9 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
|
||||
set_versions "${qemu_vanilla_hash}"
|
||||
|
||||
replace_list=(
|
||||
"VERSION=$VERSION"
|
||||
"RELEASE=$RELEASE"
|
||||
"QEMU_VANILLA_HASH=${qemu_vanilla_hash:0:10}"
|
||||
"VERSION=$VERSION"
|
||||
"RELEASE=$RELEASE"
|
||||
"QEMU_VANILLA_HASH=${qemu_vanilla_hash:0:10}"
|
||||
)
|
||||
|
||||
verify
|
||||
|
@@ -81,19 +81,19 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
|
||||
set_versions "$kata_runtime_hash"
|
||||
|
||||
replace_list=(
|
||||
"GO_CHECKSUM=$go_checksum"
|
||||
"GO_VERSION=$go_version"
|
||||
"GO_ARCH=$GO_ARCH"
|
||||
"HASH=$short_hashtag"
|
||||
"RELEASE=$RELEASE"
|
||||
"VERSION=$VERSION"
|
||||
"kata_osbuilder_version=${KATA_IMAGE_REQUIRED_VERSION}"
|
||||
"kata_proxy_version=${PROXY_REQUIRED_VERESION}"
|
||||
"kata_shim_version=${SHIM_REQUIRED_VERSION}"
|
||||
"ksm_throttler_version=${KSM_THROTTLER_REQUIRED_VERSION}"
|
||||
"linux_container_version=${KERNEL_REQUIRED_VERSION}"
|
||||
"qemu_lite_version=${KATA_QEMU_LITE_REQUIRED_VERSION}"
|
||||
"qemu_vanilla_version=${KATA_QEMU_VANILLA_REQUIRED_VERSION}"
|
||||
"GO_CHECKSUM=$go_checksum"
|
||||
"GO_VERSION=$go_version"
|
||||
"GO_ARCH=$GO_ARCH"
|
||||
"HASH=$short_hashtag"
|
||||
"RELEASE=$RELEASE"
|
||||
"VERSION=$VERSION"
|
||||
"kata_osbuilder_version=${KATA_IMAGE_REQUIRED_VERSION}"
|
||||
"kata_proxy_version=${PROXY_REQUIRED_VERESION}"
|
||||
"kata_shim_version=${SHIM_REQUIRED_VERSION}"
|
||||
"ksm_throttler_version=${KSM_THROTTLER_REQUIRED_VERSION}"
|
||||
"linux_container_version=${KERNEL_REQUIRED_VERSION}"
|
||||
"qemu_lite_version=${KATA_QEMU_LITE_REQUIRED_VERSION}"
|
||||
"qemu_vanilla_version=${KATA_QEMU_VANILLA_REQUIRED_VERSION}"
|
||||
)
|
||||
|
||||
verify
|
||||
@@ -102,4 +102,3 @@ get_git_info
|
||||
changelog_update $VERSION
|
||||
generate_files "$SCRIPT_DIR" "${replace_list[@]}"
|
||||
build_pkg "${PROJECT_REPO}"
|
||||
|
||||
|
@@ -33,180 +33,197 @@ else
|
||||
echo "Go not installed using $GO_ARCH to install go in dockerfile"
|
||||
fi
|
||||
|
||||
function display_help()
|
||||
{
|
||||
function display_help() {
|
||||
cat <<-EOL
|
||||
$SCRIPT_NAME
|
||||
|
||||
This script is intended to create Kata Containers packages for the OBS
|
||||
(Open Build Service) platform.
|
||||
|
||||
Usage:
|
||||
$SCRIPT_NAME [options]
|
||||
|
||||
Options:
|
||||
|
||||
-l --local-build Build the runtime locally
|
||||
-b --branch Build with a given branch name
|
||||
-p --push Push changes to OBS
|
||||
-a --api-url Especify an OBS API (e.g. custom private OBS)
|
||||
-r --obs-repository An OBS repository to push the changes.
|
||||
-w --workdir Directory of a working copy of the OBS runtime repo
|
||||
-v --verbose Set the -x flag for verbosity
|
||||
-C --clean Clean the repository
|
||||
-V --verify Verify the environment
|
||||
-h --help Display this help message
|
||||
|
||||
Usage examples:
|
||||
|
||||
$SCRIPT_NAME --local-build --branch staging
|
||||
$SCRIPT_NAME --push --api-url http://127.0.0.1
|
||||
$SCRIPT_NAME --push --obs-repository home:userx/repository
|
||||
$SCRIPT_NAME --push
|
||||
|
||||
$SCRIPT_NAME
|
||||
|
||||
This script is intended to create Kata Containers packages for the OBS
|
||||
(Open Build Service) platform.
|
||||
|
||||
Usage:
|
||||
$SCRIPT_NAME [options]
|
||||
|
||||
Options:
|
||||
|
||||
-l --local-build Build the runtime locally
|
||||
-b --branch Build with a given branch name
|
||||
-p --push Push changes to OBS
|
||||
-a --api-url Especify an OBS API (e.g. custom private OBS)
|
||||
-r --obs-repository An OBS repository to push the changes.
|
||||
-w --workdir Directory of a working copy of the OBS runtime repo
|
||||
-v --verbose Set the -x flag for verbosity
|
||||
-C --clean Clean the repository
|
||||
-V --verify Verify the environment
|
||||
-h --help Display this help message
|
||||
|
||||
Usage examples:
|
||||
|
||||
$SCRIPT_NAME --local-build --branch staging
|
||||
$SCRIPT_NAME --push --api-url http://127.0.0.1
|
||||
$SCRIPT_NAME --push --obs-repository home:userx/repository
|
||||
$SCRIPT_NAME --push
|
||||
|
||||
EOL
|
||||
exit 1
|
||||
}
|
||||
|
||||
die()
|
||||
{
|
||||
die() {
|
||||
msg="$*"
|
||||
echo >&2 "ERROR: $msg"
|
||||
exit 1
|
||||
}
|
||||
|
||||
info()
|
||||
{
|
||||
info() {
|
||||
msg="$*"
|
||||
echo "INFO: $msg"
|
||||
}
|
||||
|
||||
function verify()
|
||||
{
|
||||
# This function perform some checks in order to make sure
|
||||
# the script will run flawlessly.
|
||||
function verify() {
|
||||
# This function perform some checks in order to make sure
|
||||
# the script will run flawlessly.
|
||||
|
||||
# Make sure this script is called from ./
|
||||
[ "$SCRIPT_DIR" != "." ] && die "The script must be called from its base dir."
|
||||
# Make sure this script is called from ./
|
||||
[ "$SCRIPT_DIR" != "." ] && die "The script must be called from its base dir."
|
||||
|
||||
# Verify if osc is installed, exit otherwise.
|
||||
[ ! -x "$(command -v osc)" ] && die "osc is not installed."
|
||||
# Verify if osc is installed, exit otherwise.
|
||||
[ ! -x "$(command -v osc)" ] && die "osc is not installed."
|
||||
|
||||
info "OK"
|
||||
info "OK"
|
||||
}
|
||||
|
||||
function clean()
|
||||
{
|
||||
# This function clean generated files
|
||||
for file in "$@"
|
||||
do
|
||||
[ -e $file ] && rm -v $file
|
||||
done
|
||||
[ -e ./debian.changelog ] && git checkout ./debian.changelog
|
||||
[ -e ./release ] && git checkout ./release
|
||||
echo "Clean done."
|
||||
function clean() {
|
||||
# This function clean generated files
|
||||
for file in "$@"; do
|
||||
[ -e $file ] && rm -v $file
|
||||
done
|
||||
[ -e ./debian.changelog ] && git checkout ./debian.changelog
|
||||
[ -e ./release ] && git checkout ./release
|
||||
echo "Clean done."
|
||||
}
|
||||
|
||||
function get_git_info()
|
||||
{
|
||||
AUTHOR=${AUTHOR:-$(git config user.name)}
|
||||
AUTHOR_EMAIL=${AUTHOR_EMAIL:-$(git config user.email)}
|
||||
function get_git_info() {
|
||||
AUTHOR=${AUTHOR:-$(git config user.name)}
|
||||
AUTHOR_EMAIL=${AUTHOR_EMAIL:-$(git config user.email)}
|
||||
}
|
||||
|
||||
function set_versions()
|
||||
{
|
||||
local commit_hash="$1"
|
||||
hash_tag="$commit_hash"
|
||||
short_hashtag="${hash_tag:0:7}"
|
||||
function set_versions() {
|
||||
local commit_hash="$1"
|
||||
hash_tag="$commit_hash"
|
||||
short_hashtag="${hash_tag:0:7}"
|
||||
}
|
||||
|
||||
function changelog_update {
|
||||
d=$(date -R)
|
||||
cat <<< "$PKG_NAME ($VERSION) stable; urgency=medium
|
||||
function changelog_update() {
|
||||
d=$(date -R)
|
||||
cat <<<"$PKG_NAME ($VERSION) stable; urgency=medium
|
||||
|
||||
* Update $PKG_NAME $VERSION ${hash_tag:0:7}
|
||||
|
||||
-- $AUTHOR <$AUTHOR_EMAIL> $d
|
||||
" > debian.changelog
|
||||
" >debian.changelog
|
||||
# Append, so it can be copied to the OBS repository
|
||||
GENERATED_FILES+=('debian.changelog')
|
||||
}
|
||||
|
||||
function local_build()
|
||||
{
|
||||
[ ! -e $PACKAGING_DIR ] && mkdir $PACKAGING_DIR
|
||||
[ ! -e $LOG_DIR ] && mkdir $LOG_DIR
|
||||
function local_build() {
|
||||
[ ! -e $PACKAGING_DIR ] && mkdir $PACKAGING_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')
|
||||
[ "$OFFLINE" == "true" ] && BUILD_ARGS+=('--offline')
|
||||
BUILD_ARGS=('--local-package' '--no-verify' '--noservice' '--trust-all-projects' '--keep-pkgs=/var/packaging/results')
|
||||
[ "$OFFLINE" == "true" ] && BUILD_ARGS+=('--offline')
|
||||
|
||||
osc service run
|
||||
for distro in ${BUILD_DISTROS[@]}
|
||||
do
|
||||
# If more distros are supported, add here the relevant validations.
|
||||
if [[ "$distro" =~ ^Fedora.* ]] || [[ "$distro" =~ ^CentOS.* ]]
|
||||
then
|
||||
echo "Perform a local build for ${distro}"
|
||||
osc build ${BUILD_ARGS[@]} \
|
||||
${distro} $BUILD_ARCH *.spec | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log
|
||||
osc service run
|
||||
for distro in ${BUILD_DISTROS[@]}; do
|
||||
# If more distros are supported, add here the relevant validations.
|
||||
if [[ $distro =~ ^Fedora.* ]] || [[ $distro =~ ^CentOS.* ]]; then
|
||||
echo "Perform a local build for ${distro}"
|
||||
osc build ${BUILD_ARGS[@]} \
|
||||
${distro} $BUILD_ARCH *.spec | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log
|
||||
|
||||
elif [[ "$distro" =~ ^xUbuntu.* ]]
|
||||
then
|
||||
echo "Perform a local build for ${distro}"
|
||||
osc build ${BUILD_ARGS[@]} \
|
||||
${distro} $BUILD_ARCH *.dsc | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log
|
||||
fi
|
||||
done
|
||||
elif [[ $distro =~ ^xUbuntu.* ]]; then
|
||||
echo "Perform a local build for ${distro}"
|
||||
osc build ${BUILD_ARGS[@]} \
|
||||
${distro} $BUILD_ARCH *.dsc | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
function checkout_repo()
|
||||
{
|
||||
local REPO="${1}"
|
||||
if [ -z "${OBS_WORKDIR:-}" ]
|
||||
then
|
||||
OBS_WORKDIR=$(mktemp -d -u -t obs-repo.XXXXXXXXXXX) || exit 1
|
||||
osc co "${REPO}" -o "${OBS_WORKDIR}"
|
||||
fi
|
||||
find "${OBS_WORKDIR}" -maxdepth 1 -mindepth 1 ! -name '.osc' -prune -exec echo remove {} \; -exec rm -rf {} \;
|
||||
function checkout_repo() {
|
||||
local REPO="${1}"
|
||||
if [ -z "${OBS_WORKDIR:-}" ]; then
|
||||
OBS_WORKDIR=$(mktemp -d -u -t obs-repo.XXXXXXXXXXX) || exit 1
|
||||
osc co "${REPO}" -o "${OBS_WORKDIR}"
|
||||
fi
|
||||
find "${OBS_WORKDIR}" -maxdepth 1 -mindepth 1 ! -name '.osc' -prune -exec echo remove {} \; -exec rm -rf {} \;
|
||||
|
||||
mv "${GENERATED_FILES[@]}" "${OBS_WORKDIR}"
|
||||
cp "${STATIC_FILES[@]}" "$OBS_WORKDIR"
|
||||
mv "${GENERATED_FILES[@]}" "${OBS_WORKDIR}"
|
||||
cp "${STATIC_FILES[@]}" "$OBS_WORKDIR"
|
||||
}
|
||||
|
||||
function obs_push()
|
||||
{
|
||||
pushd $OBS_WORKDIR
|
||||
osc addremove
|
||||
osc commit -m "Update ${PKG_NAME} $VERSION: ${hash_tag:0:7}"
|
||||
popd
|
||||
function obs_push() {
|
||||
pushd $OBS_WORKDIR
|
||||
osc addremove
|
||||
osc commit -m "Update ${PKG_NAME} $VERSION: ${hash_tag:0:7}"
|
||||
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 -- "$@")
|
||||
while true; do
|
||||
case "${1}" in
|
||||
-b | --branch ) BRANCH="true"; OBS_REVISION="$2"; shift 2;;
|
||||
-l | --local-build ) LOCAL_BUILD="true"; shift;;
|
||||
-p | --push ) OBS_PUSH="true"; shift;;
|
||||
-r | --obs-repository ) PROJECT_REPO="$2"; shift 2;;
|
||||
-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 ;;
|
||||
-b | --branch)
|
||||
BRANCH="true"
|
||||
OBS_REVISION="$2"
|
||||
shift 2
|
||||
;;
|
||||
-l | --local-build)
|
||||
LOCAL_BUILD="true"
|
||||
shift
|
||||
;;
|
||||
-p | --push)
|
||||
OBS_PUSH="true"
|
||||
shift
|
||||
;;
|
||||
-r | --obs-repository)
|
||||
PROJECT_REPO="$2"
|
||||
shift 2
|
||||
;;
|
||||
-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
|
||||
done
|
||||
|
||||
}
|
||||
|
||||
function build_pkg()
|
||||
{
|
||||
function build_pkg() {
|
||||
|
||||
obs_repository="${1}"
|
||||
|
||||
@@ -226,7 +243,7 @@ function build_pkg()
|
||||
|
||||
}
|
||||
|
||||
function generate_files () {
|
||||
function generate_files() {
|
||||
|
||||
directory=$1
|
||||
replace_list=$2
|
||||
@@ -242,8 +259,8 @@ function generate_files () {
|
||||
|
||||
# check replace list
|
||||
# key=val
|
||||
for replace in "${replace_list[@]}" ; do
|
||||
[[ "$replace" = *"="* ]] || die "invalid replace $replace"
|
||||
for replace in "${replace_list[@]}"; do
|
||||
[[ $replace == *"="* ]] || die "invalid replace $replace"
|
||||
local key="${replace%%=*}"
|
||||
local value="${replace##*=}"
|
||||
[ -n "$key" ] || die "${replace} key is empty"
|
||||
@@ -255,13 +272,13 @@ function generate_files () {
|
||||
genfile="${f%-template}"
|
||||
cp "$f" "${genfile}"
|
||||
info "Generate file ${genfile}"
|
||||
for replace in "${replace_list[@]}" ; do
|
||||
[[ "$replace" = *"="* ]] || die "invalid replace $replace"
|
||||
for replace in "${replace_list[@]}"; do
|
||||
[[ $replace == *"="* ]] || die "invalid replace $replace"
|
||||
local key="${replace%%=*}"
|
||||
local value="${replace##*=}"
|
||||
export k="@${key}@"
|
||||
export v="$value"
|
||||
perl -p -e 's/$ENV{k}/$ENV{v}/g' "${genfile}" > "${genfile}.out"
|
||||
perl -p -e 's/$ENV{k}/$ENV{v}/g' "${genfile}" >"${genfile}.out"
|
||||
mv "${genfile}.out" ${genfile}
|
||||
done
|
||||
done
|
||||
@@ -299,11 +316,11 @@ function get_obs_pkg_release() {
|
||||
|
||||
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
|
||||
# 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
|
||||
|
||||
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 {} \;)
|
||||
n="1"
|
||||
rm -f debian.series
|
||||
for p in ${patches} ; do
|
||||
for p in ${patches}; do
|
||||
STATIC_FILES+=("patches/$p")
|
||||
RPM_PATCH_LIST+="Patch00${n}: $p"$'\n'
|
||||
RPM_APPLY_PATCHES+="%patch00${n} -p1"$'\n'
|
||||
echo "$p" >> debian.series
|
||||
echo "$p" >>debian.series
|
||||
((n++))
|
||||
done
|
||||
GENERATED_FILES+=(debian.series)
|
||||
|
@@ -36,12 +36,12 @@ RELEASE=$(get_obs_pkg_release "${PROJECT_REPO}")
|
||||
|
||||
set_versions $kata_shim_hash
|
||||
replace_list=(
|
||||
"GO_CHECKSUM=$go_checksum"
|
||||
"GO_VERSION=$go_version"
|
||||
"GO_ARCH=$GO_ARCH"
|
||||
"HASH=$short_hashtag"
|
||||
"RELEASE=$RELEASE"
|
||||
"VERSION=$VERSION"
|
||||
"GO_CHECKSUM=$go_checksum"
|
||||
"GO_VERSION=$go_version"
|
||||
"GO_ARCH=$GO_ARCH"
|
||||
"HASH=$short_hashtag"
|
||||
"RELEASE=$RELEASE"
|
||||
"VERSION=$VERSION"
|
||||
)
|
||||
|
||||
verify
|
||||
|
@@ -91,7 +91,7 @@ install_image() {
|
||||
install_kernel() {
|
||||
go get "github.com/${project}/packaging" || true
|
||||
pushd ${GOPATH}/src/github.com/${project}/packaging >>/dev/null
|
||||
git checkout "${kata_version}-kernel-config"
|
||||
git checkout "${kata_version}-kernel-config"
|
||||
popd >>/dev/null
|
||||
pushd "${script_dir}/../kernel" >>/dev/null
|
||||
|
||||
|
@@ -88,7 +88,7 @@ tag_repos() {
|
||||
info "Creating tag ${kata_version} in all repos"
|
||||
for repo in "${repos[@]}"; do
|
||||
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 fetch origin --tags
|
||||
tag="$kata_version"
|
||||
@@ -99,7 +99,7 @@ tag_repos() {
|
||||
info "Creating tag ${tag} for ${repo}"
|
||||
git tag -a "${tag}" -s -m "${PROJECT} release ${tag}"
|
||||
fi
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
@@ -107,21 +107,21 @@ push_tags() {
|
||||
info "Pushing tags to repos"
|
||||
build_hub
|
||||
for repo in "${repos[@]}"; do
|
||||
pushd "${repo}" >> /dev/null
|
||||
pushd "${repo}" >>/dev/null
|
||||
tag="$kata_version"
|
||||
[[ "packaging" == "${repo}" ]] && tag="${tag}-kernel-config"
|
||||
info "Push tag ${tag} for ${repo}"
|
||||
git push origin "${tag}"
|
||||
create_github_release "${PWD}" "${tag}"
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
done
|
||||
}
|
||||
|
||||
create_github_release(){
|
||||
create_github_release() {
|
||||
repo_dir=${1:-}
|
||||
tag=${2:-}
|
||||
[ -d "${repo_dir}" ] || die "No repository directory"
|
||||
[ -n "${tag}" ] || die "No repository directory"
|
||||
[ -d "${repo_dir}" ] || die "No repository directory"
|
||||
[ -n "${tag}" ] || die "No repository directory"
|
||||
if ! "${hub_bin}" release | grep "${tag}"; then
|
||||
info "Creating Github release"
|
||||
"${hub_bin}" -C "${repo_dir}" release create -m "${PROJECT} ${tag}" "${tag}"
|
||||
@@ -136,13 +136,13 @@ while getopts "hp" opt; do
|
||||
p) PUSH="true" ;;
|
||||
esac
|
||||
done
|
||||
shift $(($OPTIND - 1))
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
subcmd=${1:-""}
|
||||
|
||||
[ -z "${subcmd}" ] && usage && exit 0
|
||||
|
||||
pushd "${tmp_dir}" >> /dev/null
|
||||
pushd "${tmp_dir}" >>/dev/null
|
||||
|
||||
case "${subcmd}" in
|
||||
status)
|
||||
@@ -167,4 +167,4 @@ tag)
|
||||
|
||||
esac
|
||||
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
|
@@ -10,10 +10,10 @@ set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
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"
|
||||
./release/tag_repos.sh -h | grep Usage
|
||||
./release/tag_repos.sh -h | grep Usage
|
||||
|
||||
echo "Check tag_repos.sh status"
|
||||
./release/tag_repos.sh status | grep runtime
|
||||
|
@@ -9,7 +9,7 @@ set -o errexit
|
||||
set -o nounset
|
||||
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 tmp_dir=$(mktemp -t -d pr-bump.XXXX)
|
||||
@@ -19,7 +19,7 @@ GOPATH=${GOPATH:-${HOME}/go}
|
||||
|
||||
source "${script_dir}/../scripts/lib.sh"
|
||||
|
||||
cleanup (){
|
||||
cleanup() {
|
||||
[ -d "${tmp_dir}" ] && rm -rf "${tmp_dir}"
|
||||
}
|
||||
|
||||
@@ -36,8 +36,7 @@ get_changes() {
|
||||
fi
|
||||
|
||||
# list all PRs merged from $current_version to HEAD
|
||||
git log --merges "${current_version}..HEAD" | awk '/Merge pull/{getline; getline;print }' | while read pr
|
||||
do
|
||||
git log --merges "${current_version}..HEAD" | awk '/Merge pull/{getline; getline;print }' | while read pr; do
|
||||
echo "- ${pr}"
|
||||
done
|
||||
|
||||
@@ -71,7 +70,7 @@ bump_repo() {
|
||||
|
||||
git clone --quiet "${remote_github}"
|
||||
|
||||
pushd "${repo}" >> /dev/null
|
||||
pushd "${repo}" >>/dev/null
|
||||
|
||||
# All repos we build should have a VERSION file
|
||||
[ -f "VERSION" ] || die "VERSION file not found "
|
||||
@@ -79,7 +78,7 @@ bump_repo() {
|
||||
|
||||
info "Creating PR message"
|
||||
notes_file=notes.md
|
||||
cat << EOT > "${notes_file}"
|
||||
cat <<EOT >"${notes_file}"
|
||||
# Kata Containers ${new_version}
|
||||
|
||||
$(get_changes "$current_version")
|
||||
@@ -87,15 +86,15 @@ $(get_changes "$current_version")
|
||||
EOT
|
||||
|
||||
info "Updating VERSION file"
|
||||
echo "${new_version}" > VERSION
|
||||
echo "${new_version}" >VERSION
|
||||
branch="${new_version}-branch-bump"
|
||||
git checkout -b "${branch}" master
|
||||
git add -u
|
||||
info "Creating commit with new changes"
|
||||
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
|
||||
info "Forking remote"
|
||||
${hub_bin} fork --remote-name=fork
|
||||
@@ -103,12 +102,12 @@ EOT
|
||||
${hub_bin} push fork -f "${branch}"
|
||||
info "Create PR"
|
||||
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
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
}
|
||||
|
||||
usage(){
|
||||
usage() {
|
||||
exit_code="$1"
|
||||
cat <<EOT
|
||||
Usage:
|
||||
@@ -125,21 +124,20 @@ EOT
|
||||
exit "$exit_code"
|
||||
}
|
||||
|
||||
while getopts "hp" opt
|
||||
do
|
||||
while getopts "hp" opt; do
|
||||
case $opt in
|
||||
h) usage 0 ;;
|
||||
p) PUSH="true" ;;
|
||||
h) usage 0 ;;
|
||||
p) PUSH="true" ;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $(( $OPTIND - 1 ))
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
repo=${1:-}
|
||||
new_version=${2:-}
|
||||
[ -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}"
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
|
@@ -9,37 +9,37 @@ set -o errexit
|
||||
set -o nounset
|
||||
set -o pipefail
|
||||
|
||||
readonly script_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||
readonly script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
out=""
|
||||
|
||||
handle_error(){
|
||||
handle_error() {
|
||||
echo "not ok"
|
||||
echo "output: ${out}"
|
||||
}
|
||||
|
||||
OK(){
|
||||
OK() {
|
||||
echo "ok"
|
||||
}
|
||||
output_should_contain(){
|
||||
output_should_contain() {
|
||||
local output="$1"
|
||||
local text_to_find="$2"
|
||||
[ -n "$output" ]
|
||||
[ -n "$text_to_find" ]
|
||||
[ -n "$output" ]
|
||||
[ -n "$text_to_find" ]
|
||||
echo "${output}" | grep "${text_to_find}"
|
||||
}
|
||||
|
||||
trap handle_error ERR
|
||||
|
||||
echo "Missing args show help"
|
||||
out=$("${script_dir}/update-repository-version.sh" 2>&1) || (($?!=0))
|
||||
echo "${out}" | grep Usage >> /dev/null
|
||||
out=$("${script_dir}/update-repository-version.sh" 2>&1) || (($? != 0))
|
||||
echo "${out}" | grep Usage >>/dev/null
|
||||
output_should_contain "${out}" "Usage"
|
||||
OK
|
||||
|
||||
echo "Missing version show help"
|
||||
out=$("${script_dir}/update-repository-version.sh" runtime 2>&1) || (($?!=0))
|
||||
echo "${out}" | grep Usage >> /dev/null
|
||||
echo "${out}" | grep "no new version">> /dev/null
|
||||
out=$("${script_dir}/update-repository-version.sh" runtime 2>&1) || (($? != 0))
|
||||
echo "${out}" | grep Usage >>/dev/null
|
||||
echo "${out}" | grep "no new version" >>/dev/null
|
||||
OK
|
||||
|
||||
echo "help option"
|
||||
|
@@ -48,17 +48,15 @@ recognised_tags=(
|
||||
)
|
||||
|
||||
# Display message to stderr and exit indicating script failed.
|
||||
die()
|
||||
{
|
||||
die() {
|
||||
local msg="$*"
|
||||
echo >&2 "$script_name: ERROR: $msg"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Display usage to stdout.
|
||||
usage()
|
||||
{
|
||||
cat <<EOT
|
||||
usage() {
|
||||
cat <<EOT
|
||||
Overview:
|
||||
|
||||
Display configure options required to build the specified
|
||||
@@ -83,8 +81,7 @@ Example:
|
||||
EOT
|
||||
}
|
||||
|
||||
show_tags_header()
|
||||
{
|
||||
show_tags_header() {
|
||||
local keys
|
||||
local key
|
||||
local value
|
||||
@@ -96,10 +93,9 @@ EOT
|
||||
|
||||
# sort the tags
|
||||
keys=${!recognised_tags[@]}
|
||||
keys=$(echo "$keys"|tr ' ' '\n'|sort -u)
|
||||
keys=$(echo "$keys" | tr ' ' '\n' | sort -u)
|
||||
|
||||
for key in $keys
|
||||
do
|
||||
for key in $keys; do
|
||||
value="${recognised_tags[$key]}"
|
||||
printf "# %s\t%s.\n" "$key" "$value"
|
||||
done
|
||||
@@ -107,8 +103,7 @@ EOT
|
||||
printf "#\n\n"
|
||||
}
|
||||
|
||||
check_tag()
|
||||
{
|
||||
check_tag() {
|
||||
local tag="$1"
|
||||
local entry="$2"
|
||||
|
||||
@@ -123,18 +118,16 @@ check_tag()
|
||||
die "invalid tag '$tag' found for entry '$entry'"
|
||||
}
|
||||
|
||||
check_tags()
|
||||
{
|
||||
check_tags() {
|
||||
local tags="$1"
|
||||
local entry="$2"
|
||||
|
||||
[ -z "$tags" ] && die "entry '$entry' doesn't have any tags"
|
||||
[ -z "$entry" ] && die "no entry for tags '$tags'"
|
||||
|
||||
tags=$(echo "$tags"|tr ',' '\n')
|
||||
tags=$(echo "$tags" | tr ',' '\n')
|
||||
|
||||
for tag in $tags
|
||||
do
|
||||
for tag in $tags; do
|
||||
check_tag "$tag" "$entry"
|
||||
done
|
||||
}
|
||||
@@ -151,8 +144,7 @@ check_tags()
|
||||
# $2: (optional) "multi" - show values across multiple lines,
|
||||
# "dump" - show full hash values. Any other value results in the
|
||||
# options being displayed on a single line.
|
||||
show_array()
|
||||
{
|
||||
show_array() {
|
||||
local action="$1"
|
||||
local _array=("$@")
|
||||
_array=("${_array[@]:1}")
|
||||
@@ -167,27 +159,23 @@ show_array()
|
||||
|
||||
[ "$action" = "dump" ] && show_tags_header
|
||||
|
||||
for entry in "${_array[@]}"
|
||||
do
|
||||
for entry in "${_array[@]}"; do
|
||||
[ -z "$entry" ] && die "found empty entry"
|
||||
|
||||
tags=$(echo "$entry"|cut -s -d: -f1)
|
||||
elem=$(echo "$entry"|cut -s -d: -f2-)
|
||||
tags=$(echo "$entry" | cut -s -d: -f1)
|
||||
elem=$(echo "$entry" | cut -s -d: -f2-)
|
||||
|
||||
[ -z "$elem" ] && die "no option for entry '$entry'"
|
||||
|
||||
check_tags "$tags" "$entry"
|
||||
|
||||
if [ "$action" = "dump" ]
|
||||
then
|
||||
if [ "$action" = "dump" ]; then
|
||||
printf "%s\t\t%s\n" "$tags" "$elem"
|
||||
elif [ "$action" = "multi" ]
|
||||
then
|
||||
if [ $i -eq $size ]
|
||||
then
|
||||
elif [ "$action" = "multi" ]; then
|
||||
if [ $i -eq $size ]; then
|
||||
suffix=""
|
||||
else
|
||||
suffix=" \\"
|
||||
suffix=' \'
|
||||
fi
|
||||
|
||||
printf '%s%s\n' "$elem" "$suffix"
|
||||
@@ -202,8 +190,7 @@ show_array()
|
||||
[ "$one_line" = yes ] && echo
|
||||
}
|
||||
|
||||
generate_qemu_options()
|
||||
{
|
||||
generate_qemu_options() {
|
||||
#---------------------------------------------------------------------
|
||||
# Disabled options
|
||||
|
||||
@@ -255,10 +242,10 @@ generate_qemu_options()
|
||||
|
||||
# Disable TCG support
|
||||
case "$arch" in
|
||||
aarch64) ;;
|
||||
x86_64) qemu_options+=(size:--disable-tcg);;
|
||||
ppc64le) ;;
|
||||
esac
|
||||
aarch64) ;;
|
||||
x86_64) qemu_options+=(size:--disable-tcg) ;;
|
||||
ppc64le) ;;
|
||||
esac
|
||||
|
||||
# SECURITY: Don't build a static binary (lowers security)
|
||||
# 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.
|
||||
case "$arch" in
|
||||
aarch64) qemu_options+=(size:--disable-uuid)
|
||||
;;
|
||||
x86_64)
|
||||
qemu_options+=(size:--disable-uuid)
|
||||
qemu_options+=(size:--disable-debug-tcg)
|
||||
qemu_options+=(size:--disable-tcg-interpreter)
|
||||
;;
|
||||
ppc64le)
|
||||
qemu_options+=(size:--disable-debug-tcg)
|
||||
qemu_options+=(size:--disable-tcg-interpreter)
|
||||
;;
|
||||
esac
|
||||
aarch64)
|
||||
qemu_options+=(size:--disable-uuid)
|
||||
;;
|
||||
x86_64)
|
||||
qemu_options+=(size:--disable-uuid)
|
||||
qemu_options+=(size:--disable-debug-tcg)
|
||||
qemu_options+=(size:--disable-tcg-interpreter)
|
||||
;;
|
||||
ppc64le)
|
||||
qemu_options+=(size:--disable-debug-tcg)
|
||||
qemu_options+=(size:--disable-tcg-interpreter)
|
||||
;;
|
||||
esac
|
||||
qemu_options+=(size:--disable-qom-cast-debug)
|
||||
qemu_options+=(size:--disable-tcmalloc)
|
||||
|
||||
@@ -299,10 +287,10 @@ generate_qemu_options()
|
||||
|
||||
# Disable XEN driver
|
||||
case "$arch" in
|
||||
aarch64) ;;
|
||||
x86_64) qemu_options+=(size:--disable-xen);;
|
||||
ppc64le) qemu_options+=(size:--disable-xen);;
|
||||
esac
|
||||
aarch64) ;;
|
||||
x86_64) qemu_options+=(size:--disable-xen) ;;
|
||||
ppc64le) qemu_options+=(size:--disable-xen) ;;
|
||||
esac
|
||||
|
||||
# FIXME: why is this disabled?
|
||||
# (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.
|
||||
# (https://wiki.debian.org/Hardening)
|
||||
case "$arch" in
|
||||
aarch64) _qemu_cflags+=" -fPIC";;
|
||||
x86_64) _qemu_cflags+=" -fPIE";;
|
||||
ppc64le) _qemu_cflags+=" -fPIE";;
|
||||
aarch64) _qemu_cflags+=" -fPIC" ;;
|
||||
x86_64) _qemu_cflags+=" -fPIE" ;;
|
||||
ppc64le) _qemu_cflags+=" -fPIE" ;;
|
||||
esac
|
||||
|
||||
# Set compile options
|
||||
@@ -385,9 +373,9 @@ generate_qemu_options()
|
||||
# and take advantage of ASLR, making ROP attacks much harder to perform.
|
||||
# (https://wiki.debian.org/Hardening)
|
||||
case "$arch" in
|
||||
aarch64) ;;
|
||||
x86_64) [ -z "${static}" ] && _qemu_ldflags+=" -pie";;
|
||||
ppc64le) [ -z "${static}" ] && _qemu_ldflags+=" -pie";;
|
||||
aarch64) ;;
|
||||
x86_64) [ -z "${static}" ] && _qemu_ldflags+=" -pie" ;;
|
||||
ppc64le) [ -z "${static}" ] && _qemu_ldflags+=" -pie" ;;
|
||||
esac
|
||||
|
||||
# SECURITY: Disallow executing code on the stack.
|
||||
@@ -420,32 +408,30 @@ generate_qemu_options()
|
||||
}
|
||||
|
||||
# Entry point
|
||||
main()
|
||||
{
|
||||
main() {
|
||||
action=""
|
||||
|
||||
while getopts "dhms" opt
|
||||
do
|
||||
while getopts "dhms" opt; do
|
||||
case "$opt" in
|
||||
d)
|
||||
action="dump"
|
||||
;;
|
||||
d)
|
||||
action="dump"
|
||||
;;
|
||||
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
h)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
|
||||
m)
|
||||
action="multi"
|
||||
;;
|
||||
s)
|
||||
static="true"
|
||||
;;
|
||||
m)
|
||||
action="multi"
|
||||
;;
|
||||
s)
|
||||
static="true"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
shift $[$OPTIND-1]
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
[ -z "$1" ] && die "need hypervisor name"
|
||||
hypervisor="$1"
|
||||
@@ -456,23 +442,23 @@ main()
|
||||
local qemu_version_major=$(cut -d. -f1 "${qemu_version_file}")
|
||||
local qemu_version_minor=$(cut -d. -f2 "${qemu_version_file}")
|
||||
|
||||
[ -n "${qemu_version_major}" ] \
|
||||
|| die "cannot determine qemu major version from file $qemu_version_file"
|
||||
[ -n "${qemu_version_minor}" ] \
|
||||
|| die "cannot determine qemu minor version from file $qemu_version_file"
|
||||
[ -n "${qemu_version_major}" ] ||
|
||||
die "cannot determine qemu major version from file $qemu_version_file"
|
||||
[ -n "${qemu_version_minor}" ] ||
|
||||
die "cannot determine qemu minor version from file $qemu_version_file"
|
||||
|
||||
local gcc_version_major=$(gcc -dumpversion | cut -f1 -d.)
|
||||
local gcc_version_minor=$(gcc -dumpversion | cut -f2 -d.)
|
||||
|
||||
[ -n "${gcc_version_major}" ] \
|
||||
|| die "cannot determine gcc major version, please ensure it is installed"
|
||||
[ -n "${gcc_version_minor}" ] \
|
||||
|| die "cannot determine gcc minor version, please ensure it is installed"
|
||||
[ -n "${gcc_version_major}" ] ||
|
||||
die "cannot determine gcc major version, please ensure it is installed"
|
||||
[ -n "${gcc_version_minor}" ] ||
|
||||
die "cannot determine gcc minor version, please ensure it is installed"
|
||||
|
||||
# Generate qemu options
|
||||
generate_qemu_options
|
||||
|
||||
show_array "$action" "${qemu_options[@]}"
|
||||
show_array "$action" "${qemu_options[@]}"
|
||||
|
||||
exit 0
|
||||
}
|
||||
|
@@ -2,7 +2,7 @@ export GOPATH=${GOPATH:-${HOME}/go}
|
||||
readonly kata_arch_sh="${GOPATH}/src/github.com/kata-containers/tests/.ci/kata-arch.sh"
|
||||
hub_bin="hub-bin"
|
||||
|
||||
get_kata_arch(){
|
||||
get_kata_arch() {
|
||||
go get -u github.com/kata-containers/tests || true
|
||||
[ -f "${kata_arch_sh}" ] || die "Not found $kata_arch_sh"
|
||||
}
|
||||
@@ -11,7 +11,7 @@ install_yq() {
|
||||
GOPATH=${GOPATH:-${HOME}/go}
|
||||
local yq_path="${GOPATH}/bin/yq"
|
||||
local yq_pkg="github.com/mikefarah/yq"
|
||||
[ -x "${GOPATH}/bin/yq" ] && return
|
||||
[ -x "${GOPATH}/bin/yq" ] && return
|
||||
|
||||
get_kata_arch
|
||||
goarch=$("${kata_arch_sh}" -g)
|
||||
@@ -30,7 +30,7 @@ install_yq() {
|
||||
chmod +x "${yq_path}"
|
||||
}
|
||||
|
||||
get_from_kata_deps(){
|
||||
get_from_kata_deps() {
|
||||
local dependency="$1"
|
||||
local branch="${2:-master}"
|
||||
local runtime_repo="github.com/kata-containers/runtime"
|
||||
@@ -47,20 +47,20 @@ get_from_kata_deps(){
|
||||
}
|
||||
|
||||
die() {
|
||||
echo >&2 "ERROR: $*"
|
||||
exit 1
|
||||
echo >&2 "ERROR: $*"
|
||||
exit 1
|
||||
}
|
||||
|
||||
info() {
|
||||
echo >&2 "INFO: $*"
|
||||
echo >&2 "INFO: $*"
|
||||
}
|
||||
|
||||
get_repo_hash(){
|
||||
get_repo_hash() {
|
||||
local repo_dir=${1:-}
|
||||
[ -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
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
}
|
||||
|
||||
build_hub() {
|
||||
@@ -68,18 +68,17 @@ build_hub() {
|
||||
|
||||
if cmd=$(command -v hub); then
|
||||
hub_bin="${cmd}"
|
||||
return
|
||||
return
|
||||
else
|
||||
hub_bin="${tmp_dir:-/tmp}/hub-bin"
|
||||
fi
|
||||
|
||||
local hub_repo="github.com/github/hub"
|
||||
local hub_repo_dir="${GOPATH}/src/${hub_repo}"
|
||||
[ -d "${hub_repo_dir}" ]|| git clone --quiet --depth 1 "https://${hub_repo}.git" "${hub_repo_dir}"
|
||||
pushd "${hub_repo_dir}" >> /dev/null
|
||||
[ -d "${hub_repo_dir}" ] || git clone --quiet --depth 1 "https://${hub_repo}.git" "${hub_repo_dir}"
|
||||
pushd "${hub_repo_dir}" >>/dev/null
|
||||
git checkout master
|
||||
git pull
|
||||
./script/build -o "${hub_bin}"
|
||||
popd >> /dev/null
|
||||
popd >>/dev/null
|
||||
}
|
||||
|
||||
|
@@ -13,7 +13,7 @@ local arch_bios_url=""
|
||||
local arch_qemu_cpu="qemu64"
|
||||
local arch_qemu_machine="pc"
|
||||
local arch_qemu_extra_opts=""
|
||||
if [ "$(arch)" == "x86_64" ];then
|
||||
if [ "$(arch)" == "x86_64" ]; then
|
||||
arch_qemu_cpu="host"
|
||||
arch_qemu_machine="pc,accel=kvm"
|
||||
arch_qemu_extra_opts="-enable-kvm"
|
||||
|
@@ -5,12 +5,12 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
error(){
|
||||
error() {
|
||||
msg="$*"
|
||||
echo "ERROR: $msg" >&2
|
||||
}
|
||||
|
||||
die(){
|
||||
die() {
|
||||
error "$*"
|
||||
exit 1
|
||||
}
|
||||
@@ -46,7 +46,10 @@ setup_image() {
|
||||
img_url=$1
|
||||
img=$2
|
||||
[ -f "${img}" ] && return
|
||||
{ download "${img_url}" "$(dirname ${img})"; ret=$?; } || true
|
||||
{
|
||||
download "${img_url}" "$(dirname ${img})"
|
||||
ret=$?
|
||||
} || true
|
||||
[ ${ret} != 0 ] && rm -f "${img}" && return
|
||||
qemu-img resize "${img}" +5G
|
||||
}
|
||||
@@ -63,7 +66,7 @@ ping_vm() {
|
||||
timeout=$4
|
||||
minute=60
|
||||
sleeptime=10
|
||||
timeoutsec=$((timeout*minute))
|
||||
timeoutsec=$((timeout * minute))
|
||||
tries=$((timeoutsec/sleeptime))
|
||||
|
||||
for i in $(seq 1 ${tries}); do
|
||||
@@ -102,9 +105,9 @@ run_qemu() {
|
||||
fi
|
||||
|
||||
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)" \
|
||||
${img_opts} ${seed_opts} \
|
||||
-display none -vga none -daemonize ${extra_opts}
|
||||
-net nic,model=virtio -device virtio-rng-pci -net user,hostfwd=tcp:${ip}:${port}-:22,dnssearch="$(get_dnssearch)" \
|
||||
${img_opts} ${seed_opts} \
|
||||
-display none -vga none -daemonize ${extra_opts}
|
||||
[ $? != 0 ] && return 1
|
||||
|
||||
# depending of the host's hw, it takes for around ~15 minutes
|
||||
|
@@ -12,28 +12,28 @@ set -x -e
|
||||
|
||||
sudo apt-get update -y
|
||||
sudo apt-get install -y \
|
||||
build-essential \
|
||||
cpio \
|
||||
docker.io \
|
||||
golang-go \
|
||||
libattr1-dev \
|
||||
libcap-dev \
|
||||
libcap-ng-dev \
|
||||
libdw-dev \
|
||||
libelf-dev \
|
||||
libfdt-dev \
|
||||
libglib2.0-dev \
|
||||
libiberty-dev \
|
||||
libnewt-dev \
|
||||
libpci-dev \
|
||||
libpixman-1-dev \
|
||||
librbd-dev \
|
||||
libssl-dev \
|
||||
libz-dev \
|
||||
openssl \
|
||||
python \
|
||||
snapcraft \
|
||||
snapd
|
||||
build-essential \
|
||||
cpio \
|
||||
docker.io \
|
||||
golang-go \
|
||||
libattr1-dev \
|
||||
libcap-dev \
|
||||
libcap-ng-dev \
|
||||
libdw-dev \
|
||||
libelf-dev \
|
||||
libfdt-dev \
|
||||
libglib2.0-dev \
|
||||
libiberty-dev \
|
||||
libnewt-dev \
|
||||
libpci-dev \
|
||||
libpixman-1-dev \
|
||||
librbd-dev \
|
||||
libssl-dev \
|
||||
libz-dev \
|
||||
openssl \
|
||||
python \
|
||||
snapcraft \
|
||||
snapd
|
||||
|
||||
# start docker
|
||||
sudo systemctl start docker
|
||||
|
@@ -23,7 +23,7 @@ scp="scp -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o Identiti
|
||||
gen_seed() {
|
||||
rm -f "${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
|
||||
apt_proxy="apt:\n https_proxy: ${https_proxy}\n proxy: ${http_proxy}"
|
||||
@@ -38,7 +38,7 @@ gen_seed() {
|
||||
|
||||
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})"
|
||||
|
||||
sed \
|
||||
@@ -48,9 +48,9 @@ gen_seed() {
|
||||
-e "s|@DOCKER_ENV@|""${docker_env}""|g" \
|
||||
-e "s|@DOCKER_DNS@|""${docker_dns}""|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() {
|
||||
@@ -77,13 +77,13 @@ build_arch() {
|
||||
|
||||
# run QEMU
|
||||
run_qemu "${arch_qemu}" \
|
||||
"${arch_qemu_cpu}" \
|
||||
"${arch_qemu_machine}" \
|
||||
"${ip}" \
|
||||
"${port}" \
|
||||
"${arch_image}" \
|
||||
"${seed_img}" \
|
||||
"${arch_qemu_extra_opts}"
|
||||
"${arch_qemu_cpu}" \
|
||||
"${arch_qemu_machine}" \
|
||||
"${ip}" \
|
||||
"${port}" \
|
||||
"${arch_image}" \
|
||||
"${seed_img}" \
|
||||
"${arch_qemu_extra_opts}"
|
||||
|
||||
# copy snap script to VM
|
||||
${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"
|
||||
|
||||
# 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
|
||||
${ssh} "${ip}" -p "${port}" sudo poweroff
|
||||
}
|
||||
|
||||
help()
|
||||
{
|
||||
usage=$(cat << EOF
|
||||
help() {
|
||||
usage=$(
|
||||
cat <<EOF
|
||||
Usage: $0 [-h] [options]
|
||||
Description:
|
||||
Build snap images.
|
||||
@@ -109,9 +109,12 @@ Usage: $0 [-h] [options]
|
||||
-h, Show this help text and exit.
|
||||
|
||||
Supported architectures:
|
||||
$(IFS=$'\t'; echo -e "${supported_archs[*]}")
|
||||
$(
|
||||
IFS=$'\t'
|
||||
echo -e "${supported_archs[*]}"
|
||||
)
|
||||
EOF
|
||||
)
|
||||
)
|
||||
echo "$usage"
|
||||
}
|
||||
|
||||
@@ -121,20 +124,20 @@ main() {
|
||||
while getopts "a:h" opt; do
|
||||
case ${opt} in
|
||||
a)
|
||||
arch="${OPTARG}"
|
||||
;;
|
||||
arch="${OPTARG}"
|
||||
;;
|
||||
h)
|
||||
help
|
||||
exit 0;
|
||||
;;
|
||||
help
|
||||
exit 0
|
||||
;;
|
||||
?)
|
||||
# parse failure
|
||||
help
|
||||
die "Failed to parse arguments"
|
||||
;;
|
||||
# parse failure
|
||||
help
|
||||
die "Failed to parse arguments"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $((OPTIND-1))
|
||||
shift $((OPTIND - 1))
|
||||
|
||||
[ -z "${arch}" ] && help && die "Mandatory architecture not supplied"
|
||||
if ! [[ " ${supported_archs[@]} " =~ " ${arch} " ]]; then
|
||||
@@ -145,10 +148,10 @@ main() {
|
||||
gen_seed
|
||||
|
||||
if [ "${arch}" != "all" ]; then
|
||||
build_arch "${arch}" &> "${arch}.log"
|
||||
build_arch "${arch}" &>"${arch}.log"
|
||||
else
|
||||
for a in ${supported_archs[@]}; do
|
||||
(build_arch "${a}" &> "${a}.log") &
|
||||
(build_arch "${a}" &>"${a}.log") &
|
||||
done
|
||||
wait
|
||||
fi
|
||||
|
@@ -8,7 +8,7 @@ set -o errexit
|
||||
set -o nounset
|
||||
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"
|
||||
|
||||
@@ -23,11 +23,10 @@ if [ -z "$qemu_repo" ]; then
|
||||
[ -n "$qemu_url" ] || die "failed to get qemu url"
|
||||
qemu_repo="${qemu_url}.git"
|
||||
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" ] || die "failed to get qemu version"
|
||||
[ -n "$qemu_version" ] || die "failed to get qemu version"
|
||||
|
||||
info "Build ${qemu_repo} version: ${qemu_version}"
|
||||
|
||||
|
Reference in New Issue
Block a user