]> git.siccegge.de Git - forks/vmdebootstrap.git/blobdiff - vmdebootstrap
Prepare for 0.11 release
[forks/vmdebootstrap.git] / vmdebootstrap
index 163ee41d59d3147c48265bb500fc6bcfd690c9df..3cd526d81a261865a255ee01ff7b3544b713b463 100755 (executable)
@@ -30,7 +30,7 @@ import time
 from distro_info import DebianDistroInfo, UbuntuDistroInfo
 
 
-__version__ = '0.10'
+__version__ = '0.11'
 
 # pylint: disable=invalid-name,line-too-long,missing-docstring,too-many-branches
 
@@ -646,7 +646,8 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
             args.append('--foreign')
         if self.settings['debootstrapopts']:
             for opt in self.settings['debootstrapopts']:
-                args.append('--%s' % opt)
+                for part in opt.split(' '):
+                    args.append('--%s' % part)
         elif self.settings['variant']:
             args.append('--variant')
             args.append(self.settings['variant'])
@@ -785,18 +786,20 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
 
     def setup_networking(self, rootdir):
         self.message('Setting up networking')
+        ifc_file = os.path.join(rootdir, 'etc', 'network', 'interfaces')
+        ifc_d = os.path.join(rootdir, 'etc', 'network', 'interfaces.d')
 
-        # unconditionally write for wheezy (which became oldstable on 04/25/2015)
+        # unconditionally write for wheezy (which became oldstable 2015.04.25)
         if self.was_oldstable(datetime.date(2015, 4, 26)):
-            with open(os.path.join(rootdir, 'etc', 'network', 'interfaces'), 'w') as netfile:
+            with open(ifc_file, 'w') as netfile:
                 netfile.write('source /etc/network/interfaces.d/*\n')
-            os.mkdir(os.path.join(rootdir, 'etc', 'network', 'interfaces.d'))
-
-        elif not os.path.exists(os.path.join(rootdir, 'etc', 'network', 'interfaces')):
-            iface_path = os.path.join(rootdir, 'etc', 'network', 'interfaces')
-            with open(iface_path, 'w') as netfile:
+        elif not os.path.exists(ifc_file):
+            with open(ifc_file, 'a') as netfile:
                 netfile.write('source-directory /etc/network/interfaces.d\n')
-        ethpath = os.path.join(rootdir, 'etc', 'network', 'interfaces.d', 'setup')
+
+        if not os.path.exists(ifc_d):
+            os.mkdir(ifc_d)
+        ethpath = os.path.join(ifc_d, 'setup')
         with open(ethpath, 'w') as eth:
             eth.write('auto lo\n')
             eth.write('iface lo inet loopback\n')
@@ -1023,14 +1026,12 @@ append initrd=%(initrd)s root=UUID=%(uuid)s ro %(kserial)s
         logging.debug(
             "%s usage: %s", self.settings['image'],
             self.runcmd(['du', self.settings['image']]))
-        with open('/dev/tty', 'w') as tty:
-            try:
+        try:
+            with open('/dev/tty', 'w') as tty:
                 cliapp.runcmd([script, rootdir, self.settings['image']], stdout=tty, stderr=tty)
-            except IOError:
-                subprocess.call([script, rootdir, self.settings['image']])
-        logging.debug(
-            "%s usage: %s", self.settings['image'],
-            self.runcmd(['du', self.settings['image']]))
+        except IOError:
+            logging.debug('tty unavailable, trying in headless mode.')
+            subprocess.call([script, rootdir, self.settings['image']])
 
     def create_tarball(self, rootdir):
         # Create a tarball of the disk's contents