]> git.siccegge.de Git - forks/vmdebootstrap.git/blobdiff - vmdebootstrap
Let configure-apt be optional to prevent duplicate apt sources on native.
[forks/vmdebootstrap.git] / vmdebootstrap
index 7f76b14a10ccb20d0f41b5a9c1d9fb5e991b025b..d7edde26646b82dc03358baea9d2ef3697117607 100755 (executable)
@@ -33,7 +33,9 @@ __version__ = '0.3'
 class VmDebootstrap(cliapp.Application):
 
     def add_settings(self):
-        default_arch = 'amd64'
+        default_arch = self.runcmd(
+            ["dpkg", "--print-architecture"],
+            ignore_fail=False).strip()
 
         self.settings.boolean(['verbose'], 'report what is going on')
         self.settings.string(['image'], 'put created disk image in FILE',
@@ -154,7 +156,8 @@ class VmDebootstrap(cliapp.Application):
             self.create_users(rootdir)
             self.remove_udev_persistent_rules(rootdir)
             self.setup_networking(rootdir)
-            self.configure_apt(rootdir)
+            if self.settings['configure-apt']:
+                self.configure_apt(rootdir)
             self.customize(rootdir)
             if self.settings['image']:
                 if self.settings['extlinux']:
@@ -242,8 +245,9 @@ class VmDebootstrap(cliapp.Application):
                      'set', '1', 'boot', 'on'])
 
     def install_mbr(self):
-        self.message('Installing MBR')
-        self.runcmd(['install-mbr', self.settings['image']])
+        if os.path.exists("/sbin/install-mbr"):
+            self.message('Installing MBR')
+            self.runcmd(['install-mbr', self.settings['image']])
 
     def setup_kpartx(self):
         out = self.runcmd(['kpartx', '-avs', self.settings['image']])
@@ -440,6 +444,9 @@ class VmDebootstrap(cliapp.Application):
                 f.write('\nS0:23:respawn:%s\n' % serial_command)
 
     def install_extlinux(self, rootdev, rootdir):
+        if not os.path.exists("/usr/bin/extlinux"):
+            self.message("extlinux not installed, skipping.")
+            return
         self.message('Installing extlinux')
 
         def find(pattern):
@@ -554,9 +561,9 @@ append initrd=%(initrd)s root=UUID=%(uuid)s ro %(kserial)s
         logging.debug('configure apt %s' % conf)
         f = open(conf, 'w')
         f.write('''
-        deb %(mirror)s %(distribution)s main
-        #deb-src %(mirror)s %(distribution)s main
-        ''' % {
+deb %(mirror)s %(distribution)s main
+#deb-src %(mirror)s %(distribution)s main
+''' % {
             'mirror': self.settings['mirror'],
             'distribution': self.settings['distribution']
         })