]> git.siccegge.de Git - forks/vmdebootstrap.git/blobdiff - vmdebootstrap
Create useable fstab for kfreebsd systems
[forks/vmdebootstrap.git] / vmdebootstrap
index f5041cde93025de934a9c17422f4dfa24b3bdc5b..c9764ae67c44fffe66cdff7b42d23fe4acbca7a6 100755 (executable)
@@ -700,24 +700,33 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
 
     def create_fstab(self, rootdir, rootdev, roottype, bootdev, boottype):  # pylint: disable=too-many-arguments
         def fsuuid(device):
-            out = self.runcmd(['blkid', '-c', '/dev/null', '-o', 'value',
-                               '-s', 'UUID', device])
-            return out.splitlines()[0].strip()
+            if 'freebsd' in os.sys.platform:
+                out = self.runcmd(['grub-probe', '-d', device, '-t', 'fs_uuid'])
+                return "/dev/ufsid/%s" % out.strip()
+            else:
+                out = self.runcmd(['blkid', '-c', '/dev/null', '-o', 'value',
+                                '-s', 'UUID', device])
+                return "UUID=%s" % out.splitlines()[0].strip()
 
         if rootdev:
-            rootdevstr = 'UUID=%s' % fsuuid(rootdev)
+            rootdevstr = fsuuid(rootdev)
         else:
             rootdevstr = '/dev/sda1'
 
         if bootdev and not self.settings['use-uefi']:
-            bootdevstr = 'UUID=%s' % fsuuid(bootdev)
+            bootdevstr = fsuuid(bootdev)
         else:
             bootdevstr = None
 
         fstab = os.path.join(rootdir, 'etc', 'fstab')
         with open(fstab, 'w') as f:
-            f.write('proc /proc proc defaults 0 0\n')
-            f.write('%s / %s errors=remount-ro 0 1\n' % (rootdevstr, roottype))
+            if 'freebsd' in os.sys.platform:
+                f.write('proc  /proc   linprocfs rw 0 0\n')
+                f.write('sys   /sys    linsysfs  rw 0 0\n')
+                f.write('fdesc /dev/fd fdescfs   rw 0 0\n')
+            else:
+                f.write('proc /proc proc defaults 0 0\n')
+            f.write('%s / %s rw 0 1\n' % (rootdevstr, roottype))
             if bootdevstr:
                 f.write('%s /boot %s errors=remount-ro 0 2\n' % (bootdevstr, boottype))
                 if self.settings['swap'] > 0:
@@ -854,12 +863,20 @@ class VmDebootstrap(cliapp.Application):  # pylint: disable=too-many-public-meth
             cfg.write("%s\n" % command)
 
     def _mount_wrapper(self, rootdir):
-        self.runcmd(['mount', '/dev', '-t', 'devfs', '-obind',
-                     '%s' % os.path.join(rootdir, 'dev')])
-        self.runcmd(['mount', '/proc', '-t', 'proc', '-obind',
-                     '%s' % os.path.join(rootdir, 'proc')])
-        self.runcmd(['mount', '/sys', '-t', 'sysfs', '-obind',
-                     '%s' % os.path.join(rootdir, 'sys')])
+        if 'freebsd' in os.sys.platform:
+            self.runcmd(['mount', 'dev', '-t', 'devfs',
+                        '%s' % os.path.join(rootdir, 'dev')])
+            self.runcmd(['mount', 'proc', '-t', 'linprocfs',
+                        '%s' % os.path.join(rootdir, 'proc')])
+            self.runcmd(['mount', 'sys', '-t', 'linsysfs',
+                        '%s' % os.path.join(rootdir, 'sys')])
+        else:
+            self.runcmd(['mount', '/dev', '-t', 'devfs', '-obind',
+                        '%s' % os.path.join(rootdir, 'dev')])
+            self.runcmd(['mount', '/proc', '-t', 'proc', '-obind',
+                        '%s' % os.path.join(rootdir, 'proc')])
+            self.runcmd(['mount', '/sys', '-t', 'sysfs', '-obind',
+                        '%s' % os.path.join(rootdir, 'sys')])
 
     def _umount_wrapper(self, rootdir):
         self.runcmd(['umount', os.path.join(rootdir, 'sys')])