Ejemplo n.º 1
0
    def preInstallScripts(self):
        # /proc and /sys are already created and mounted
        self.createDirectory("dev")
        self.createDirectory("root")
        self.createDirectory("tmp")
        self.createDirectory("var")
        self.createDirectory("var/lock/subsys")
        self.createDirectory("boot/grub")
        self.createDirectory("etc/sysconfig/network-scripts")

        # Create fstab early for RPM scripts to use.  Use normal
        # defaults that will work on RPM-based and Conary-based
        # systems.  If this becomes insufficient, we will need
        # to add default fstab setup to product definition.
        fstab = ""
        for mountPoint in reversed(sortMountPoints(self.filesystems.keys())):
            fs = self.filesystems[mountPoint]

            if fs.fsType == "swap":
                fstab += "LABEL=%s\tswap\tswap\tdefaults\t0\t0\n" % fs.fsLabel
            elif fs.fsType not in ("none", "unallocated"):
                fstab += "LABEL=%s\t%s\t%s\tdefaults\t1\t%d\n" % (
                    (fs.fsLabel, mountPoint, fs.fsType, (mountPoint == "/") and 1 or 2)
                )

        # Add elements that might otherwise be missing:
        if "devpts " not in fstab:
            fstab += "devpts                  /dev/pts                devpts  gid=5,mode=620  0 0\n"
        if "/dev/shm " not in fstab:
            fstab += "tmpfs                   /dev/shm                tmpfs   defaults        0 0\n"
        if "/proc " not in fstab:
            fstab += "proc                    /proc                   proc    defaults        0 0\n"
        if "/sys " not in fstab:
            fstab += "sysfs                   /sys                    sysfs   defaults        0 0\n"
        if self.swapSize and self.swapPath:
            fstab += "%s\tswap\tswap\tdefaults\t0\t0\n" % self.swapPath

        self.createFile("etc/fstab", fstab)

        # Create devices that we need most of the time.
        for dev, type, major, minor, mode in self.devices:
            devicePath = self.filePath("dev/%s" % dev)
            if os.path.exists(devicePath):
                os.unlink(devicePath)

            if type == "c":
                flags = stat.S_IFCHR
            else:
                flags = stat.S_IFBLK

            # Create device.
            devnum = os.makedev(major, minor)
            os.mknod(devicePath, flags, devnum)
            os.chmod(devicePath, mode)
Ejemplo n.º 2
0
    def find_mount(self, path):
        """
        Return the mount point containing the given path.
        """

        if not path.endswith("/"):
            path += "/"
        path = path.endswith("/") and path or (path + "/")

        for mountPoint in sortMountPoints(self.filesystems.keys()):
            _mountPoint = mountPoint.endswith("/") and mountPoint or (mountPoint + "/")
            if path.startswith(_mountPoint):
                return mountPoint

        return "/"
Ejemplo n.º 3
0
 def umountAll(self):
     mounts = sortMountPoints(self.filesystems.keys())
     for mountPoint in mounts:
         self.filesystems[mountPoint].umount()
Ejemplo n.º 4
0
 def mountAll(self):
     rootDir = os.path.join(self.workDir, "root")
     mounts = sortMountPoints(self.filesystems.keys())
     for mountPoint in reversed(mounts):
         util.mkdirChain(rootDir + mountPoint)
         self.filesystems[mountPoint].mount(rootDir + mountPoint)