From 40f6ee0088528f355f3fe16e440c8d5f60b0d27d Mon Sep 17 00:00:00 2001 From: Serge Hallyn Date: Tue, 31 Jul 2012 16:07:18 +0200 Subject: [PATCH] lxc-ubuntu: Use dpkg --add-architecture MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a container has dpkg >= 1.16.2, use dpkg --add-architecture for multi-arch configuration on foreign architecture containers. Signed-off-by: Stéphane Graber Signed-off-by: Serge Hallyn Signed-off-by: Daniel Lezcano --- templates/lxc-ubuntu.in | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in index fbee3f769..a0337c5bd 100644 --- a/templates/lxc-ubuntu.in +++ b/templates/lxc-ubuntu.in @@ -469,8 +469,13 @@ post_process() # If the container isn't running a native architecture, setup multiarch if [ -x "$(ls -1 ${rootfs}/usr/bin/qemu-*-static 2>/dev/null)" ]; then - mkdir -p ${rootfs}/etc/dpkg/dpkg.cfg.d - echo "foreign-architecture ${hostarch}" > ${rootfs}/etc/dpkg/dpkg.cfg.d/lxc-multiarch + dpkg_version=$(chroot $rootfs dpkg-query -W -f='${Version}' dpkg) + if chroot $rootfs dpkg --compare-versions $dpkg_version ge "1.16.2"; then + chroot $rootfs dpkg --add-architecture ${hostarch} + else + mkdir -p ${rootfs}/etc/dpkg/dpkg.cfg.d + echo "foreign-architecture ${hostarch}" > ${rootfs}/etc/dpkg/dpkg.cfg.d/lxc-multiarch + fi # Save existing value of MIRROR and SECURITY_MIRROR DEFAULT_MIRROR=$MIRROR