From: Jan Kiszka <
jan.k...@siemens.com>
In trixie, qemu-user decided to exclusively rely on systemd for
installing its binfmt configs. First, we do not have and otherwise do
not need systemd in our container. Second, we cannot use systemd-binfmt
because it will always unregister pre-existing entries before
(re-)adding them. That could break parallel kas-isar runs because we can
still not benefit from binfmt namespaces with current isar.
Switch to a manual registration procedure instead which will not
overwrite existing entries, only add missing ones that are found in the
container's /usr/lib/binfmt.d folder and that are related to qemu-user.
Signed-off-by: Jan Kiszka <
jan.k...@siemens.com>
---
Dockerfile | 2 +-
container-entrypoint | 14 +++++++++++++-
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/Dockerfile b/Dockerfile
index 716e060..f508777 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -105,7 +105,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=${CACHE_SHARING} \
--mount=type=cache,target=/var/lib/apt,sharing=${CACHE_SHARING} \
apt-get update && \
apt-get install -y -f --no-install-recommends \
- binfmt-support bzip2 mmdebstrap arch-test apt-utils dosfstools \
+ bzip2 mmdebstrap arch-test apt-utils dosfstools \
dpkg-dev gettext-base git mtools parted python3 \
quilt qemu-user-static reprepro sudo unzip git-buildpackage \
pristine-tar sbuild schroot zstd \
diff --git a/container-entrypoint b/container-entrypoint
index 8cf3645..8e586d4 100755
--- a/container-entrypoint
+++ b/container-entrypoint
@@ -22,7 +22,19 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
-# kas-isar: sudo update-binfmts --enable && [ -f /proc/sys/fs/binfmt_misc/status ]
+enable_qemu_binfmts()
+{
+ if ! [ -f /proc/sys/fs/binfmt_misc/status ]; then
+ sudo mount -t binfmt_misc null /proc/sys/fs/binfmt_misc
+ fi
+ for CONF in /usr/lib/binfmt.d/qemu-*.conf; do
+ if ! [ -f /proc/sys/fs/binfmt_misc/"$(basename "${CONF%%.conf}")" ]; then
+ sudo sh -c "cat '$CONF' > /proc/sys/fs/binfmt_misc/register"
+ fi
+ done
+}
+
+# kas-isar: enable_qemu_binfmts
chown_managed_dirs()
{
--
2.51.0