Skip to content

Commit

Permalink
scripts: Change here document delimiters
Browse files Browse the repository at this point in the history
Fix the outstanding scripts using non standard shell here document delimiters.

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

Fixes: #3864.

Signed-off-by: James O. D. Hunt <james.o.hunt@intel.com>
  • Loading branch information
jodh-intel committed Mar 10, 2022
1 parent 5a7fd94 commit 5d6d39b
Show file tree
Hide file tree
Showing 18 changed files with 60 additions and 60 deletions.
4 changes: 2 additions & 2 deletions src/libs/protocols/hack/update-generated-proto.sh
Expand Up @@ -7,14 +7,14 @@
# //

die() {
cat <<EOT >&2
cat <<EOF >&2
====================================================================
==== compile protocols failed ====
$1
====================================================================
EOT
EOF
exit 1
}

Expand Down
4 changes: 2 additions & 2 deletions tools/osbuilder/image-builder/image_builder.sh
Expand Up @@ -72,7 +72,7 @@ readonly mem_boundary_mb=128
source "${lib_file}"

usage() {
cat <<EOT
cat <<EOF
Usage: ${script_name} [options] <rootfs-dir>
This script will create a Kata Containers image file of
an adequate size based on the <rootfs-dir> directory.
Expand Down Expand Up @@ -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
[2] - https://github.com/torvalds/linux/blob/master/drivers/nvdimm/pfn.h
EOT
EOF
}


Expand Down
4 changes: 2 additions & 2 deletions tools/osbuilder/initrd-builder/initrd_builder.sh
Expand Up @@ -23,7 +23,7 @@ AGENT_INIT=${AGENT_INIT:-no}
usage()
{
error="${1:-0}"
cat <<EOT
cat <<EOF
Usage: ${script_name} [options] <rootfs-dir>
This script creates a Kata Containers initrd image file based on the
<rootfs-dir> directory.
Expand All @@ -38,7 +38,7 @@ Extra environment variables:
DEFAULT: kata-agent
AGENT_INIT: use kata agent as init process
DEFAULT: no
EOT
EOF
exit "${error}"
}

Expand Down
12 changes: 6 additions & 6 deletions tools/osbuilder/rootfs-builder/rootfs.sh
Expand Up @@ -63,7 +63,7 @@ typeset init=
usage()
{
error="${1:-0}"
cat <<EOT
cat <<EOF
Usage: ${script_name} [options] [DISTRO]
Expand Down Expand Up @@ -143,7 +143,7 @@ Refer to the Platform-OS Compatibility Matrix for more details on the supported
architectures:
https://github.com/kata-containers/kata-containers/tree/main/tools/osbuilder#platform-distro-compatibility-matrix
EOT
EOF
exit "${error}"
}

Expand Down Expand Up @@ -473,7 +473,7 @@ setup_rootfs()
local unitFile="./etc/systemd/system/tmp.mount"
info "Install tmp.mount in ./etc/systemd/system"
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.
#
# systemd is free software; you can redistribute it and/or modify it
Expand All @@ -496,7 +496,7 @@ What=tmpfs
Where=/tmp
Type=tmpfs
Options=mode=1777,strictatime,nosuid,nodev
EOT
EOF
fi

popd >> /dev/null
Expand All @@ -519,12 +519,12 @@ EOT
esac

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
# Step the system clock instead of slewing it if the adjustment is larger than
# one second, at any time
makestep 1 -1
EOT
EOF

# Comment out ntp sources for chrony to be extra careful
# Reference: https://chrony.tuxfamily.org/doc/3.4/chrony.conf.html
Expand Down
4 changes: 2 additions & 2 deletions tools/osbuilder/scripts/lib.sh
Expand Up @@ -168,7 +168,7 @@ create_summary_file()
local -r agentdir="${script_dir}/../../../"
local -r agent_version=$(cat ${agentdir}/VERSION)

cat >"$file"<<-EOT
cat >"$file"<<-EOF
---
osbuilder:
url: "${osbuilder_url}"
Expand All @@ -190,7 +190,7 @@ ${extra}
name: "${AGENT_BIN}"
version: "${agent_version}"
agent-is-init-daemon: "${AGENT_INIT}"
EOT
EOF

local rootfs_file="${file_dir}/$(basename "${file}")"
info "Created summary file '${rootfs_file}' inside rootfs"
Expand Down
4 changes: 2 additions & 2 deletions tools/osbuilder/tests/test_images.sh
Expand Up @@ -53,7 +53,7 @@ source "${project_dir}/scripts/lib.sh"

usage()
{
cat <<EOT
cat <<EOF
Usage: $script_name [options] [command | <distro>]
Options:
Expand All @@ -72,7 +72,7 @@ Otherwise, tests are run on all distros.
$(basename ${test_config}) includes a list of distros to exclude from testing,
depending on the detected test environment. However, when a <distro> is specified,
distro exclusion based on $(basename ${test_config}) is not enforced.
EOT
EOF
}

# Add an entry to the specified stats file
Expand Down
4 changes: 2 additions & 2 deletions tools/packaging/guest-image/build_image.sh
Expand Up @@ -59,7 +59,7 @@ build_image() {

usage() {
return_code=${1:-0}
cat <<EOT
cat <<EOF
Create image and initrd in a tarball for kata containers.
Use it to build an image to distribute kata.
Expand All @@ -70,7 +70,7 @@ Options:
--imagetype=${image_type}
--prefix=${prefix}
--destdir=${destdir}
EOT
EOF

exit "${return_code}"
}
Expand Down
Expand Up @@ -50,7 +50,7 @@ error() {

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

exit "${return_code}"
}
Expand Down
16 changes: 8 additions & 8 deletions tools/packaging/kata-deploy/scripts/kata-deploy.sh
Expand Up @@ -94,10 +94,10 @@ function configure_different_shims_base() {
fi
fi

cat << EOT | tee "$shim_file"
cat << EOF | tee "$shim_file"
#!/usr/bin/env bash
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"

if [ "${shim}" == "${default_shim}" ]; then
Expand Down Expand Up @@ -132,15 +132,15 @@ function configure_crio_runtime() {
local kata_path="/usr/local/bin/containerd-shim-${runtime}-v2"
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
[$kata_conf]
runtime_path = "${kata_path}"
runtime_type = "vm"
runtime_root = "/run/vc"
privileged_without_host_devices = true
EOT
EOF
}

function configure_crio() {
Expand Down Expand Up @@ -178,22 +178,22 @@ function configure_containerd_runtime() {
echo "Configuration exists for $runtime_table, overwriting"
sed -i "/\[$runtime_table\]/,+1s#runtime_type.*#runtime_type = \"${runtime_type}\"#" $containerd_conf_file
else
cat <<EOT | tee -a "$containerd_conf_file"
cat <<EOF | tee -a "$containerd_conf_file"
[$runtime_table]
runtime_type = "${runtime_type}"
privileged_without_host_devices = true
pod_annotations = ["io.katacontainers.*"]
EOT
EOF
fi

if grep -q "\[$options_table\]" $containerd_conf_file; then
echo "Configuration exists for $options_table, overwriting"
sed -i "/\[$options_table\]/,+1s#ConfigPath.*#ConfigPath = \"${config_path}\"#" $containerd_conf_file
else
cat <<EOT | tee -a "$containerd_conf_file"
cat <<EOF | tee -a "$containerd_conf_file"
[$options_table]
ConfigPath = "${config_path}"
EOT
EOF
fi
}

Expand Down
4 changes: 2 additions & 2 deletions tools/packaging/kernel/build-kernel.sh
Expand Up @@ -65,7 +65,7 @@ source "${packaging_scripts_dir}/lib.sh"

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

Expand Down
4 changes: 2 additions & 2 deletions tools/packaging/release/publish-kata-image.sh
Expand Up @@ -28,7 +28,7 @@ die() {

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

exit "${return_code}"
}
Expand Down
16 changes: 8 additions & 8 deletions tools/packaging/release/release-notes.sh
Expand Up @@ -26,7 +26,7 @@ trap exit_handler EXIT

usage() {
return_code=${1:-}
cat <<EOT
cat <<EOF
Usage ${script_name} <previous-release> <new_release>
Args:
Expand All @@ -37,7 +37,7 @@ new-release: new release version that will have the
Example:
./${script_name} 1.2.0 1.2.1 > notes.md
EOT
EOF
exit "${return_code}"
}

Expand Down Expand Up @@ -81,25 +81,25 @@ changes() {
}

print_release_notes() {
cat <<EOT
cat <<EOF
# Release ${runtime_version}
EOT
EOF

for repo in "${repos[@]}"; do
git clone -q "https://github.com/${project}/${repo}.git" "${tmp_dir}/${repo}"
pushd "${tmp_dir}/${repo}" >>/dev/null

cat <<EOT
cat <<EOF
## ${repo} Changes
$(changes)
EOT
EOF
popd >>/dev/null
rm -rf "${tmp_dir}/${repo}"
done

cat <<EOT
cat <<EOF
## Compatibility with CRI-O
Kata Containers ${runtime_version} is compatible with CRI-O ${crio_version}
Expand Down Expand Up @@ -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
[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
EOT
EOF
}

main() {
Expand Down
8 changes: 4 additions & 4 deletions tools/packaging/release/tag_repos.sh
Expand Up @@ -27,16 +27,16 @@ source "${script_dir}/../scripts/lib.sh"

function usage() {

cat <<EOT
cat <<EOF
Usage: ${script_name} [options] <args>
This script creates a new release for ${PROJECT}.
It tags and create release for:
EOT
EOF
for r in "${repos[@]}"; do
echo " - ${r}"
done

cat <<EOT
cat <<EOF
Args:
status : Get Current ${PROJECT} tags status
Expand All @@ -48,7 +48,7 @@ Options:
-h : Show this help
-p : push tags
EOT
EOF

}

Expand Down
8 changes: 4 additions & 4 deletions tools/packaging/release/update-repository-version.sh
Expand Up @@ -223,12 +223,12 @@ bump_repo() {

info "Creating PR message"
notes_file=notes.md
cat <<EOT >"${notes_file}"
cat <<EOF >"${notes_file}"
# Kata Containers ${new_version}
$(get_changes "$current_version")
EOT
EOF
cat "${notes_file}"

if (echo "${current_version}" | grep "alpha") && (echo "${new_version}" | grep -v "alpha");then
Expand Down Expand Up @@ -282,7 +282,7 @@ EOT

usage() {
exit_code="$1"
cat <<EOT
cat <<EOF
Usage:
${script_name} [options] <args>
Args:
Expand All @@ -293,7 +293,7 @@ Example:
Options
-h : Show this help
-p : create a PR
EOT
EOF
exit "$exit_code"
}

Expand Down

0 comments on commit 5d6d39b

Please sign in to comment.