support vdfs and squashfs image creation
[tools/mic.git] / mic / kickstart / custom_commands / partition.py
1 #!/usr/bin/python -tt
2 #
3 # Marko Saukko <marko.saukko@cybercom.com>
4 #
5 # Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 #
7 # This copyrighted material is made available to anyone wishing to use, modify,
8 # copy, or redistribute it subject to the terms and conditions of the GNU
9 # General Public License v.2. This program is distributed in the hope that it
10 # will be useful, but WITHOUT ANY WARRANTY expressed or implied, including the
11 # implied warranties of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 # See the GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License along with
15 # this program; if not, write to the Free Software Foundation, Inc., 51
16 # Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 from pykickstart.commands.partition import *
19
20 class Mic_PartData(FC4_PartData):
21     removedKeywords = FC4_PartData.removedKeywords
22     removedAttrs = FC4_PartData.removedAttrs
23
24     def __init__(self, *args, **kwargs):
25         FC4_PartData.__init__(self, *args, **kwargs)
26         self.deleteRemovedAttrs()
27         self.align = kwargs.get("align", None)
28         self.extopts = kwargs.get("extopts", None)
29         self.part_type = kwargs.get("part_type", None)
30         self.uuid = kwargs.get("uuid", None)
31         self.exclude_image = kwargs.get("exclude_from_image", False)
32         self.vdfsopts = kwargs.get("vdfsopts", None)
33         self.squashfsopts = kwargs.get("squashfsopts", None)
34
35     def _getArgsAsStr(self):
36         retval = FC4_PartData._getArgsAsStr(self)
37
38         if self.align:
39             retval += " --align"
40         if self.extopts:
41             retval += " --extoptions=%s" % self.extopts
42         if self.part_type:
43             retval += " --part-type=%s" % self.part_type
44         if self.uuid:
45             retval += " --uuid=%s" % self.uuid
46         if self.exclude_image:
47             retval += " --exclude-from-image"
48         if self.vdfsopts:
49             retval += " --vdfsoptions=%s" % self.vdfsopts
50         if self.squashfsopts:
51             retval += " --squashfsoptions=%s" % self.squashfsopts
52
53         return retval
54
55 class Mic_Partition(FC4_Partition):
56     removedKeywords = FC4_Partition.removedKeywords
57     removedAttrs = FC4_Partition.removedAttrs
58
59     def _getParser(self):
60         op = FC4_Partition._getParser(self)
61         # The alignment value is given in kBytes. e.g., value 8 means that
62         # the partition is aligned to start from 8096 byte boundary.
63         op.add_option("--align", type="int", action="store", dest="align",
64                       default=None)
65         op.add_option("--extoptions", type="string", action="store", dest="extopts",
66                       default=None)
67         op.add_option("--part-type", type="string", action="store", dest="part_type",
68                       default=None)
69         op.add_option("--uuid", dest="uuid", action="store", type="string")
70         op.add_option("--exclude-from-image", action="store_true", dest="exclude_image",
71                       default=False)
72         op.add_option("--vdfsoptions", type="string", action="store", dest="vdfsopts",
73                       default=None)
74         op.add_option("--squashfsoptions", type="string", action="store", dest="squashfsopts",
75                       default=None)
76         return op