-
Notifications
You must be signed in to change notification settings - Fork 85
Ubuntu rootfs #59
Ubuntu rootfs #59
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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@ |
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"} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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"} |
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 | ||
} |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are
fakeroot
andfakechroot
packages. I had a quick play around but they didn't allow me to rundebootstrap
successfully ;(There was a problem hiding this comment.
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