Skip to content

Commit 4bc876a

Browse files
committed
container: Install binfmts for qemu manually
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 <[email protected]>
1 parent 0acb621 commit 4bc876a

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ RUN --mount=type=cache,target=/var/cache/apt,sharing=${CACHE_SHARING} \
105105
--mount=type=cache,target=/var/lib/apt,sharing=${CACHE_SHARING} \
106106
apt-get update && \
107107
apt-get install -y -f --no-install-recommends \
108-
binfmt-support bzip2 mmdebstrap arch-test apt-utils dosfstools \
108+
bzip2 mmdebstrap arch-test apt-utils dosfstools \
109109
dpkg-dev gettext-base git mtools parted python3 \
110110
quilt qemu-user-static reprepro sudo unzip git-buildpackage \
111111
pristine-tar sbuild schroot zstd \

container-entrypoint

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,19 @@
2222
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2323
# SOFTWARE.
2424

25-
# kas-isar: sudo update-binfmts --enable && [ -f /proc/sys/fs/binfmt_misc/status ]
25+
enable_qemu_binfmts()
26+
{
27+
if ! [ -f /proc/sys/fs/binfmt_misc/status ]; then
28+
sudo mount -t binfmt_misc null /proc/sys/fs/binfmt_misc
29+
fi
30+
for CONF in /usr/lib/binfmt.d/qemu-*.conf; do
31+
if ! [ -f /proc/sys/fs/binfmt_misc/"$(basename "${CONF%%.conf}")" ]; then
32+
sudo sh -c "cat '$CONF' > /proc/sys/fs/binfmt_misc/register"
33+
fi
34+
done
35+
}
36+
37+
# kas-isar: enable_qemu_binfmts
2638

2739
chown_managed_dirs()
2840
{

0 commit comments

Comments
 (0)