Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ship docker sysext and rip out torcx [WIP] #982

Closed
wants to merge 16 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
50 changes: 30 additions & 20 deletions build_library/build_image_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,18 @@ image_packages_portage() {
ROOT="$1" PORTAGE_CONFIGROOT="${BUILD_DIR}"/configroot \
equery --no-color list --format '$cpv::$repo' '*'
}

# List dependencies for a package runtime dependencies

function package_run_dependencies() (
pkg=${1:?}
ebuild=$(equery-${BOARD} w "${pkg}")
function inherit() { : ; }
. "${ebuild}"
echo ${RDEPEND}
)


# List packages implicitly contained in rootfs, such as in torcx packages or
# initramfs.
image_packages_implicit() {
Expand Down Expand Up @@ -294,6 +306,12 @@ image_packages_implicit() {
[ -z "${FLAGS_torcx_manifest}" ] ||
torcx_manifest::sources_on_disk "${FLAGS_torcx_manifest}" |
while read pkg ; do query_available_package "${pkg}" ; done


# Include source packages of all sysext images installed on disk.
for docker_containerd_package in $(package_run_dependencies docker) $(package_run_dependencies containerd); do
query_available_package "${docker_containerd_package}" ;
done
}

# Generate a list of packages installed in an image.
Expand Down Expand Up @@ -625,26 +643,18 @@ finish_image() {
local install_grub=0
local disk_img="${BUILD_DIR}/${image_name}"

# Copy in packages from the torcx store that are marked as being on disk
if [ -n "${FLAGS_torcx_manifest}" ]; then
for pkg in $(torcx_manifest::get_pkg_names "${FLAGS_torcx_manifest}"); do
local default_version="$(torcx_manifest::default_version "${FLAGS_torcx_manifest}" "${pkg}")"
for version in $(torcx_manifest::get_versions "${FLAGS_torcx_manifest}" "${pkg}"); do
local on_disk_path="$(torcx_manifest::local_store_path "${FLAGS_torcx_manifest}" "${pkg}" "${version}")"
if [[ -n "${on_disk_path}" ]]; then
local casDigest="$(torcx_manifest::get_digest "${FLAGS_torcx_manifest}" "${pkg}" "${version}")"
sudo cp "${FLAGS_torcx_root}/pkgs/${BOARD}/${pkg}/${casDigest}/${pkg}:${version}.torcx.tgz" \
"${root_fs_dir}${on_disk_path}"
sudo tar xf "${root_fs_dir}${on_disk_path}" -C "${root_fs_dir}" --wildcards "./usr/share/SLSA"
if [[ "${version}" == "${default_version}" ]]; then
# Create the default symlink for this package
sudo ln -fns "${on_disk_path##*/}" \
"${root_fs_dir}/${on_disk_path%/*}/${pkg}:com.coreos.cl.torcx.tgz"
fi
fi
done
done
fi
# Ship the docker systemd-sysext image and rip out torcx in same go; TODO: create seperate sysext images for containerd and docker
mkdir -p "${PORTAGE_CONFIGROOT}"/etc/portage/profile
query_available_package containerd | sudo_clobber ${PORTAGE_CONFIGROOT}/etc/portage/profile/package.provided # use a temporary package.provided to make emerge believe the dependencies are already installed
sudo "${SCRIPTS_DIR}/build_sysext" --board="${BOARD}" --image_builddir=${BUILD_DIR} --squashfs_base="${BUILD_DIR}/${image_sysext_base}" --manglefs_script="${SCRIPTS_DIR}/manglefs_docker" docker-flatcar app-containers/docker
sudo install -m 0644 -D "${BUILD_DIR}/docker-flatcar.raw" "${root_fs_dir}"/usr/share/flatcar/
sudo mkdir -p "${root_fs_dir}"/etc/extensions/
sudo ln -sf /usr/share/flatcar/docker-flatcar.raw "${root_fs_dir}"/etc/extensions/docker-flatcar.raw
sudo rm ${PORTAGE_CONFIGROOT}/etc/portage/profile/package.provided

sudo "${SCRIPTS_DIR}/build_sysext" --board="${BOARD}" --image_builddir=${BUILD_DIR} --squashfs_base="${BUILD_DIR}/${image_sysext_base}" --manglefs_script="${SCRIPTS_DIR}/manglefs_containerd" containerd-flatcar app-containers/containerd
sudo install -m 0644 -D "${BUILD_DIR}/containerd-flatcar.raw" "${root_fs_dir}"/usr/share/flatcar/
sudo ln -sf /usr/share/flatcar/containerd-flatcar.raw "${root_fs_dir}"/etc/extensions/containerd-flatcar.raw

# Only enable rootfs verification on prod builds.
local disable_read_write="${FLAGS_FALSE}"
Expand Down
2 changes: 1 addition & 1 deletion build_library/dev_container_util.sh
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ create_dev_container() {
# The remount services are provided by coreos-base/coreos-init
systemd_enable "${root_fs_dir}" "multi-user.target" "remount-usr.service"

finish_image "${image_name}" "${disk_layout}" "${root_fs_dir}" "${image_contents}" "${image_contents_wtd}"
DEVCONTAINER=1 finish_image "${image_name}" "${disk_layout}" "${root_fs_dir}" "${image_contents}" "${image_contents_wtd}"

declare -a files_to_evaluate
declare -a compressed_images
Expand Down
7 changes: 7 additions & 0 deletions manglefs_containerd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -euo pipefail
rootfs="${1}"

mkdir -p "${rootfs}/usr/lib/systemd/system/multi-user.target.d"
{ echo "[Unit]"; echo "Upholds=containerd.service"; } > "${rootfs}/usr/lib/systemd/system/multi-user.target.d/10-containerd-service.conf"
7 changes: 7 additions & 0 deletions manglefs_docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

set -euo pipefail
rootfs="${1}"

mkdir -p "${rootfs}/usr/lib/systemd/system/sockets.target.d"
{ echo "[Unit]"; echo "Upholds=docker.socket"; } > "${rootfs}/usr/lib/systemd/system/sockets.target.d/10-docker-socket.conf"

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,6 @@ RDEPEND="${RDEPEND}
app-arch/xz-utils
app-arch/zstd
app-arch/tar
app-arch/torcx
app-arch/unzip
app-arch/zip
app-arch/ncompress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ RDEPEND="
sys-boot/grub
sys-firmware/edk2-ovmf-bin
)
app-containers/containerd
app-containers/docker
app-emulation/amazon-ssm-agent
app-emulation/wa-linux-agent
coreos-base/coreos
Expand Down