mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-09-20 16:27:52 +00:00
format: use shfmt to format sh files.
Use shfmt to format all the sh file. https://github.com/mvdan/sh Signed-off-by: Jose Carlos Venegas Munoz <jose.carlos.venegas.munoz@intel.com>
This commit is contained in:
@@ -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}
|
||||||
|
@@ -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:-}"
|
||||||
|
|
||||||
|
@@ -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}')
|
||||||
|
@@ -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,7 +29,6 @@ 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() {
|
||||||
@@ -87,12 +84,14 @@ 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}"
|
||||||
|
@@ -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,20 +101,18 @@ 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
|
||||||
|
|
||||||
@@ -132,8 +124,7 @@ function changelog_update {
|
|||||||
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"
|
||||||
|
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 ;;
|
*) break ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function build_pkg()
|
function build_pkg() {
|
||||||
{
|
|
||||||
|
|
||||||
obs_repository="${1}"
|
obs_repository="${1}"
|
||||||
|
|
||||||
@@ -243,7 +260,7 @@ 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"
|
||||||
@@ -256,7 +273,7 @@ function generate_files () {
|
|||||||
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}@"
|
||||||
|
@@ -136,7 +136,7 @@ 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:-""}
|
||||||
|
|
||||||
|
@@ -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
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -125,15 +124,14 @@ 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:-}
|
||||||
|
@@ -48,16 +48,14 @@ 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:
|
||||||
|
|
||||||
@@ -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
|
||||||
@@ -98,8 +95,7 @@ EOT
|
|||||||
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,8 +118,7 @@ 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"
|
||||||
|
|
||||||
@@ -133,8 +127,7 @@ check_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,8 +159,7 @@ 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)
|
||||||
@@ -178,16 +169,13 @@ show_array()
|
|||||||
|
|
||||||
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
|
||||||
|
|
||||||
@@ -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)
|
||||||
@@ -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
|
||||||
|
@@ -82,4 +82,3 @@ build_hub() {
|
|||||||
./script/build -o "${hub_bin}"
|
./script/build -o "${hub_bin}"
|
||||||
popd >>/dev/null
|
popd >>/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -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
|
||||||
}
|
}
|
||||||
|
@@ -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,7 +109,10 @@ 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
|
||||||
|
@@ -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