def _generate_boot_partition(self): """ Generates the start and size (in cylinders) of the boot partition. """ boot = Partition('boot') # Config variables boot_partition_size_mb = \ self._config.get_clean('CONFIG_INSTALLER_UBOOT_PARTITION_SIZE') if self._config.has_option('CONFIG_BSP_ARCH_SD_CARD_INSTALLER_BOOTLOADER_OUT_OF_FS'): boot.start = 1 # Leave room for the MBR at cylinder 0 else: boot.start = 0 if boot_partition_size_mb == geometry.FULL_SIZE: boot.size = geometry.FULL_SIZE else: boot_partition_size_b = float(int(boot_partition_size_mb) << 20) boot_partition_size = math.ceil(boot_partition_size_b / geometry.CYLINDER_BYTE_SIZE) boot.size = int(boot_partition_size) # Boot partition is bootable boot.bootable = True # Boot partition is FAT32/VFAT boot.type = Partition.TYPE_FAT32_LBA boot.filesystem = Partition.FILESYSTEM_VFAT # Boot components are: bootloader and kernel. boot.components = [boot.COMPONENT_BOOTLOADER, boot.COMPONENT_KERNEL] self._partitions.append(boot)
def _generate_rootfs_partition(self): """ Generates the information for the rootfs (filesystem) partition. """ rootfs = Partition('rootfs') rootfs.filesystem = Partition.FILESYSTEM_UNKNOWN if self._config.has_option('CONFIG_INSTALLER_SD_ROOTFS_TYPE_EXT3'): rootfs.filesystem = Partition.FILESYSTEM_EXT3 elif self._config.has_option('CONFIG_INSTALLER_SD_ROOTFS_TYPE_EXT4'): rootfs.filesystem = Partition.FILESYSTEM_EXT4 elif self._config.has_option('CONFIG_INSTALLER_SD_ROOTFS_TYPE_EXT4_NO_JOURNAL'): rootfs.filesystem = Partition.FILESYSTEM_EXT4_WRITEBACK rootfs.type = Partition.TYPE_UNKNOWN if (rootfs.filesystem == Partition.FILESYSTEM_EXT3 or rootfs.filesystem == Partition.FILESYSTEM_EXT4 or rootfs.filesystem == Partition.FILESYSTEM_EXT4_WRITEBACK): rootfs.type = Partition.TYPE_LINUX_NATIVE # If the partition filesystem for rootfs was not specified, assume # Linux native, ext4. if rootfs.filesystem == Partition.FILESYSTEM_UNKNOWN: rootfs.filesystem = Partition.FILESYSTEM_EXT4 rootfs.type = Partition.TYPE_LINUX_NATIVE # Take the whole SD card rootfs.start = 1 rootfs.size = geometry.FULL_SIZE rootfs.bootable = False rootfs.components = [rootfs.COMPONENT_ROOTFS] self._partitions.append(rootfs)
def _generate_rootfs_partition(self): """ Generates the information for the rootfs (filesystem) partition. """ rootfs = Partition('rootfs') rootfs.filesystem = Partition.FILESYSTEM_UNKNOWN if self._config.has_option('CONFIG_INSTALLER_SD_ROOTFS_TYPE_EXT3'): rootfs.filesystem = Partition.FILESYSTEM_EXT3 elif self._config.has_option('CONFIG_INSTALLER_SD_ROOTFS_TYPE_EXT4'): rootfs.filesystem = Partition.FILESYSTEM_EXT4 elif self._config.has_option( 'CONFIG_INSTALLER_SD_ROOTFS_TYPE_EXT4_NO_JOURNAL'): rootfs.filesystem = Partition.FILESYSTEM_EXT4_WRITEBACK rootfs.type = Partition.TYPE_UNKNOWN if (rootfs.filesystem == Partition.FILESYSTEM_EXT3 or rootfs.filesystem == Partition.FILESYSTEM_EXT4 or rootfs.filesystem == Partition.FILESYSTEM_EXT4_WRITEBACK): rootfs.type = Partition.TYPE_LINUX_NATIVE # If the partition filesystem for rootfs was not specified, assume # Linux native, ext4. if rootfs.filesystem == Partition.FILESYSTEM_UNKNOWN: rootfs.filesystem = Partition.FILESYSTEM_EXT4 rootfs.type = Partition.TYPE_LINUX_NATIVE # Take the whole SD card rootfs.start = 1 rootfs.size = geometry.FULL_SIZE rootfs.bootable = False rootfs.components = [rootfs.COMPONENT_ROOTFS] self._partitions.append(rootfs)
def _generate_boot_partition(self): boot = Partition('boot') if self._config.has_option('CONFIG_BSP_ARCH_SD_CARD_INSTALLER_BOOTLOADER_OUT_OF_FS'): boot.start = 1 # Leave room for the MBR at cylinder 0 else: boot.start = 0 boot.size = geometry.FULL_SIZE boot.bootable = True boot.type = Partition.TYPE_FAT32_LBA boot.filesystem = Partition.FILESYSTEM_VFAT boot.components = [boot.COMPONENT_BOOTLOADER] self._partitions.append(boot)
def _generate_boot_partition(self): boot = Partition('boot') if self._config.has_option( 'CONFIG_BSP_ARCH_SD_CARD_INSTALLER_BOOTLOADER_OUT_OF_FS'): boot.start = 1 # Leave room for the MBR at cylinder 0 else: boot.start = 0 boot.size = geometry.FULL_SIZE boot.bootable = True boot.type = Partition.TYPE_FAT32_LBA boot.filesystem = Partition.FILESYSTEM_VFAT boot.components = [boot.COMPONENT_BOOTLOADER] self._partitions.append(boot)
def _generate_boot_partition(self): """ Generates the start and size (in cylinders) of the boot partition. """ boot = Partition('boot') # Config variables boot_partition_size_mb = \ self._config.get_clean('CONFIG_INSTALLER_UBOOT_PARTITION_SIZE') if self._config.has_option( 'CONFIG_BSP_ARCH_SD_CARD_INSTALLER_BOOTLOADER_OUT_OF_FS'): boot.start = 1 # Leave room for the MBR at cylinder 0 else: boot.start = 0 if boot_partition_size_mb == geometry.FULL_SIZE: boot.size = geometry.FULL_SIZE else: boot_partition_size_b = float(int(boot_partition_size_mb) << 20) boot_partition_size = math.ceil(boot_partition_size_b / geometry.CYLINDER_BYTE_SIZE) boot.size = int(boot_partition_size) # Boot partition is bootable boot.bootable = True # Boot partition is FAT32/VFAT boot.type = Partition.TYPE_FAT32_LBA boot.filesystem = Partition.FILESYSTEM_VFAT # Boot components are: bootloader and kernel. boot.components = [boot.COMPONENT_BOOTLOADER, boot.COMPONENT_KERNEL] self._partitions.append(boot)
def read(self, filename): """ Reads the partitions information from the given file. Side effect: Existing information for partitions will be overwritten. """ if not os.path.exists(filename): self._logger.error('File %s does not exist' % filename) return # Reset the list self._partitions[:] = [] config = ConfigParser.RawConfigParser() config.readfp(open(filename)) # Uboot if config.has_section("boot"): name = "" size = "" start = "" part_type = "" filesystem = "" bootable = False if config.has_option("boot", "name"): name = config.get("boot", "name") if config.has_option("boot", "start"): start = config.get("boot", "start") if config.has_option("boot", "size"): size = config.get("boot", "size") if config.has_option("boot", "bootable"): bootable = config.getboolean("boot", "bootable") if config.has_option("boot", "type"): part_type = config.get("boot", "type") if config.has_option("boot", "filesystem"): filesystem = config.get("boot", "filesystem") uboot = Partition(name) uboot.start = int(start) if size == geometry.FULL_SIZE: uboot.size = size else: uboot.size = int(size) uboot.bootable = bootable uboot.type = part_type uboot.filesystem = filesystem self._partitions.append(uboot) # Filesystem if config.has_section("rootfs"): name = "" size = "" start = "" part_type = "" filesystem = "" bootable = False if config.has_option("rootfs", "name"): name = config.get("rootfs", "name") if config.has_option("rootfs", "start"): start = config.get("rootfs", "start") if config.has_option("rootfs", "size"): size = config.get("rootfs", "size") if config.has_option("rootfs", "bootable"): bootable = config.getboolean("rootfs", "bootable") if config.has_option("rootfs", "type"): part_type = config.get("rootfs", "type") if config.has_option("rootfs", "filesystem"): filesystem = config.get("rootfs", "filesystem") fs = Partition(name) fs.start = int(start) if size == geometry.FULL_SIZE: fs.size = size else: fs.size = int(size) fs.bootable = bootable fs.type = part_type fs.filesystem = filesystem self._partitions.append(fs)