]> git.siccegge.de Git - forks/vmdebootstrap.git/blobdiff - vmdebootstrap
Reinstate headless support if there is no /dev/tty
[forks/vmdebootstrap.git] / vmdebootstrap
index 78f098270b77050e19f36cd382df633036e67949..4c3aefc0f64d396ae3809e880c174a291d36bf08 100755 (executable)
@@ -263,7 +263,7 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
 
         # wheezy (which became oldstable on 04/25/2015) only had amd64 uefi
         if self.was_oldstable(datetime.date(2015, 4, 26)):
-            if self.settings['arch'] != 'amd64':
+            if self.settings['use-uefi'] and self.settings['arch'] != 'amd64':
                 raise cliapp.AppException(
                     'Only amd64 supports UEFI in Wheezy')
 
@@ -1017,14 +1017,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