scripts: Change here document delimiters

Fix the outstanding scripts using non standard shell here document delimiters.

This should have been caught by
https://github.com/kata-containers/tests/pull/3937, but there is a bug
in the checker which is fixed on
https://github.com/kata-containers/tests/pull/4569.

Fixes: #3864.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
This commit is contained in:
James O. D. Hunt 2022-03-10 09:23:37 +00:00
parent 5a7fd943c1
commit 5d6d39be48
18 changed files with 60 additions and 60 deletions

View File

@ -7,14 +7,14 @@
# // # //
die() { die() {
cat <<EOT >&2 cat <<EOF >&2
==================================================================== ====================================================================
==== compile protocols failed ==== ==== compile protocols failed ====
$1 $1
==================================================================== ====================================================================
EOT EOF
exit 1 exit 1
} }

View File

@ -72,7 +72,7 @@ readonly mem_boundary_mb=128
source "${lib_file}" source "${lib_file}"
usage() { usage() {
cat <<EOT cat <<EOF
Usage: ${script_name} [options] <rootfs-dir> Usage: ${script_name} [options] <rootfs-dir>
This script will create a Kata Containers image file of This script will create a Kata Containers image file of
an adequate size based on the <rootfs-dir> directory. an adequate size based on the <rootfs-dir> directory.
@ -117,7 +117,7 @@ Kernels and hypervisors that support DAX/NVDIMM read the MBR #2, otherwise MBR #
[1] - https://github.com/kata-containers/kata-containers/blob/main/tools/osbuilder/image-builder/nsdax.gpl.c [1] - https://github.com/kata-containers/kata-containers/blob/main/tools/osbuilder/image-builder/nsdax.gpl.c
[2] - https://github.com/torvalds/linux/blob/master/drivers/nvdimm/pfn.h [2] - https://github.com/torvalds/linux/blob/master/drivers/nvdimm/pfn.h
EOT EOF
} }

View File

@ -23,7 +23,7 @@ AGENT_INIT=${AGENT_INIT:-no}
usage() usage()
{ {
error="${1:-0}" error="${1:-0}"
cat <<EOT cat <<EOF
Usage: ${script_name} [options] <rootfs-dir> Usage: ${script_name} [options] <rootfs-dir>
This script creates a Kata Containers initrd image file based on the This script creates a Kata Containers initrd image file based on the
<rootfs-dir> directory. <rootfs-dir> directory.
@ -38,7 +38,7 @@ Extra environment variables:
DEFAULT: kata-agent DEFAULT: kata-agent
AGENT_INIT: use kata agent as init process AGENT_INIT: use kata agent as init process
DEFAULT: no DEFAULT: no
EOT EOF
exit "${error}" exit "${error}"
} }

View File

@ -63,7 +63,7 @@ typeset init=
usage() usage()
{ {
error="${1:-0}" error="${1:-0}"
cat <<EOT cat <<EOF
Usage: ${script_name} [options] [DISTRO] Usage: ${script_name} [options] [DISTRO]
@ -143,7 +143,7 @@ Refer to the Platform-OS Compatibility Matrix for more details on the supported
architectures: architectures:
https://github.com/kata-containers/kata-containers/tree/main/tools/osbuilder#platform-distro-compatibility-matrix https://github.com/kata-containers/kata-containers/tree/main/tools/osbuilder#platform-distro-compatibility-matrix
EOT EOF
exit "${error}" exit "${error}"
} }
@ -473,7 +473,7 @@ setup_rootfs()
local unitFile="./etc/systemd/system/tmp.mount" local unitFile="./etc/systemd/system/tmp.mount"
info "Install tmp.mount in ./etc/systemd/system" info "Install tmp.mount in ./etc/systemd/system"
mkdir -p `dirname "$unitFile"` mkdir -p `dirname "$unitFile"`
cp ./usr/share/systemd/tmp.mount "$unitFile" || cat > "$unitFile" << EOT cp ./usr/share/systemd/tmp.mount "$unitFile" || cat > "$unitFile" << EOF
# This file is part of systemd. # This file is part of systemd.
# #
# systemd is free software; you can redistribute it and/or modify it # systemd is free software; you can redistribute it and/or modify it
@ -496,7 +496,7 @@ What=tmpfs
Where=/tmp Where=/tmp
Type=tmpfs Type=tmpfs
Options=mode=1777,strictatime,nosuid,nodev Options=mode=1777,strictatime,nosuid,nodev
EOT EOF
fi fi
popd >> /dev/null popd >> /dev/null
@ -519,12 +519,12 @@ EOT
esac esac
info "Configure chrony file ${chrony_conf_file}" info "Configure chrony file ${chrony_conf_file}"
cat >> "${chrony_conf_file}" <<EOT cat >> "${chrony_conf_file}" <<EOF
refclock PHC /dev/ptp0 poll 3 dpoll -2 offset 0 refclock PHC /dev/ptp0 poll 3 dpoll -2 offset 0
# Step the system clock instead of slewing it if the adjustment is larger than # Step the system clock instead of slewing it if the adjustment is larger than
# one second, at any time # one second, at any time
makestep 1 -1 makestep 1 -1
EOT EOF
# Comment out ntp sources for chrony to be extra careful # Comment out ntp sources for chrony to be extra careful
# Reference: https://chrony.tuxfamily.org/doc/3.4/chrony.conf.html # Reference: https://chrony.tuxfamily.org/doc/3.4/chrony.conf.html

View File

@ -168,7 +168,7 @@ create_summary_file()
local -r agentdir="${script_dir}/../../../" local -r agentdir="${script_dir}/../../../"
local -r agent_version=$(cat ${agentdir}/VERSION) local -r agent_version=$(cat ${agentdir}/VERSION)
cat >"$file"<<-EOT cat >"$file"<<-EOF
--- ---
osbuilder: osbuilder:
url: "${osbuilder_url}" url: "${osbuilder_url}"
@ -190,7 +190,7 @@ ${extra}
name: "${AGENT_BIN}" name: "${AGENT_BIN}"
version: "${agent_version}" version: "${agent_version}"
agent-is-init-daemon: "${AGENT_INIT}" agent-is-init-daemon: "${AGENT_INIT}"
EOT EOF
local rootfs_file="${file_dir}/$(basename "${file}")" local rootfs_file="${file_dir}/$(basename "${file}")"
info "Created summary file '${rootfs_file}' inside rootfs" info "Created summary file '${rootfs_file}' inside rootfs"

View File

@ -53,7 +53,7 @@ source "${project_dir}/scripts/lib.sh"
usage() usage()
{ {
cat <<EOT cat <<EOF
Usage: $script_name [options] [command | <distro>] Usage: $script_name [options] [command | <distro>]
Options: Options:
@ -72,7 +72,7 @@ Otherwise, tests are run on all distros.
$(basename ${test_config}) includes a list of distros to exclude from testing, $(basename ${test_config}) includes a list of distros to exclude from testing,
depending on the detected test environment. However, when a <distro> is specified, depending on the detected test environment. However, when a <distro> is specified,
distro exclusion based on $(basename ${test_config}) is not enforced. distro exclusion based on $(basename ${test_config}) is not enforced.
EOT EOF
} }
# Add an entry to the specified stats file # Add an entry to the specified stats file

View File

@ -59,7 +59,7 @@ build_image() {
usage() { usage() {
return_code=${1:-0} return_code=${1:-0}
cat <<EOT cat <<EOF
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.
@ -70,7 +70,7 @@ Options:
--imagetype=${image_type} --imagetype=${image_type}
--prefix=${prefix} --prefix=${prefix}
--destdir=${destdir} --destdir=${destdir}
EOT EOF
exit "${return_code}" exit "${return_code}"
} }

View File

@ -50,7 +50,7 @@ error() {
usage() { usage() {
return_code=${1:-0} return_code=${1:-0}
cat <<EOT cat <<EOF
This script is used as part of the ${project} release process. This script is used as part of the ${project} release process.
It is used to create a tarball with static binaries. It is used to create a tarball with static binaries.
@ -74,7 +74,7 @@ options:
rootfs-image rootfs-image
rootfs-initrd rootfs-initrd
shim-v2 shim-v2
EOT EOF
exit "${return_code}" exit "${return_code}"
} }

View File

@ -94,10 +94,10 @@ function configure_different_shims_base() {
fi fi
fi fi
cat << EOT | tee "$shim_file" cat << EOF | tee "$shim_file"
#!/usr/bin/env bash #!/usr/bin/env bash
KATA_CONF_FILE=/opt/kata/share/defaults/kata-containers/configuration-${shim}.toml /opt/kata/bin/containerd-shim-kata-v2 "\$@" KATA_CONF_FILE=/opt/kata/share/defaults/kata-containers/configuration-${shim}.toml /opt/kata/bin/containerd-shim-kata-v2 "\$@"
EOT EOF
chmod +x "$shim_file" chmod +x "$shim_file"
if [ "${shim}" == "${default_shim}" ]; then if [ "${shim}" == "${default_shim}" ]; then
@ -132,7 +132,7 @@ function configure_crio_runtime() {
local kata_path="/usr/local/bin/containerd-shim-${runtime}-v2" local kata_path="/usr/local/bin/containerd-shim-${runtime}-v2"
local kata_conf="crio.runtime.runtimes.${runtime}" local kata_conf="crio.runtime.runtimes.${runtime}"
cat <<EOT | tee -a "$crio_drop_in_conf_file" cat <<EOF | tee -a "$crio_drop_in_conf_file"
# Path to the Kata Containers runtime binary that uses the $1 # Path to the Kata Containers runtime binary that uses the $1
[$kata_conf] [$kata_conf]
@ -140,7 +140,7 @@ function configure_crio_runtime() {
runtime_type = "vm" runtime_type = "vm"
runtime_root = "/run/vc" runtime_root = "/run/vc"
privileged_without_host_devices = true privileged_without_host_devices = true
EOT EOF
} }
function configure_crio() { function configure_crio() {
@ -178,22 +178,22 @@ function configure_containerd_runtime() {
echo "Configuration exists for $runtime_table, overwriting" echo "Configuration exists for $runtime_table, overwriting"
sed -i "/\[$runtime_table\]/,+1s#runtime_type.*#runtime_type = \"${runtime_type}\"#" $containerd_conf_file sed -i "/\[$runtime_table\]/,+1s#runtime_type.*#runtime_type = \"${runtime_type}\"#" $containerd_conf_file
else else
cat <<EOT | tee -a "$containerd_conf_file" cat <<EOF | tee -a "$containerd_conf_file"
[$runtime_table] [$runtime_table]
runtime_type = "${runtime_type}" runtime_type = "${runtime_type}"
privileged_without_host_devices = true privileged_without_host_devices = true
pod_annotations = ["io.katacontainers.*"] pod_annotations = ["io.katacontainers.*"]
EOT EOF
fi fi
if grep -q "\[$options_table\]" $containerd_conf_file; then if grep -q "\[$options_table\]" $containerd_conf_file; then
echo "Configuration exists for $options_table, overwriting" echo "Configuration exists for $options_table, overwriting"
sed -i "/\[$options_table\]/,+1s#ConfigPath.*#ConfigPath = \"${config_path}\"#" $containerd_conf_file sed -i "/\[$options_table\]/,+1s#ConfigPath.*#ConfigPath = \"${config_path}\"#" $containerd_conf_file
else else
cat <<EOT | tee -a "$containerd_conf_file" cat <<EOF | tee -a "$containerd_conf_file"
[$options_table] [$options_table]
ConfigPath = "${config_path}" ConfigPath = "${config_path}"
EOT EOF
fi fi
} }

View File

@ -65,7 +65,7 @@ source "${packaging_scripts_dir}/lib.sh"
usage() { usage() {
exit_code="$1" exit_code="$1"
cat <<EOT cat <<EOF
Overview: Overview:
Build a kernel for Kata Containers Build a kernel for Kata Containers
@ -99,7 +99,7 @@ Options:
-t <hypervisor> : Hypervisor_target. -t <hypervisor> : Hypervisor_target.
-v <version> : Kernel version to use if kernel path not provided. -v <version> : Kernel version to use if kernel path not provided.
-x <type> : Confidential guest protection type, such as sev and tdx -x <type> : Confidential guest protection type, such as sev and tdx
EOT EOF
exit "$exit_code" exit "$exit_code"
} }

View File

@ -28,7 +28,7 @@ die() {
usage() { usage() {
return_code=${1:-0} return_code=${1:-0}
cat <<EOT cat <<EOF
Usage: Usage:
${script_name} [options] <version> ${script_name} [options] <version>
@ -41,7 +41,7 @@ options:
-h : show this help -h : show this help
-p : push image to github -p : push image to github
EOT EOF
exit "${return_code}" exit "${return_code}"
} }

View File

@ -26,7 +26,7 @@ trap exit_handler EXIT
usage() { usage() {
return_code=${1:-} return_code=${1:-}
cat <<EOT cat <<EOF
Usage ${script_name} <previous-release> <new_release> Usage ${script_name} <previous-release> <new_release>
Args: Args:
@ -37,7 +37,7 @@ new-release: new release version that will have the
Example: Example:
./${script_name} 1.2.0 1.2.1 > notes.md ./${script_name} 1.2.0 1.2.1 > notes.md
EOT EOF
exit "${return_code}" exit "${return_code}"
} }
@ -81,25 +81,25 @@ changes() {
} }
print_release_notes() { print_release_notes() {
cat <<EOT cat <<EOF
# Release ${runtime_version} # Release ${runtime_version}
EOT EOF
for repo in "${repos[@]}"; do for repo in "${repos[@]}"; do
git clone -q "https://github.com/${project}/${repo}.git" "${tmp_dir}/${repo}" git clone -q "https://github.com/${project}/${repo}.git" "${tmp_dir}/${repo}"
pushd "${tmp_dir}/${repo}" >>/dev/null pushd "${tmp_dir}/${repo}" >>/dev/null
cat <<EOT cat <<EOF
## ${repo} Changes ## ${repo} Changes
$(changes) $(changes)
EOT EOF
popd >>/dev/null popd >>/dev/null
rm -rf "${tmp_dir}/${repo}" rm -rf "${tmp_dir}/${repo}"
done done
cat <<EOT cat <<EOF
## Compatibility with CRI-O ## Compatibility with CRI-O
Kata Containers ${runtime_version} is compatible with CRI-O ${crio_version} Kata Containers ${runtime_version} is compatible with CRI-O ${crio_version}
@ -157,7 +157,7 @@ More information [Limitations][limitations]
[custom-agent-doc]: https://github.com/kata-containers/kata-containers/blob/main/docs/Developer-Guide.md#build-a-custom-kata-agent---optional [custom-agent-doc]: https://github.com/kata-containers/kata-containers/blob/main/docs/Developer-Guide.md#build-a-custom-kata-agent---optional
[limitations]: https://github.com/kata-containers/kata-containers/blob/${new_release}/docs/Limitations.md [limitations]: https://github.com/kata-containers/kata-containers/blob/${new_release}/docs/Limitations.md
[installation]: https://github.com/kata-containers/kata-containers/blob/${new_release}/docs/install [installation]: https://github.com/kata-containers/kata-containers/blob/${new_release}/docs/install
EOT EOF
} }
main() { main() {

View File

@ -27,16 +27,16 @@ source "${script_dir}/../scripts/lib.sh"
function usage() { function usage() {
cat <<EOT cat <<EOF
Usage: ${script_name} [options] <args> Usage: ${script_name} [options] <args>
This script creates a new release for ${PROJECT}. This script creates a new release for ${PROJECT}.
It tags and create release for: It tags and create release for:
EOT EOF
for r in "${repos[@]}"; do for r in "${repos[@]}"; do
echo " - ${r}" echo " - ${r}"
done done
cat <<EOT cat <<EOF
Args: Args:
status : Get Current ${PROJECT} tags status status : Get Current ${PROJECT} tags status
@ -48,7 +48,7 @@ Options:
-h : Show this help -h : Show this help
-p : push tags -p : push tags
EOT EOF
} }

View File

@ -223,12 +223,12 @@ bump_repo() {
info "Creating PR message" info "Creating PR message"
notes_file=notes.md notes_file=notes.md
cat <<EOT >"${notes_file}" cat <<EOF >"${notes_file}"
# Kata Containers ${new_version} # Kata Containers ${new_version}
$(get_changes "$current_version") $(get_changes "$current_version")
EOT EOF
cat "${notes_file}" cat "${notes_file}"
if (echo "${current_version}" | grep "alpha") && (echo "${new_version}" | grep -v "alpha");then if (echo "${current_version}" | grep "alpha") && (echo "${new_version}" | grep -v "alpha");then
@ -282,7 +282,7 @@ EOT
usage() { usage() {
exit_code="$1" exit_code="$1"
cat <<EOT cat <<EOF
Usage: Usage:
${script_name} [options] <args> ${script_name} [options] <args>
Args: Args:
@ -293,7 +293,7 @@ Example:
Options Options
-h : Show this help -h : Show this help
-p : create a PR -p : create a PR
EOT EOF
exit "$exit_code" exit "$exit_code"
} }

View File

@ -12,7 +12,7 @@ script_dir="$(realpath $(dirname $0))"
patches_dir="$1" patches_dir="$1"
if [ -z "$patches_dir" ]; then if [ -z "$patches_dir" ]; then
cat <<-EOT cat <<-EOF
Apply patches to the sources at the current directory. Apply patches to the sources at the current directory.
Patches are expected to be named in the standard git-format-patch(1) format where Patches are expected to be named in the standard git-format-patch(1) format where
@ -30,7 +30,7 @@ if [ -z "$patches_dir" ]; then
$0 PATCHES_DIR $0 PATCHES_DIR
Where: Where:
PATCHES_DIR is the directory containing the patches PATCHES_DIR is the directory containing the patches
EOT EOF
exit 1 exit 1
fi fi

View File

@ -72,7 +72,7 @@ die() {
# Display usage to stdout. # Display usage to stdout.
usage() { usage() {
cat <<EOT cat <<EOF
Overview: Overview:
Display configure options required to build the specified Display configure options required to build the specified
@ -94,7 +94,7 @@ Example:
$ $script_name qemu $ $script_name qemu
EOT EOF
} }
show_tags_header() { show_tags_header() {
@ -102,10 +102,10 @@ show_tags_header() {
local key local key
local value local value
cat <<EOT cat <<EOF
# Recognised option tags: # Recognised option tags:
# #
EOT EOF
# sort the tags # sort the tags
keys=${!recognised_tags[@]} keys=${!recognised_tags[@]}

View File

@ -55,7 +55,7 @@ gen_version_file() {
# see https://github.com/semver/semver/issues/145 # see https://github.com/semver/semver/issues/145
kata_version=$(get_kata_version) kata_version=$(get_kata_version)
kata_version=${kata_version/-/\~} kata_version=${kata_version/-/\~}
cat > "$versions_txt" <<EOT cat > "$versions_txt" <<EOF
# This is a generated file from ${script_name} # This is a generated file from ${script_name}
kata_version=${kata_version} kata_version=${kata_version}
@ -70,7 +70,7 @@ kernel_version=${kernel_version}
# Golang # Golang
go_version=${golang_version} go_version=${golang_version}
EOT EOF
} }
die() { die() {
@ -85,7 +85,7 @@ die() {
usage() { usage() {
exit_code=$"${1:-0}" exit_code=$"${1:-0}"
cat <<EOT cat <<EOF
Usage: Usage:
${script_name} [--compare | -h | --help] <kata-branch> ${script_name} [--compare | -h | --help] <kata-branch>
@ -98,7 +98,7 @@ Options:
--compare Only compare the kata version at branch <kata-branch> with the --compare Only compare the kata version at branch <kata-branch> with the
one in ${versions_txt} and leave the file untouched. one in ${versions_txt} and leave the file untouched.
--head Use <kata-branch>'s head to generate the versions file. --head Use <kata-branch>'s head to generate the versions file.
EOT EOF
exit "${exit_code}" exit "${exit_code}"
} }

View File

@ -31,7 +31,7 @@ info() {
usage(){ usage(){
exit_code="$1" exit_code="$1"
cat <<EOT cat <<EOF
Usage: Usage:
${script_name} [options] ${script_name} [options]
@ -43,7 +43,7 @@ Options
-d <path> : destination path, path where go will be installed. -d <path> : destination path, path where go will be installed.
-f : enable force install, remove existent go pkg before installation. -f : enable force install, remove existent go pkg before installation.
-h : display this help. -h : display this help.
EOT EOF
exit "$exit_code" exit "$exit_code"
} }