diff options
-rwxr-xr-x | writeexts.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/writeexts.py b/writeexts.py index 9caab839..aea08085 100755 --- a/writeexts.py +++ b/writeexts.py @@ -65,7 +65,8 @@ class WriteExtension(cliapp.Application): self.create_factory(mp, temp_root) self.create_fstab(mp) self.create_factory_run(mp) - self.install_extlinux(mp) + if self.bootloader_is_wanted(): + self.install_extlinux(mp) except BaseException, e: sys.stderr.write('Error creating disk image') self.unmount(mp) @@ -229,6 +230,28 @@ class WriteExtension(cliapp.Application): else: return [] + def bootloader_is_wanted(self): + '''Does the user request a bootloader? + + The user may set $BOOTLOADER to yes, no, or auto. If not + set, auto is the default and means that the bootloader will + be installed on x86-32 and x86-64, but not otherwise. + + ''' + + def is_x86(arch): + return (arch == 'x86_64' or + (arch.startswith('i') and arch.endswith('86'))) + + value = os.environ.get('BOOTLOADER', 'auto') + if value == 'auto': + if is_x86(os.uname()[-1]): + value = 'yes' + else: + value = 'no' + + return value == 'yes' + def parse_autostart(self): '''Parse $AUTOSTART to determine if VMs should be started.''' |