mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-04 02:14:29 +00:00
Merge pull request #138 from jcvenegas/shfmt
format: use shfmt to format sh files.
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
@@ -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}
|
||||||
|
@@ -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
|
||||||
|
@@ -13,7 +13,7 @@ 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
|
||||||
|
|
||||||
|
@@ -20,7 +20,7 @@ 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]
|
||||||
|
@@ -7,4 +7,3 @@ 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
|
||||||
|
|
||||||
|
@@ -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:-}"
|
||||||
|
|
||||||
|
@@ -1 +1 @@
|
|||||||
8
|
9
|
||||||
|
@@ -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}" \
|
||||||
|
@@ -15,12 +15,12 @@ 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
|
||||||
|
|
||||||
@@ -31,7 +31,6 @@ gen_version_file(){
|
|||||||
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}"
|
||||||
|
@@ -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,11 +29,10 @@ 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}" \
|
||||||
@@ -46,7 +43,7 @@ build_initrd(){
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
build_image(){
|
build_image() {
|
||||||
sudo -E PATH="${PATH}" make image \
|
sudo -E PATH="${PATH}" make image \
|
||||||
DISTRO="${img_distro}" \
|
DISTRO="${img_distro}" \
|
||||||
DEBUG="${DEBUG:-}" \
|
DEBUG="${DEBUG:-}" \
|
||||||
@@ -55,7 +52,7 @@ build_image(){
|
|||||||
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}"
|
||||||
|
@@ -42,8 +42,8 @@ function check_image() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
replace_list=(
|
replace_list=(
|
||||||
"VERSION=$VERSION"
|
"VERSION=$VERSION"
|
||||||
"RELEASE=$RELEASE"
|
"RELEASE=$RELEASE"
|
||||||
)
|
)
|
||||||
|
|
||||||
verify
|
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
|
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
|
||||||
|
@@ -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
|
||||||
|
@@ -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
|
||||||
|
@@ -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."
|
||||||
|
@@ -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
|
||||||
|
@@ -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}"
|
||||||
|
|
||||||
|
@@ -33,8 +33,7 @@ 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
|
||||||
|
|
||||||
@@ -68,21 +67,18 @@ function display_help()
|
|||||||
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.
|
||||||
|
|
||||||
@@ -95,11 +91,9 @@ function verify()
|
|||||||
info "OK"
|
info "OK"
|
||||||
}
|
}
|
||||||
|
|
||||||
function clean()
|
function clean() {
|
||||||
{
|
|
||||||
# This function clean generated files
|
# This function clean generated files
|
||||||
for file in "$@"
|
for file in "$@"; do
|
||||||
do
|
|
||||||
[ -e $file ] && rm -v $file
|
[ -e $file ] && rm -v $file
|
||||||
done
|
done
|
||||||
[ -e ./debian.changelog ] && git checkout ./debian.changelog
|
[ -e ./debian.changelog ] && git checkout ./debian.changelog
|
||||||
@@ -107,33 +101,30 @@ function clean()
|
|||||||
echo "Clean done."
|
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
|
||||||
|
|
||||||
@@ -143,17 +134,14 @@ function local_build()
|
|||||||
[ "$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.* ]]
|
if [[ $distro =~ ^Fedora.* ]] || [[ $distro =~ ^CentOS.* ]]; 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 *.spec | tee ${LOG_DIR}/${distro}_${PKG_NAME}_build.log
|
${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
|
||||||
@@ -161,11 +149,9 @@ function local_build()
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkout_repo()
|
function checkout_repo() {
|
||||||
{
|
|
||||||
local REPO="${1}"
|
local REPO="${1}"
|
||||||
if [ -z "${OBS_WORKDIR:-}" ]
|
if [ -z "${OBS_WORKDIR:-}" ]; then
|
||||||
then
|
|
||||||
OBS_WORKDIR=$(mktemp -d -u -t obs-repo.XXXXXXXXXXX) || exit 1
|
OBS_WORKDIR=$(mktemp -d -u -t obs-repo.XXXXXXXXXXX) || exit 1
|
||||||
osc co "${REPO}" -o "${OBS_WORKDIR}"
|
osc co "${REPO}" -o "${OBS_WORKDIR}"
|
||||||
fi
|
fi
|
||||||
@@ -175,38 +161,69 @@ function checkout_repo()
|
|||||||
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
|
||||||
@@ -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)
|
||||||
|
@@ -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
|
||||||
|
@@ -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,17 +107,17 @@ 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"
|
||||||
@@ -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
|
||||||
|
@@ -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,7 +86,7 @@ $(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
|
||||||
@@ -95,7 +94,7 @@ EOT
|
|||||||
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
|
||||||
@@ -105,10 +104,10 @@ EOT
|
|||||||
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
|
||||||
|
@@ -9,18 +9,18 @@ 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" ]
|
||||||
@@ -31,15 +31,15 @@ output_should_contain(){
|
|||||||
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"
|
||||||
|
@@ -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
|
||||||
|
|
||||||
@@ -256,7 +243,7 @@ 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
|
||||||
|
|
||||||
@@ -272,7 +259,8 @@ 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)
|
x86_64)
|
||||||
qemu_options+=(size:--disable-uuid)
|
qemu_options+=(size:--disable-uuid)
|
||||||
@@ -300,8 +288,8 @@ 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?
|
||||||
@@ -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
|
||||||
@@ -386,8 +374,8 @@ generate_qemu_options()
|
|||||||
# (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,12 +408,10 @@ 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"
|
||||||
@@ -445,7 +431,7 @@ main()
|
|||||||
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,18 +442,18 @@ 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
|
||||||
|
@@ -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"
|
||||||
}
|
}
|
||||||
@@ -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"
|
||||||
@@ -55,12 +55,12 @@ 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() {
|
||||||
@@ -75,11 +75,10 @@ build_hub() {
|
|||||||
|
|
||||||
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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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"
|
||||||
|
@@ -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
|
||||||
|
@@ -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,7 +48,7 @@ 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 ::
|
||||||
}
|
}
|
||||||
@@ -98,9 +98,9 @@ build_arch() {
|
|||||||
${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"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -125,7 +128,7 @@ main() {
|
|||||||
;;
|
;;
|
||||||
h)
|
h)
|
||||||
help
|
help
|
||||||
exit 0;
|
exit 0
|
||||||
;;
|
;;
|
||||||
?)
|
?)
|
||||||
# parse failure
|
# parse failure
|
||||||
@@ -134,7 +137,7 @@ main() {
|
|||||||
;;
|
;;
|
||||||
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
|
||||||
|
@@ -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"
|
||||||
|
|
||||||
@@ -25,7 +25,6 @@ if [ -z "$qemu_repo" ]; then
|
|||||||
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"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user