Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Ubuntu rootfs #59

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions rootfs-builder/rootfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ ENV PATH=\$PATH:\$GOROOT/bin:\$GOPATH/bin
sed \
-e "s|@GO_VERSION@|${GO_VERSION}|g" \
-e "s|@OS_VERSION@|${OS_VERSION}|g" \
-e "s|@OS_NAME@|${OS_NAME}|g" \
-e "s|@INSTALL_GO@|${install_go//$'\n'/\\n}|g" \
${dockerfile_template} > Dockerfile
popd
Expand Down Expand Up @@ -193,16 +194,17 @@ if [ -n "${USE_DOCKER}" ] ; then
--env https_proxy="${https_proxy}" \
--env http_proxy="${http_proxy}" \
--env AGENT_VERSION="${AGENT_VERSION}" \
--env ROOTFS_DIR="/rootfs" \
--env ROOTFS_DIR="${ROOTFS_DIR}" \
--env GO_AGENT_PKG="${GO_AGENT_PKG}" \
--env AGENT_BIN="${AGENT_BIN}" \
--env AGENT_INIT="${AGENT_INIT}" \
--env GOPATH="${GOPATH}" \
--env KERNEL_MODULES_DIR="${KERNEL_MODULES_DIR}" \
-v "${script_dir}":"/osbuilder" \
-v "${ROOTFS_DIR}":"/rootfs" \
-v "${ROOTFS_DIR}":"${ROOTFS_DIR}" \
-v "${kernel_mod_dir}":"${kernel_mod_dir}" \
-v "${GOPATH}":"${GOPATH}" \
--privileged \
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debootstrap needs chroot Is there another way of doing this?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it mounting any special device or why chroot need it ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think debootstrap first downloads the rootfs then chroots into it then mounts file systems and then installs packages.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are fakeroot and fakechroot packages. I had a quick play around but they didn't allow me to run debootstrap successfully ;(

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will go through them and get back soon.

Thanks

${image_name} \
bash /osbuilder/rootfs.sh "${distro}"

Expand Down
6 changes: 6 additions & 0 deletions rootfs-builder/ubuntu/Dockerfile.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
From ubuntu:@OS_NAME@

RUN apt-get update && apt-get install -y git systemd debootstrap build-essential

# This will install the proper golang to build Kata components
@INSTALL_GO@
19 changes: 19 additions & 0 deletions rootfs-builder/ubuntu/config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#
# Copyright (c) 2018 Yash Jain
#
# SPDX-License-Identifier: Apache-2.0


# architecture to build the rootfs for
ARCH=${ARCH:-"amd64"}

# url to download rootfs from
ARCHIVE_URL=${ARCHIVE_URL:-"http://archive.ubuntu.com/ubuntu/"}

# this should be ubuntu's codename eg Xenial for 16.04
OS_NAME=${OS_NAME:-"xenial"}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't really a comment specific to this PR - just a reminder to all...

I appreciate this is following the existing convention, but we do all need to think about how we'll manage these versions and code names as one day, they will become invalid.

See:

For osbuilder, we could create a special build target which called a shell script and checked ARCHIVE_URL + OS_NAME maybe (and there are bound to be distro-specific bits to add to that). But we could then atleast call this build rule as part of the CI.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree we should have a mechanism to detect EOL distro version.....However I won't be able to work on that issue before 17th(have my exams till then) I can hopefully work on it after that, if the issue is not already resolved by then.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @ydjainopensource - thanks. I added this comment as your PR just reminded me of the general issue. Please don't feel you have to work on that feature unless it's something that interests you ;)

I suspect there will need to be a bit of discussion about how best to solve this problem for all the distros we handle but it is something that has "caught us out" before so it would be good to find a general and robust solution to the problem.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I loved love to work on it. Do you have any ideas as to how we should go about tackling them? I have worked only on apt based distros.


# packages to be installed by default
PACKAGES="systemd iptables"

DEBOOTSTRAP=${PACKAGE_MANAGER:-"debootstrap"}
68 changes: 68 additions & 0 deletions rootfs-builder/ubuntu/rootfs_lib.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#!/bin/bash
#
# Copyright (c) 2018 Yash Jain
#
# SPDX-License-Identifier: Apache-2.0

set -e

check_program(){
type "$1" >/dev/null 2>&1
}



build_rootfs()
{
# Mandatory
local ROOTFS_DIR=$1

# In case of support EXTRA packages, use it to allow
# users add more packages to the base rootfs
local EXTRA_PKGS=${EXTRA_PKGS:-""}


check_root
mkdir -p "${ROOTFS_DIR}"

if [ -n "${PKG_MANAGER}" ]; then
info "debootstrap path provided by user: ${PKG_MANAGER}"
elif check_program $DEBOOTSTRAP ; then
PKG_MANAGER=$DEBOOTSTRAP
else
die "$DEBOOTSTRAP is not installed"
fi

# trim whitespace
PACKAGES=$(echo $PACKAGES |xargs )
EXTRA_PKGS=$(echo $EXTRA_PKGS |xargs)

# add comma as debootstrap needs , separated package names.
# Don't change $PACKAGES in config.sh to include ','
# This is done to maintain consistency
PACKAGES=$(echo $PACKAGES | sed -e 's/ /,/g' )
EXTRA_PKGS=$(echo $EXTRA_PKGS | sed -e 's/ /,/g' )

# extra packages are added to packages and finally passed to debootstrap
if [ "${EXTRA_PKGS}" = "" ]; then
echo "no extra packages"
else
PACKAGES="${PACKAGES},${EXTRA_PKGS}"
fi

${PKG_MANAGER} --variant=minbase \
--arch="${ARCH}" \
--include="$PACKAGES" \
"${OS_NAME}" \
"${ROOTFS_DIR}"\
"${ARCHIVE_URL}"
}


check_root()
{
if [ "$(id -u)" != "0" ]; then
echo "Root is needed"
exit 1
fi
}