mirror of
https://github.com/kata-containers/kata-containers.git
synced 2026-04-27 02:56:50 +00:00
tools: Fix shellcheck issues in rootfs_lib.sh
Fix shellcheck warnings and notes identified by running shellcheck --severity=style. Signed-off-by: Fabiano Fidêncio <ffidencio@nvidia.com>
This commit is contained in:
@@ -11,31 +11,33 @@ build_rootfs() {
|
||||
# E: Can't find a source to download version '2021.03.26' of 'ubuntu-keyring:amd64'
|
||||
apt update
|
||||
# focal version of mmdebstrap only supports comma separated package lists
|
||||
if [ "$OS_VERSION" = "focal" ]; then
|
||||
PACKAGES=$(echo "$PACKAGES" | tr ' ' ',')
|
||||
EXTRA_PKGS=$(echo "$EXTRA_PKGS" | tr ' ' ',')
|
||||
# shellcheck disable=SC2154
|
||||
if [[ "${OS_VERSION}" = "focal" ]]; then
|
||||
PACKAGES=$(echo "${PACKAGES}" | tr ' ' ',')
|
||||
EXTRA_PKGS=$(echo "${EXTRA_PKGS}" | tr ' ' ',')
|
||||
fi
|
||||
if ! mmdebstrap --mode auto --arch "$DEB_ARCH" --variant required \
|
||||
--components="$REPO_COMPONENTS" \
|
||||
--include "$PACKAGES,$EXTRA_PKGS" "$OS_VERSION" "$rootfs_dir" "$REPO_URL"; then
|
||||
# shellcheck disable=SC2154
|
||||
if ! mmdebstrap --mode auto --arch "${DEB_ARCH}" --variant required \
|
||||
--components="${REPO_COMPONENTS}" \
|
||||
--include "${PACKAGES},${EXTRA_PKGS}" "${OS_VERSION}" "${rootfs_dir}" "${REPO_URL}"; then
|
||||
echo "ERROR: mmdebstrap failed, cannot proceed" && exit 1
|
||||
else
|
||||
echo "INFO: mmdebstrap succeeded"
|
||||
fi
|
||||
rm -rf "$rootfs_dir/var/run"
|
||||
ln -s /run "$rootfs_dir/var/run"
|
||||
cp --remove-destination /etc/resolv.conf "$rootfs_dir/etc"
|
||||
rm -rf "${rootfs_dir}/var/run"
|
||||
ln -s /run "${rootfs_dir}/var/run"
|
||||
cp --remove-destination /etc/resolv.conf "${rootfs_dir}/etc"
|
||||
|
||||
local dir="$rootfs_dir/etc/ssl/certs"
|
||||
mkdir -p "$dir"
|
||||
cp --remove-destination /etc/ssl/certs/ca-certificates.crt "$dir"
|
||||
local dir="${rootfs_dir}/etc/ssl/certs"
|
||||
mkdir -p "${dir}"
|
||||
cp --remove-destination /etc/ssl/certs/ca-certificates.crt "${dir}"
|
||||
|
||||
# Reduce image size and memory footprint by removing unnecessary files and directories.
|
||||
rm -rf $rootfs_dir/usr/share/{bash-completion,bug,doc,info,lintian,locale,man,menu,misc,pixmaps,terminfo,zsh}
|
||||
rm -rf "${rootfs_dir}"/usr/share/{bash-completion,bug,doc,info,lintian,locale,man,menu,misc,pixmaps,terminfo,zsh}
|
||||
|
||||
# Minimal set of device nodes needed when AGENT_INIT=yes so that the
|
||||
# kernel can properly setup stdout/stdin/stderr for us
|
||||
pushd $rootfs_dir/dev
|
||||
pushd "${rootfs_dir}/dev" || return
|
||||
MAKEDEV -v console tty ttyS null zero fd
|
||||
popd
|
||||
popd || return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user