[lxc-devel] [PATCH] lxc-debian: added possibility to give target architecture, use host's arch by default

Marcus Osdoba marcus.osdoba at googlemail.com
Tue Nov 29 22:17:04 UTC 2011


Hi mailinglist,

Please note the attached patch for lxc-debian.
With this patch, one is able to create e.g. a 32bit container on a amd64 
host system easily.

Not done by this patch: add lxc.arch = $ARCH in file config

Best regards,
Marcus


From: Marcus Osdoba <marcus.osdoba at googlemail.com>
Date: Tue, 29 Nov 2011 22:35:14 +0100

useful when creating 32bit containers on 64bit hosts
e.g. i386 on amd64 host

sample:
bash#>export ARCH=i386; ./lxc-debian -p /var/lib/lxc/samplecontainer

Signed-off-by: Marcus Osdoba <marcus.osdoba at googlemail.com>
---
  templates/lxc-debian.in |   12 ++++++------
  1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/templates/lxc-debian.in b/templates/lxc-debian.in
index 9d33113..3bf67ce 100644
--- a/templates/lxc-debian.in
+++ b/templates/lxc-debian.in
@@ -22,6 +22,8 @@

  SUITE=${SUITE:-squeeze}
  MIRROR=${MIRROR:-http://cdn.debian.net/debian}
+HOSTARCH=$(dpkg --print-architecture)
+ARCH=${ARCH:-$HOSTARCH}

  configure_debian()
  {
@@ -158,18 +160,16 @@ install_debian()
             return 1
         fi

-       arch=$(dpkg --print-architecture)
-
-       echo "Checking cache download in $cache/rootfs-$SUITE-$arch ... "
-       if [ ! -e "$cache/rootfs-$SUITE-$arch" ]; then
-           download_debian $cache $arch
+       echo "Checking cache download in $cache/rootfs-$SUITE-$ARCH ... "
+       if [ ! -e "$cache/rootfs-$SUITE-$ARCH" ]; then
+           download_debian $cache $ARCH
             if [ $? -ne 0 ]; then
                 echo "Failed to download 'debian base'"
                 return 1
             fi
         fi

-       copy_debian $cache $arch $rootfs
+       copy_debian $cache $ARCH $rootfs
         if [ $? -ne 0 ]; then
             echo "Failed to copy rootfs"
             return 1
--
1.7.2.5




More information about the lxc-devel mailing list