kiwi-el8/kiwi/partitioner/base.py
Marcus Schäfer 37c1e1e3a1
Allow to convert GPT into MBR
The type attribute force_mbr allows to convert a system selected
for use with a GPT to use an MBR (msdos table). The attribute
only takes effect on image configurations which would select the
GPT partitioner. This Fixes #236
2017-02-20 16:27:52 +01:00

101 lines
2.5 KiB
Python

# Copyright (c) 2015 SUSE Linux GmbH. All rights reserved.
#
# This file is part of kiwi.
#
# kiwi is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# kiwi is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with kiwi. If not, see <http://www.gnu.org/licenses/>
#
class PartitionerBase(object):
"""
Base class for partitioners
Attributes
* :attr:`disk_device`
disk device node
* :attr:`partition_id`
current partition number
* :attr:`flag_map`
initial partition type/flag map
"""
def __init__(self, disk_provider):
self.disk_device = disk_provider.get_device()
self.partition_id = 0
self.flag_map = None
self.post_init()
def post_init(self):
"""
Post initialization method
Implementation in specialized partitioner class
"""
pass
def get_id(self):
"""
Current partition number
Zero indicates no partition has been created so far
:return: partition number
:rtype: int
"""
return self.partition_id
def create(self, name, mbsize, type_name, flags=None):
"""
Create partition
Implementation in specialized partitioner class
:param string name: unused
:param int mbsize: unused
:param string type_name: unused
:param list flags: unused
"""
raise NotImplementedError
def set_flag(self, partition_id, flag_name):
"""
Set partition flag
Implementation in specialized partitioner class
:param int partition_id: unused
:param string flag_name: unused
"""
raise NotImplementedError
def set_hybrid_mbr(self):
"""
Turn partition table into hybrid table if supported
Implementation in specialized partitioner class
"""
raise NotImplementedError
def set_mbr(self):
"""
Turn partition table into MBR (msdos table)
Implementation in specialized partitioner class
"""
raise NotImplementedError