• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python partitionedfs.PartitionedMount类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mic.utils.partitionedfs.PartitionedMount的典型用法代码示例。如果您正苦于以下问题:Python PartitionedMount类的具体用法?Python PartitionedMount怎么用?Python PartitionedMount使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了PartitionedMount类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: do_unpack

    def do_unpack(cls, srcimg):
        srcimgsize = (misc.get_file_size(srcimg)) * 1024L * 1024L
        srcmnt = misc.mkdtemp("srcmnt")
        disk = fs_related.SparseLoopbackDisk(srcimg, srcimgsize)
        srcloop = PartitionedMount({'/dev/sdb':disk}, srcmnt, skipformat = True)

        srcloop.add_partition(srcimgsize/1024/1024, "/dev/sdb", "/", "ext3", boot=False)
        try:
            srcloop.mount()

        except errors.MountError:
            srcloop.cleanup()
            raise

        image = os.path.join(tempfile.mkdtemp(dir = "/var/tmp", prefix = "tmp"), "target.img")
        args = ['dd', "if=%s" % srcloop.partitions[0]['device'], "of=%s" % image]

        msger.info("`dd` image ...")
        rc = runner.show(args)
        srcloop.cleanup()
        shutil.rmtree(os.path.dirname(srcmnt), ignore_errors = True)

        if rc != 0:
            raise errors.CreatorError("Failed to dd")
        else:
            return image
开发者ID:xiaoqiang0,项目名称:mic,代码行数:26,代码来源:raw_plugin.py


示例2: _mount_instroot

    def _mount_instroot(self, base_on = None):
        self.__imgdir = self._mkdtemp()

        parts = self._get_parts()

        #create disk
        for item in self.get_diskinfo():
            msger.debug("Adding disk %s as %s/%s-%s.raw with size %s bytes" %
                        (item['name'], self.__imgdir, self.name, item['name'],
                         item['size']))

            disk = fs_related.SparseLoopbackDisk("%s/%s-%s.raw" % (
                                                                self.__imgdir,
                                                                self.name,
                                                                item['name']),
                                                 item['size'])
            self.__disks[item['name']] = disk

        self.__instloop = PartitionedMount(self.__disks, self._instroot)

        for p in parts:
            self.__instloop.add_partition(int(p.size),
                                          p.disk,
                                          p.mountpoint,
                                          p.fstype,
                                          fsopts = p.fsopts,
                                          boot = p.active,
                                          align = p.align)

        self.__instloop.mount()
        self._create_mkinitrd_config()
开发者ID:lbt,项目名称:mic,代码行数:31,代码来源:raw.py


示例3: _mount_instroot

    def _mount_instroot(self, base_on = None):
        parts = self._get_parts()
        self.__instloop = PartitionedMount(self._instroot)

        for p in parts:
            self.__instloop.add_partition(int(p.size),
                                          p.disk,
                                          p.mountpoint,
                                          p.fstype,
                                          p.label,
                                          fsopts = p.fsopts,
                                          boot = p.active,
                                          align = p.align,
                                          part_type = p.part_type)

        self.__instloop.layout_partitions(self._ptable_format)

        # Create the disks
        self.__imgdir = self._mkdtemp()
        for disk_name, disk in self.__instloop.disks.items():
            full_path = self._full_path(self.__imgdir, disk_name, "raw")
            msger.debug("Adding disk %s as %s with size %s bytes" \
                        % (disk_name, full_path, disk['min_size']))

            disk_obj = fs_related.SparseLoopbackDisk(full_path,
                                                     disk['min_size'])
            self.__disks[disk_name] = disk_obj
            self.__instloop.add_disk(disk_name, disk_obj)

        self.__instloop.mount()
        self._create_mkinitrd_config()
开发者ID:tizenorg,项目名称:tools.mic,代码行数:31,代码来源:raw.py


示例4: do_unpack

    def do_unpack(cls, srcimg):
        img = srcimg
        imgsize = misc.get_file_size(img) * 1024L * 1024L
        imgmnt = misc.mkdtemp()
        disk = fs_related.SparseLoopbackDisk(img, imgsize)
        imgloop = PartitionedMount({"/dev/sdb": disk}, imgmnt, skipformat=True)
        imgloop.add_partition(imgsize / 1024 / 1024, "/dev/sdb", "/", "vfat", boot=False)
        try:
            imgloop.mount()
        except errors.MountError:
            imgloop.cleanup()
            raise

        # legacy LiveOS filesystem layout support, remove for F9 or F10
        if os.path.exists(imgmnt + "/squashfs.img"):
            squashimg = imgmnt + "/squashfs.img"
        else:
            squashimg = imgmnt + "/LiveOS/squashfs.img"

        tmpoutdir = misc.mkdtemp()
        # unsquashfs requires outdir mustn't exist
        shutil.rmtree(tmpoutdir, ignore_errors=True)
        misc.uncompress_squashfs(squashimg, tmpoutdir)

        try:
            # legacy LiveOS filesystem layout support, remove for F9 or F10
            if os.path.exists(tmpoutdir + "/os.img"):
                os_image = tmpoutdir + "/os.img"
            else:
                os_image = tmpoutdir + "/LiveOS/ext3fs.img"

            if not os.path.exists(os_image):
                raise errors.CreatorError(
                    "'%s' is not a valid live CD ISO : neither " "LiveOS/ext3fs.img nor os.img exist" % img
                )
            imgname = os.path.basename(srcimg)
            imgname = os.path.splitext(imgname)[0] + ".img"
            rtimage = os.path.join(tempfile.mkdtemp(dir="/var/tmp", prefix="tmp"), imgname)
            shutil.copyfile(os_image, rtimage)

        finally:
            imgloop.cleanup()
            shutil.rmtree(tmpoutdir, ignore_errors=True)
            shutil.rmtree(imgmnt, ignore_errors=True)

        return rtimage
开发者ID:JussiPakkanen,项目名称:mic,代码行数:46,代码来源:liveusb_plugin.py


示例5: _mount_instroot

    def _mount_instroot(self, base_on = None):
        self.__imgdir = self._mkdtemp()

        #Set a default partition if no partition is given out
        if not self.ks.handler.partition.partitions:
            partstr = "part / --size 1900 --ondisk sda --fstype=ext3"
            args = partstr.split()
            pd = self.ks.handler.partition.parse(args[1:])
            if pd not in self.ks.handler.partition.partitions:
                self.ks.handler.partition.partitions.append(pd)

        #list of partitions from kickstart file
        parts = kickstart.get_partitions(self.ks)

        #list of disks where a disk is an dict with name: and size
        disks = []

        for i in range(len(parts)):
            if parts[i].disk:
                disk = parts[i].disk
            else:
                raise CreatorError("Failed to create disks, no --ondisk specified in partition line of ks file")

            if not parts[i].fstype:
                 raise CreatorError("Failed to create disks, no --fstype specified in partition line of ks file")

            size =   parts[i].size * 1024L * 1024L

            found = False
            for j in range(len(disks)):
                if disks[j]['name'] == disk:
                    disks[j]['size'] = disks[j]['size'] + size
                    found = True
                    break
                else:
                    found = False
            if not found:
                disks.append({ 'name': disk, 'size': size })

        #create disk
        for item in disks:
            msger.debug("Adding disk %s as %s/%s-%s.raw" % (item['name'], self.__imgdir,self.name, item['name']))
            disk = fs_related.SparseLoopbackDisk("%s/%s-%s.raw" % (self.__imgdir,self.name, item['name']),item['size'])
            self.__disks[item['name']] = disk

        self.__instloop = PartitionedMount(self.__disks, self._instroot)

        for p in parts:
            self.__instloop.add_partition(int(p.size), p.disk, p.mountpoint, p.fstype, fsopts = p.fsopts, boot = p.active)

        self.__instloop.mount()
        self._create_mkinitrd_config()
开发者ID:xiaoqiang0,项目名称:mic,代码行数:52,代码来源:raw.py


示例6: _create_usbimg

    def _create_usbimg(self, isodir):
        overlaysizemb = 64 #default
        #skipcompress = self.skip_compression?
        fstype = "vfat"
        homesizemb=0
        swapsizemb=0
        homefile="home.img"
        plussize=128
        kernelargs=None

        if fstype == 'vfat':
            if overlaysizemb > 2047:
                raise CreatorError("Can't have an overlay of 2048MB or "
                                   "greater on VFAT")

            if homesizemb > 2047:
                raise CreatorError("Can't have an home overlay of 2048MB or "
                                   "greater on VFAT")

            if swapsizemb > 2047:
                raise CreatorError("Can't have an swap overlay of 2048MB or "
                                   "greater on VFAT")

        livesize = misc.get_file_size(isodir + "/LiveOS")

        usbimgsize = (overlaysizemb + \
                      homesizemb + \
                      swapsizemb + \
                      livesize + \
                      plussize) * 1024L * 1024L

        disk = fs_related.SparseLoopbackDisk("%s/%s.usbimg" \
                                                 % (self._outdir, self.name),
                                             usbimgsize)
        usbmnt = self._mkdtemp("usb-mnt")
        usbloop = PartitionedMount(usbmnt)
        usbloop.add_disk('/dev/sdb', disk)

        usbloop.add_partition(usbimgsize/1024/1024,
                              "/dev/sdb",
                              "/",
                              fstype,
                              boot=True)

        usbloop.mount()

        try:
            fs_related.makedirs(usbmnt + "/LiveOS")

            if os.path.exists(isodir + "/LiveOS/squashfs.img"):
                shutil.copyfile(isodir + "/LiveOS/squashfs.img",
                                usbmnt + "/LiveOS/squashfs.img")
            else:
                fs_related.mksquashfs(os.path.dirname(self._image),
                                      usbmnt + "/LiveOS/squashfs.img")

            if os.path.exists(isodir + "/LiveOS/osmin.img"):
                shutil.copyfile(isodir + "/LiveOS/osmin.img",
                                usbmnt + "/LiveOS/osmin.img")

            if fstype == "vfat" or fstype == "msdos":
                uuid = usbloop.partitions[0]['mount'].uuid
                label = usbloop.partitions[0]['mount'].fslabel
                usblabel = "UUID=%s-%s" % (uuid[0:4], uuid[4:8])
                overlaysuffix = "-%s-%s-%s" % (label, uuid[0:4], uuid[4:8])
            else:
                diskmount = usbloop.partitions[0]['mount']
                usblabel = "UUID=%s" % diskmount.uuid
                overlaysuffix = "-%s-%s" % (diskmount.fslabel, diskmount.uuid)

            args = ['cp', "-Rf", isodir + "/isolinux", usbmnt + "/syslinux"]
            rc = runner.show(args)
            if rc:
                raise CreatorError("Can't copy isolinux directory %s" \
                                   % (isodir + "/isolinux/*"))

            if os.path.isfile("/usr/share/syslinux/isolinux.bin"):
                syslinux_path = "/usr/share/syslinux"
            elif  os.path.isfile("/usr/lib/syslinux/isolinux.bin"):
                syslinux_path = "/usr/lib/syslinux"
            else:
                raise CreatorError("syslinux not installed : "
                                   "cannot find syslinux installation path")

            for f in ("isolinux.bin", "vesamenu.c32"):
                path = os.path.join(syslinux_path, f)
                if os.path.isfile(path):
                    args = ['cp', path, usbmnt + "/syslinux/"]
                    rc = runner.show(args)
                    if rc:
                        raise CreatorError("Can't copy syslinux file " + path)
                else:
                    raise CreatorError("syslinux not installed: "
                                       "syslinux file %s not found" % path)

            fd = open(isodir + "/isolinux/isolinux.cfg", "r")
            text = fd.read()
            fd.close()
            pattern = re.compile('CDLABEL=[^ ]*')
            text = pattern.sub(usblabel, text)
#.........这里部分代码省略.........
开发者ID:117111302,项目名称:poky,代码行数:101,代码来源:liveusb.py


示例7: DirectImageCreator


#.........这里部分代码省略.........
        bootloader handler since it's the one non-partition object in
        any setup.  By default the default plugin is set to the same
        plugin as the /boot partition; since we hang it off the
        bootloader object, the default can be explicitly set using the
        --source bootloader param.
        """
        return self.ks.handler.bootloader.source

    #
    # Actual implemention
    #
    def _mount_instroot(self, base_on = None):
        """
        For 'wic', we already have our build artifacts and don't want
        to loop mount anything to install into, we just create
        filesystems from the artifacts directly and combine them into
        a partitioned image.

        We still want to reuse as much of the basic mic machinery
        though; despite the fact that we don't actually do loop or any
        other kind of mounting we still want to do many of the same
        things to prepare images, so we basically just adapt to the
        basic framework and reinterpret what 'mounting' means in our
        context.

        _instroot would normally be something like
        /var/tmp/wic/build/imgcreate-s_9AKQ/install_root, for
        installing packages, etc.  We don't currently need to do that,
        so we simplify life by just using /var/tmp/wic/build as our
        workdir.
        """
        parts = self._get_parts()

        self.__instimage = PartitionedMount(self._instroot)

        for p in parts:
            # as a convenience, set source to the boot partition source
            # instead of forcing it to be set via bootloader --source
            if not self.ks.handler.bootloader.source and p.mountpoint == "/boot":
                self.ks.handler.bootloader.source = p.source

        for p in parts:
            # need to create the filesystems in order to get their
            # sizes before we can add them and do the layout.
            # PartitionedMount.mount() actually calls __format_disks()
            # to create the disk images and carve out the partitions,
            # then self.install() calls PartitionedMount.install()
            # which calls __install_partitition() for each partition
            # to dd the fs into the partitions.  It would be nice to
            # be able to use e.g. ExtDiskMount etc to create the
            # filesystems, since that's where existing e.g. mkfs code
            # is, but those are only created after __format_disks()
            # which needs the partition sizes so needs them created
            # before its called.  Well, the existing setup is geared
            # to installing packages into mounted filesystems - maybe
            # when/if we need to actually do package selection we
            # should modify things to use those objects, but for now
            # we can avoid that.

            fstab = self.__write_fstab(self.rootfs_dir.get("ROOTFS_DIR"))

            p.prepare(self, self.workdir, self.oe_builddir, self.rootfs_dir,
                      self.bootimg_dir, self.kernel_dir, self.native_sysroot)

            self._restore_fstab(fstab)
开发者ID:117111302,项目名称:poky,代码行数:66,代码来源:direct.py


示例8: _mount_instroot

    def _mount_instroot(self, base_on = None):
        """
        For 'wic', we already have our build artifacts and don't want
        to loop mount anything to install into, we just create
        filesystems from the artifacts directly and combine them into
        a partitioned image.

        We still want to reuse as much of the basic mic machinery
        though; despite the fact that we don't actually do loop or any
        other kind of mounting we still want to do many of the same
        things to prepare images, so we basically just adapt to the
        basic framework and reinterpret what 'mounting' means in our
        context.

        _instroot would normally be something like
        /var/tmp/wic/build/imgcreate-s_9AKQ/install_root, for
        installing packages, etc.  We don't currently need to do that,
        so we simplify life by just using /var/tmp/wic/build as our
        workdir.
        """
        parts = self._get_parts()

        self.__instimage = PartitionedMount(self._instroot)

        for p in parts:
            # as a convenience, set source to the boot partition source
            # instead of forcing it to be set via bootloader --source
            if not self.ks.handler.bootloader.source and p.mountpoint == "/boot":
                self.ks.handler.bootloader.source = p.source

        for p in parts:
            # need to create the filesystems in order to get their
            # sizes before we can add them and do the layout.
            # PartitionedMount.mount() actually calls __format_disks()
            # to create the disk images and carve out the partitions,
            # then self.install() calls PartitionedMount.install()
            # which calls __install_partitition() for each partition
            # to dd the fs into the partitions.  It would be nice to
            # be able to use e.g. ExtDiskMount etc to create the
            # filesystems, since that's where existing e.g. mkfs code
            # is, but those are only created after __format_disks()
            # which needs the partition sizes so needs them created
            # before its called.  Well, the existing setup is geared
            # to installing packages into mounted filesystems - maybe
            # when/if we need to actually do package selection we
            # should modify things to use those objects, but for now
            # we can avoid that.

            fstab = self.__write_fstab(self.rootfs_dir.get("ROOTFS_DIR"))

            p.prepare(self, self.workdir, self.oe_builddir, self.rootfs_dir,
                      self.bootimg_dir, self.kernel_dir, self.native_sysroot)

            self._restore_fstab(fstab)

            self.__instimage.add_partition(int(p.size),
                                           p.disk,
                                           p.mountpoint,
                                           p.source_file,
                                           p.fstype,
                                           p.label,
                                           fsopts = p.fsopts,
                                           boot = p.active,
                                           align = p.align,
                                           part_type = p.part_type)

        self.__instimage.layout_partitions(self._ptable_format)

        self.__imgdir = self.workdir
        for disk_name, disk in self.__instimage.disks.items():
            full_path = self._full_path(self.__imgdir, disk_name, "direct")
            msger.debug("Adding disk %s as %s with size %s bytes" \
                        % (disk_name, full_path, disk['min_size']))
            disk_obj = fs_related.DiskImage(full_path, disk['min_size'])
            self.__disks[disk_name] = disk_obj
            self.__instimage.add_disk(disk_name, disk_obj)

        self.__instimage.mount()
开发者ID:117111302,项目名称:poky,代码行数:78,代码来源:direct.py


示例9: do_chroot

    def do_chroot(cls, target, cmd=[]):
        img = target
        imgsize = misc.get_file_size(img) * 1024L * 1024L
        partedcmd = fs_related.find_binary_path("parted")
        disk = fs_related.SparseLoopbackDisk(img, imgsize)
        imgmnt = misc.mkdtemp()
        imgloop = PartitionedMount(imgmnt, skipformat = True)
        imgloop.add_disk('/dev/sdb', disk)
        img_fstype = "ext3"

        msger.info("Partition Table:")
        partnum = []
        for line in runner.outs([partedcmd, "-s", img, "print"]).splitlines():
            # no use strip to keep line output here
            if "Number" in line:
                msger.raw(line)
            if line.strip() and line.strip()[0].isdigit():
                partnum.append(line.strip()[0])
                msger.raw(line)

        rootpart = None
        if len(partnum) > 1:
            rootpart = msger.choice("please choose root partition", partnum)

        # Check the partitions from raw disk.
        # if choose root part, the mark it as mounted
        if rootpart:
            root_mounted = True
        else:
            root_mounted = False
        partition_mounts = 0
        for line in runner.outs([partedcmd,"-s",img,"unit","B","print"]).splitlines():
            line = line.strip()

            # Lines that start with number are the partitions,
            # because parted can be translated we can't refer to any text lines.
            if not line or not line[0].isdigit():
                continue

            # Some vars have extra , as list seperator.
            line = line.replace(",","")

            # Example of parted output lines that are handled:
            # Number  Start        End          Size         Type     File system     Flags
            #  1      512B         3400000511B  3400000000B  primary
            #  2      3400531968B  3656384511B  255852544B   primary  linux-swap(v1)
            #  3      3656384512B  3720347647B  63963136B    primary  fat16           boot, lba

            partition_info = re.split("\s+",line)

            size = partition_info[3].split("B")[0]

            if len(partition_info) < 6 or partition_info[5] in ["boot"]:
                # No filesystem can be found from partition line. Assuming
                # btrfs, because that is the only MeeGo fs that parted does
                # not recognize properly.
                # TODO: Can we make better assumption?
                fstype = "btrfs"
            elif partition_info[5] in ["ext2","ext3","ext4","btrfs"]:
                fstype = partition_info[5]
            elif partition_info[5] in ["fat16","fat32"]:
                fstype = "vfat"
            elif "swap" in partition_info[5]:
                fstype = "swap"
            else:
                raise errors.CreatorError("Could not recognize partition fs type '%s'." % partition_info[5])

            if rootpart and rootpart == line[0]:
                mountpoint = '/'
            elif not root_mounted and fstype in ["ext2","ext3","ext4","btrfs"]:
                # TODO: Check that this is actually the valid root partition from /etc/fstab
                mountpoint = "/"
                root_mounted = True
            elif fstype == "swap":
                mountpoint = "swap"
            else:
                # TODO: Assing better mount points for the rest of the partitions.
                partition_mounts += 1
                mountpoint = "/media/partition_%d" % partition_mounts

            if "boot" in partition_info:
                boot = True
            else:
                boot = False

            msger.verbose("Size: %s Bytes, fstype: %s, mountpoint: %s, boot: %s" % (size, fstype, mountpoint, boot))
            # TODO: add_partition should take bytes as size parameter.
            imgloop.add_partition((int)(size)/1024/1024, "/dev/sdb", mountpoint, fstype = fstype, boot = boot)

        try:
            imgloop.mount()

        except errors.MountError:
            imgloop.cleanup()
            raise

        try:
            if len(cmd) != 0:
                cmdline = ' '.join(cmd)
            else:
#.........这里部分代码省略.........
开发者ID:Javoe,项目名称:splicer_poky,代码行数:101,代码来源:raw_plugin.py


示例10: RawImageCreator


#.........这里部分代码省略.........
                if self._diskinfo[j]['name'] == disk:
                    self._diskinfo[j]['size'] = self._diskinfo[j]['size'] + size
                    found = True
                    break
                else:
                    found = False

            if not found:
                self._diskinfo.append({ 'name': disk, 'size': size })

        return self._diskinfo

    #
    # Actual implemention
    #
    def _mount_instroot(self, base_on = None):
        self.__imgdir = self._mkdtemp()

        parts = self._get_parts()

        #create disk
        for item in self.get_diskinfo():
            msger.debug("Adding disk %s as %s/%s-%s.raw with size %s bytes" %
                        (item['name'], self.__imgdir, self.name, item['name'],
                         item['size']))

            disk = fs_related.SparseLoopbackDisk("%s/%s-%s.raw" % (
                                                                self.__imgdir,
                                                                self.name,
                                                                item['name']),
                                                 item['size'])
            self.__disks[item['name']] = disk

        self.__instloop = PartitionedMount(self.__disks, self._instroot)

        for p in parts:
            self.__instloop.add_partition(int(p.size),
                                          p.disk,
                                          p.mountpoint,
                                          p.fstype,
                                          fsopts = p.fsopts,
                                          boot = p.active,
                                          align = p.align)

        self.__instloop.mount()
        self._create_mkinitrd_config()

    def _get_required_packages(self):
        required_packages = BaseImageCreator._get_required_packages(self)
        if not self.target_arch or not self.target_arch.startswith("arm"):
            required_packages += ["syslinux", "syslinux-extlinux"]
        return required_packages

    def _get_excluded_packages(self):
        return BaseImageCreator._get_excluded_packages(self)

    def _get_syslinux_boot_config(self):
        bootdevnum = None
        rootdevnum = None
        rootdev = None
        for p in self.__instloop.partitions:
            if p['mountpoint'] == "/boot":
                bootdevnum = p['num'] - 1
            elif p['mountpoint'] == "/" and bootdevnum is None:
                bootdevnum = p['num'] - 1
开发者ID:lbt,项目名称:mic,代码行数:66,代码来源:raw.py


示例11: RawImageCreator


#.........这里部分代码省略.........

        #get partition info from ks handler
        parts = self._get_parts()

        for i in range(len(parts)):
            if parts[i].disk:
                disk_name = parts[i].disk
            else:
                raise CreatorError("Failed to create disks, no --ondisk "
                                   "specified in partition line of ks file")

            if parts[i].mountpoint and not parts[i].fstype:
                raise CreatorError("Failed to create disks, no --fstype "
                                    "specified for partition with mountpoint "
                                    "'%s' in the ks file")

            self._disk_names.append(disk_name)

        return self._disk_names

    def _full_name(self, name, extention):
        """ Construct full file name for a file we generate. """
        return "%s-%s.%s" % (self.name, name, extention)

    def _full_path(self, path, name, extention):
        """ Construct full file path to a file we generate. """
        return os.path.join(path, self._full_name(name, extention))

    #
    # Actual implemention
    #
    def _mount_instroot(self, base_on = None):
        parts = self._get_parts()
        self.__instloop = PartitionedMount(self._instroot)

        for p in parts:
            self.__instloop.add_partition(int(p.size),
                                          p.disk,
                                          p.mountpoint,
                                          p.fstype,
                                          p.label,
                                          fsopts = p.fsopts,
                                          boot = p.active,
                                          align = p.align,
                                          part_type = p.part_type)

        self.__instloop.layout_partitions(self._ptable_format)

        # Create the disks
        self.__imgdir = self._mkdtemp()
        for disk_name, disk in self.__instloop.disks.items():
            full_path = self._full_path(self.__imgdir, disk_name, "raw")
            msger.debug("Adding disk %s as %s with size %s bytes" \
                        % (disk_name, full_path, disk['min_size']))

            disk_obj = fs_related.SparseLoopbackDisk(full_path,
                                                     disk['min_size'])
            self.__disks[disk_name] = disk_obj
            self.__instloop.add_disk(disk_name, disk_obj)

        self.__instloop.mount()
        self._create_mkinitrd_config()

    def mount(self, base_on = None, cachedir = None):
        """
        This method calls the base class' 'mount()' method and then creates
开发者ID:tizenorg,项目名称:tools.mic,代码行数:67,代码来源:raw.py


示例12: DirectImageCreator


#.........这里部分代码省略.........
        for p in parts:
            if p.mountpoint == "/boot":
                if p.fstype == "msdos":
                    boot_type = "pcbios"
                else:
                    boot_type = p.fstype
        return boot_type

    #
    # Actual implemention
    #
    def _mount_instroot(self, base_on = None):
        """
        For 'wic', we already have our build artifacts and don't want
        to loop mount anything to install into, we just create
        filesystems from the artifacts directly and combine them into
        a partitioned image.

        We still want to reuse as much of the basic mic machinery
        though; despite the fact that we don't actually do loop or any
        other kind of mounting we still want to do many of the same
        things to prepare images, so we basically just adapt to the
        basic framework and reinterpret what 'mounting' means in our
        context.

        _instroot would normally be something like
        /var/tmp/wic/build/imgcreate-s_9AKQ/install_root, for
        installing packages, etc.  We don't currently need to do that,
        so we simplify life by just using /var/tmp/wic/build as our
        workdir.
        """
        parts = self._get_parts()

        self.__instimage = PartitionedMount(self._instroot)

        fstab = self.__write_fstab()

        self.boot_type = self.get_boot_type()

        if not self.bootimg_dir:
            if self.boot_type == "pcbios":
                self.bootimg_dir = self.staging_data_dir
            elif self.boot_type == "efi":
                self.bootimg_dir = self.hdddir

        if self.boot_type == "pcbios":
            self._create_syslinux_config()
        elif self.boot_type == "efi":
            self._create_grubefi_config()
        else:
            raise CreatorError("Failed to detect boot type (no /boot partition?), "
                               "please check your kickstart setting.")

        for p in parts:
            if p.fstype == "efi":
                p.fstype = "msdos"
            # need to create the filesystems in order to get their
            # sizes before we can add them and do the layout.
            # PartitionedMount.mount() actually calls __format_disks()
            # to create the disk images and carve out the partitions,
            # then self.install() calls PartitionedMount.install()
            # which calls __install_partitition() for each partition
            # to dd the fs into the partitions.  It would be nice to
            # be able to use e.g. ExtDiskMount etc to create the
            # filesystems, since that's where existing e.g. mkfs code
            # is, but those are only created after __format_disks()
开发者ID:Dagaweyne,项目名称:yocto-for-pandaboard,代码行数:67,代码来源:direct.py



注:本文中的mic.utils.partitionedfs.PartitionedMount类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python runner.quiet函数代码示例发布时间:2022-05-27
下一篇:
Python misc.mkdtemp函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap