[libcamera-ci,RFC,v2,5/5] Add description about debian rootfs setup for testing
diff mbox series

Message ID 20260130160254.1770742-6-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • on-device-testing proof of concept
Related show

Commit Message

Barnabás Pőcze Jan. 30, 2026, 4:02 p.m. UTC
Add a document that describes how the debian based root file system can be
built and where it needs to be deployed.

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
---
 .../debian-rootfs/build-debian-rootfs.sh      | 62 +++++++++++++++++++
 containers/debian-rootfs/build.sh             |  9 +++
 .../overlay/opt/test-libcamera.sh             | 18 ++++++
 doc/debian-rootfs.rst                         | 47 ++++++++++++++
 4 files changed, 136 insertions(+)
 create mode 100755 containers/debian-rootfs/build-debian-rootfs.sh
 create mode 100755 containers/debian-rootfs/build.sh
 create mode 100755 containers/debian-rootfs/overlay/opt/test-libcamera.sh
 create mode 100644 doc/debian-rootfs.rst

--
2.52.0

Patch
diff mbox series

diff --git a/containers/debian-rootfs/build-debian-rootfs.sh b/containers/debian-rootfs/build-debian-rootfs.sh
new file mode 100755
index 0000000..af9db02
--- /dev/null
+++ b/containers/debian-rootfs/build-debian-rootfs.sh
@@ -0,0 +1,62 @@ 
+#!/bin/bash
+# based on https://gitlab.freedesktop.org/freedesktop/ci-templates/-/blob/fb9d50ccb3cbbb4c6dc5f9ef53a0ad3cb0d8a177/bootstrap/cbuild
+
+set -ex
+
+packages=(
+	# misc.
+	ca-certificates
+	coreutils
+	chrony
+	curl
+	iproute2
+	kmod
+	moreutils
+	openssh-server
+	v4l-utils
+	wget
+
+	# runtime dependencies
+	# ensure that it is in sync with the `build-deb-for-lc-compliance-testing` job
+	libevent-2.1-7
+	libevent-pthreads-2.1-7
+	libssl3t64
+	libudev1
+	libyaml-0-2
+	udev
+)
+
+deb_distribution="$1"
+deb_arch="$2"
+container_image_name="$3"
+overlay_dir="$4"
+
+newcontainer=$(buildah from scratch)
+scratchmnt=$(buildah mount "$newcontainer")
+
+debootstrap --arch="$deb_arch" --variant=minbase "$deb_distribution" "$scratchmnt"
+
+buildah run --isolation=chroot "$newcontainer" apt update -y
+buildah run --isolation=chroot "$newcontainer" apt install -y --no-install-recommends systemd systemd-sysv
+buildah run --isolation=chroot "$newcontainer" apt install -y --no-install-recommends "${packages[@]}"
+buildah run --isolation=chroot "$newcontainer" bash -c 'printf "root\nroot\n" | passwd root'
+buildah run --isolation=chroot "$newcontainer" bash -c 'echo "PermitRootLogin yes" > /etc/ssh/sshd_config.d/10-allow-root-password.conf'
+buildah run --isolation=chroot "$newcontainer" apt autoclean -y
+buildah run --isolation=chroot "$newcontainer" apt autopurge -y
+
+buildah run --isolation=chroot "$newcontainer" rm -rf /var/cache/
+buildah run --isolation=chroot "$newcontainer" rm -rf /var/lib/apt/
+
+if [[ -d "$overlay_dir" ]]; then
+	rsync -av --chown=root:root "$overlay_dir/" "$scratchmnt/"
+fi
+
+buildah unmount "$newcontainer"
+
+buildah config --entrypoint '["/sbin/init"]' "$newcontainer"
+buildah config --os linux "$newcontainer"
+buildah config --arch "$deb_arch" "$newcontainer"
+
+buildah commit --format=docker "$newcontainer" "$container_image_name"
+
+podman image inspect "$container_image_name"
diff --git a/containers/debian-rootfs/build.sh b/containers/debian-rootfs/build.sh
new file mode 100755
index 0000000..71c9fa2
--- /dev/null
+++ b/containers/debian-rootfs/build.sh
@@ -0,0 +1,9 @@ 
+#!/bin/bash
+
+set -ex
+
+exec buildah unshare ./build-debian-rootfs.sh \
+	trixie \
+	arm64 \
+	localhost/libcamera-ci/debian-rootfs:arm64 \
+	./overlay
diff --git a/containers/debian-rootfs/overlay/opt/test-libcamera.sh b/containers/debian-rootfs/overlay/opt/test-libcamera.sh
new file mode 100755
index 0000000..a22a17d
--- /dev/null
+++ b/containers/debian-rootfs/overlay/opt/test-libcamera.sh
@@ -0,0 +1,18 @@ 
+#!/bin/bash
+
+set -ex
+
+pkg_source="$1"
+camera_id="$2"
+
+trap 'rm -rf /tmp/libcamera.deb' EXIT
+curl --retry 3 -f -o /tmp/libcamera.deb -- "$pkg_source"
+dpkg -i /tmp/libcamera.deb
+rm -rf /tmp/libcamera.deb
+
+env \
+        LIBCAMERA_LOG_COLOR=no \
+        GTEST_COLOR=no \
+        ASAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1 \
+        UBSAN_OPTIONS=halt_on_error=1:abort_on_error=1:print_summary=1:print_stacktrace=1 \
+                lc-compliance -c "$camera_id"
diff --git a/doc/debian-rootfs.rst b/doc/debian-rootfs.rst
new file mode 100644
index 0000000..1cb45a1
--- /dev/null
+++ b/doc/debian-rootfs.rst
@@ -0,0 +1,47 @@ 
+.. SPDX-License-Identifier: CC-BY-SA-4.0
+
+Creating the root file system for on device testing
+===================================================
+
+At the moment, the root file system used with boot2container for testing
+needs to be built and deployed manually.
+
+Building
+--------
+
+Some dependencies that might need to be installed:
+
+   * `buildah`_
+   * debootstrap
+   * rsync
+   * qemu user emulation for aarch64 with binfmt setup
+
+.. _buildah: https://buildah.io/
+
+Simply ``cd`` into the ``containers/debian-rootfs`` directory, and execute the ``build.sh``:
+
+.. code:: shell
+
+   $ ./build.sh
+
+If everything succeeds, a new image tagged as ``localhost/libcamera-ci/debian-rootfs:arm64``
+should be available.
+
+Deployment
+----------
+
+The ``localhost/libcamera-ci/debian-rootfs:arm64`` image must be pushed to the internal
+registry running alongside the LAVA services. After starting SSH forwarding:
+
+.. code:: shell
+
+   $ ssh -N -v -L 127.0.0.1:5000:${REGISTRY_LOCAL_ADDR}:5000 ssh://${REGISTRY_REMOTE_ADDR}
+
+the image must be tagged for the registry and pushed:
+
+.. code:: shell
+
+   $ podman image tag localhost/libcamera-ci/debian-rootfs:arm64 localhost:5000/libcamera-ci/debian-rootfs-arm64:latest
+   $ podman image push --tls-verify=false localhost:5000/libcamera-ci/debian-rootfs-arm64
+
+Internal documentation describes how to gain access.