[virt-tools-list] [PATCH 5/7] lxcinstaller: install Debian trees with debootstrap

Lubomir Rintel lkundrak at v3.sk
Fri Mar 23 09:17:04 UTC 2018


This allows boostrapping Debian into LXC containers.

XXX: This currently relies on debootstrap fixes that are pending review:
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=890418
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=890419
The working debootstrap tree is here:
https://github.com/lkundrak/debootstrap/tree/lr/lxc-install
---
 virtinst/lxcinstaller.py | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/virtinst/lxcinstaller.py b/virtinst/lxcinstaller.py
index f5c416d52..c50710933 100644
--- a/virtinst/lxcinstaller.py
+++ b/virtinst/lxcinstaller.py
@@ -17,6 +17,7 @@
 # MA 02110-1301 USA.
 
 import os
+import re
 
 from . import urlfetcher
 from . import util
@@ -87,6 +88,22 @@ class LXCInstaller(Installer):
     # Run the bootstrap in installer phase #
     ########################################
 
+    def _init_debootstrap(self, guest):
+        if re.match(r'i[4-9]86', guest.os.arch):
+            arch = "i386"
+        elif guest.os.arch == "x86_64":
+            arch = "amd64"
+        else:
+            arch = guest.os.arch
+
+        guest.os.init = "/usr/sbin/debootstrap"
+        guest.os.initargs.add_new().val = "--arch"
+        guest.os.initargs.add_new().val = arch
+        guest.os.initargs.add_new().val = self._repo_version
+        guest.os.initargs.add_new().val = self._target_tree
+        if self._repo_url:
+            guest.os.initargs.add_new().val = self._repo_url
+
     ########################
     # Private method impls #
     ########################
@@ -130,6 +147,9 @@ class LXCInstaller(Installer):
         self._remove_installed_config(guest)
 
         if isinstall:
-            raise ValueError(_("%s repositories are not supported") % self._repo_type)
+            if self._repo_type == "deb":
+                self._init_debootstrap(guest)
+            else:
+                raise ValueError(_("%s repositories are not supported") % self._repo_type)
         else:
             self._restore_installed_config(guest)
-- 
2.14.3




More information about the virt-tools-list mailing list