Skip to content

Commit

Permalink
Create a sysroot flavour of the Oak Containers system image
Browse files Browse the repository at this point in the history
The idea is to use the .tar that is generated by this as the sysroot for
bazel in the future. This is not in use right now, though, as I've yet
to set up the toolchain that'd use this sysroot.

Bug: b/364256351
Change-Id: If78714221b3ff2999fd5bd58ad7f15b78950010a
  • Loading branch information
andrisaar committed Sep 16, 2024
1 parent 851ac3b commit 2cbc9cd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
14 changes: 11 additions & 3 deletions oak_containers/system_image/build-base.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,35 @@ function build_nvidia_base {
build_base "oak-containers-sysimage-nvidia-base" "nvidia_base_image.Dockerfile" "nvidia-base-image.tar"
}

function build_sysroot {
build_base "oak-sysroot" "sysroot.Dockerfile" "sysroot.tar"
}

if [ -z "${1:-}" ]
then
set +o xtrace
echo ""
echo "Building both vanilla and nvidia base images."
echo "Building both vanilla and nvidia base images and the sysroot."
echo ""
echo "If you want to build just one of the base image types, use:"
echo "If you want to build just one of the base image types, use one of the following:"
echo "./scripts/build-bash.sh vanilla"
echo "or"
echo "./scripts/build-bash.sh nvidia"
echo "./scripts/build-bash.sh sysroot"
echo ""
sleep 1
set -o xtrace
build_vanilla_base
build_nvidia_base
build_sysroot
elif [ "$1" == "vanilla" ]
then
build_vanilla_base
elif [ "$1" == "nvidia" ]
then
build_nvidia_base
elif [ "$1" == "sysroot" ]
then
build_sysroot
fi

set +o xtrace
Expand Down
25 changes: 25 additions & 0 deletions oak_containers/system_image/sysroot.Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# The expectation is that we build `base_image.Dockerfile` before this one.
# hadolint ignore=DL3007
FROM oak-containers-sysimage-base:latest

ARG LINUX_KERNEL_VERSION

SHELL ["/bin/bash", "-o", "pipefail", "-c"]

RUN apt-get --yes update \
&& apt-get install --yes --no-install-recommends \
libc6-dev flex bison build-essential bc cpio libncurses5-dev libelf-dev libssl-dev dwarves debhelper-compat rsync \
kmod \
# Cleanup
&& apt-get clean \
&& rm --recursive --force /var/lib/apt/lists/*

COPY target/linux-${LINUX_KERNEL_VERSION}.tar.xz /tmp
COPY target/minimal.config /tmp

RUN tar --directory=/tmp --extract --file /tmp/linux-${LINUX_KERNEL_VERSION}.tar.xz \
&& cp /tmp/minimal.config /tmp/linux-${LINUX_KERNEL_VERSION}/.config \
&& make --directory=/tmp/linux-${LINUX_KERNEL_VERSION} bindeb-pkg \
&& dpkg --install /tmp/linux-headers-${LINUX_KERNEL_VERSION}_${LINUX_KERNEL_VERSION}-1_amd64.deb \
&& rm -rf /tmp/linux-${LINUX_KERNEL_VERSION} /tmp/linux-${LINUX_KERNEL_VERSION}.tar.xz /tmp/minimal.config

0 comments on commit 2cbc9cd

Please sign in to comment.