mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-06-22 05:28:25 +00:00
Use `multistrap` for building Ubuntu rootfs. Adds support for building for foreign architectures using the `ARCH` environment variable. In the process, the Ubuntu rootfs workflow is vastly simplified. Signed-off-by: Jakob Naucke <jakob.naucke@ibm.com>
30 lines
823 B
Bash
30 lines
823 B
Bash
# Copyright (c) 2018 Yash Jain, 2022 IBM Corp.
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
build_rootfs() {
|
|
local rootfs_dir=$1
|
|
local multistrap_conf=multistrap.conf
|
|
|
|
# For simplicity's sake, use multistrap for foreign and native bootstraps.
|
|
cat > "$multistrap_conf" << EOF
|
|
[General]
|
|
cleanup=true
|
|
aptsources=Ubuntu
|
|
bootstrap=Ubuntu
|
|
|
|
[Ubuntu]
|
|
source=$REPO_URL
|
|
keyring=ubuntu-keyring
|
|
suite=focal
|
|
packages=$PACKAGES $EXTRA_PKGS
|
|
EOF
|
|
multistrap -a "$DEB_ARCH" -d "$rootfs_dir" -f "$multistrap_conf"
|
|
rm -rf "$rootfs_dir/var/run"
|
|
ln -s /run "$rootfs_dir/var/run"
|
|
cp --remove-destination /etc/resolv.conf "$rootfs_dir/etc"
|
|
|
|
# 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}
|
|
}
|